@webex/contact-center 3.12.0-next.158 → 3.12.0-next.159
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/ai-docs/contact-center-spec.md +3 -0
- package/dist/cc.js +10 -2
- package/dist/cc.js.map +1 -1
- package/dist/services/ApiAiAssistant.js +18 -0
- package/dist/services/ApiAiAssistant.js.map +1 -1
- package/dist/services/WebCallingService.js +10 -2
- package/dist/services/WebCallingService.js.map +1 -1
- package/dist/services/constants.js +11 -1
- package/dist/services/constants.js.map +1 -1
- package/dist/services/core/Utils.js +21 -1
- package/dist/services/core/Utils.js.map +1 -1
- package/dist/services/core/aqm-reqs.js +7 -15
- package/dist/services/core/aqm-reqs.js.map +1 -1
- package/dist/services/core/constants.js +9 -1
- package/dist/services/core/constants.js.map +1 -1
- package/dist/services/core/websocket/WebSocketManager.js +17 -1
- package/dist/services/core/websocket/WebSocketManager.js.map +1 -1
- package/dist/types/services/ApiAiAssistant.d.ts +9 -0
- package/dist/types/services/constants.d.ts +9 -0
- package/dist/types/services/core/Utils.d.ts +8 -0
- package/dist/types/services/core/constants.d.ts +7 -0
- package/dist/webex.js +1 -1
- package/package.json +1 -1
- package/src/cc.ts +15 -2
- package/src/services/ApiAiAssistant.ts +24 -0
- package/src/services/WebCallingService.ts +16 -2
- package/src/services/ai-docs/services-spec.md +8 -1
- package/src/services/constants.ts +10 -0
- package/src/services/core/Utils.ts +24 -0
- package/src/services/core/ai-docs/core-spec.md +23 -13
- package/src/services/core/aqm-reqs.ts +6 -15
- package/src/services/core/constants.ts +8 -0
- package/src/services/core/websocket/WebSocketManager.ts +26 -2
- package/test/unit/spec/cc.ts +21 -0
- package/test/unit/spec/services/ApiAiAssistant.ts +13 -0
- package/test/unit/spec/services/WebCallingService.ts +38 -0
- package/test/unit/spec/services/core/Utils.ts +22 -0
- package/test/unit/spec/services/core/aqm-reqs.ts +29 -0
- package/test/unit/spec/services/core/websocket/WebSocketManager.ts +64 -14
- package/umd/contact-center.min.js +2 -2
- package/umd/contact-center.min.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Err","_interopRequireWildcard","require","_types","_loggerProxy","_interopRequireDefault","_WebexRequest","_types2","_constants","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","isRecord","value","exports","getCommonErrorDetails","errObj","trackingId","headers","trackingid","TrackingID","msg","body","stripDialPlanChars","input","strippedChars","charsToStrip","Set","split","filter","c","join","isValidDialNumber","dialPlanEntries","LoggerProxy","warn","module","method","length","log","some","entry","sanitizedInput","regex","RegExp","test","name","getStationLoginErrorData","failure","loginOption","duplicateLocationMessage","LoginOption","EXTENSION","AGENT_DN","errorCodeMessageMap","DUPLICATE_LOCATION","message","fieldName","INVALID_DIAL_NUMBER","defaultMessage","defaultFieldName","reason","data","getErrorDetails","error","methodName","moduleName","errData","details","WebexRequest","getInstance","uploadLogs","correlationId","err","Error","generateTaskErrorObject","errorMsg","fallbackMessage","errorMessage","errorType","errorData","reasonCode","createErrDetailsObject","Details","getConsultedAgentId","media","agentId","consultParticipants","consultedParticipantId","keys","forEach","key","mType","STATE_CONSULT","participants","includes","id","find","participant","getDestAgentIdForCBT","interaction","consultingAgent","destAgentIdForCBT","foundEntry","entries","pType","toLowerCase","PARTICIPANT_TYPES","DN","type","AGENT","dn","calculateDestAgentId","destAgentIdCBT","EP_DN","epId","calculateDestType","destinationaegntId","destAgentType","undefined","CONSULT_TRANSFER_DESTINATION_TYPE","DIALNUMBER","ENTRYPOINT","buildConsultConferenceParamData","dataPassed","interactionIdPassed","to","destAgentId","destinationType","String","trim","normalizedDestinationType","toUpperCase","replace","DESTINATION_TYPE","QUEUE","interactionId","deriveConsultTransferDestinationType","taskData","destType","normalizedDestType"],"sources":["Utils.ts"],"sourcesContent":["import * as Err from './Err';\nimport {LoginOption, WebexRequestPayload} from '../../types';\nimport {Failure, AugmentedError} from './GlobalTypes';\nimport LoggerProxy from '../../logger-proxy';\nimport WebexRequest from './WebexRequest';\nimport {\n ConsultConferenceData,\n consultConferencePayloadData,\n ConsultTransferDestinationType,\n TaskData,\n CONSULT_TRANSFER_DESTINATION_TYPE,\n DESTINATION_TYPE,\n Interaction,\n InteractionParticipant,\n} from '../task/types';\nimport {PARTICIPANT_TYPES, STATE_CONSULT} from './constants';\nimport {DialPlan} from '../config/types';\n\n/** Returns whether a value is a non-null object with string keys. */\nexport const isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' && value !== null;\n\n/**\n * Extracts common error details from a Webex request payload.\n *\n * @param errObj - The Webex request payload object.\n * @returns An object containing the tracking ID and message body.\n * @private\n * @ignore\n */\nconst getCommonErrorDetails = (errObj: WebexRequestPayload) => {\n return {\n trackingId: errObj?.headers?.trackingid || errObj?.headers?.TrackingID,\n msg: errObj?.body,\n };\n};\n\n/**\n * Strips characters defined in the dial plan entry from the input string.\n *\n * @param input - The dial number to sanitize\n * @param strippedChars - String of characters to remove from the input\n * @returns The sanitized input with specified characters removed\n */\nexport const stripDialPlanChars = (input: string, strippedChars: string): string => {\n if (!strippedChars) {\n return input;\n }\n\n const charsToStrip = new Set(strippedChars.split(''));\n\n return input\n .split('')\n .filter((c) => !charsToStrip.has(c))\n .join('');\n};\n\n/**\n * Validates a dial number against the provided dial plan regex patterns.\n * A number is valid if it matches at least one regex pattern in the dial plans.\n * Skips validation when no dial plan entries are configured, deferring to the server.\n *\n * @param input - The dial number to validate\n * @param dialPlanEntries - Array of dial plan entries containing regex patterns\n * @returns true if the input matches at least one dial plan regex pattern or no entries are configured, false otherwise\n */\nexport const isValidDialNumber = (\n input: string,\n dialPlanEntries: DialPlan['dialPlanEntity']\n): boolean => {\n if (!input) {\n LoggerProxy.warn('Dial number is empty or undefined.', {\n module: 'Utils',\n method: 'isValidDialNumber',\n });\n\n return false;\n }\n\n if (!dialPlanEntries || dialPlanEntries.length === 0) {\n LoggerProxy.log(\n 'No dial plan entries found. Skipping client-side validation, deferring to server.',\n {module: 'Utils', method: 'isValidDialNumber'}\n );\n\n return true;\n }\n\n return dialPlanEntries.some((entry) => {\n try {\n const sanitizedInput = stripDialPlanChars(input, entry.strippedChars);\n const regex = new RegExp(entry.regex);\n\n return regex.test(sanitizedInput);\n } catch (e) {\n LoggerProxy.warn(`Failed to validate dial number against entry \"${entry.name}\": ${e}`, {\n module: 'Utils',\n method: 'isValidDialNumber',\n });\n\n return false;\n }\n });\n};\n\nexport const getStationLoginErrorData = (failure: Failure, loginOption: LoginOption) => {\n let duplicateLocationMessage = 'This value is already in use';\n\n if (loginOption === LoginOption.EXTENSION) {\n duplicateLocationMessage = 'This extension is already in use';\n }\n\n if (loginOption === LoginOption.AGENT_DN) {\n duplicateLocationMessage =\n 'Dial number is in use. Try a different one. For help, reach out to your administrator or support team.';\n }\n\n const errorCodeMessageMap = {\n DUPLICATE_LOCATION: {\n message: duplicateLocationMessage,\n fieldName: loginOption,\n },\n INVALID_DIAL_NUMBER: {\n message:\n 'Enter a valid dial number. For help, reach out to your administrator or support team.',\n fieldName: loginOption,\n },\n };\n\n const defaultMessage = 'An error occurred while logging in to the station';\n const defaultFieldName = 'generic';\n\n const reason = failure?.data?.reason || '';\n\n return {\n message: errorCodeMessageMap[reason]?.message || defaultMessage,\n fieldName: errorCodeMessageMap[reason]?.fieldName || defaultFieldName,\n };\n};\n\n/**\n * Extracts error details and logs the error. Also uploads logs for the error unless it is a silent relogin agent not found error.\n *\n * @param error - The error object, expected to have a `details` property of type Failure.\n * @param methodName - The name of the method where the error occurred.\n * @param moduleName - The name of the module where the error occurred.\n * @returns An object containing the error instance and the reason string.\n * @public\n * @example\n * const details = getErrorDetails(error, 'fetchData', 'DataModule');\n * if (details.error) { handleError(details.error); }\n * @ignore\n */\nexport const getErrorDetails = (error: any, methodName: string, moduleName: string) => {\n let errData = {message: '', fieldName: ''};\n\n const failure = error.details as Failure;\n const reason = failure?.data?.reason ?? `Error while performing ${methodName}`;\n\n if (!(reason === 'AGENT_NOT_FOUND' && methodName === 'silentRelogin')) {\n LoggerProxy.error(`${methodName} failed with reason: ${reason}`, {\n module: moduleName,\n method: methodName,\n trackingId: failure?.trackingId,\n });\n // we can add more conditions here if not needed for specific cases eg: silentReLogin\n WebexRequest.getInstance().uploadLogs({\n correlationId: failure?.trackingId,\n });\n }\n\n if (methodName === 'stationLogin') {\n errData = getStationLoginErrorData(failure, error.loginOption);\n\n LoggerProxy.error(\n `${methodName} failed with reason: ${reason}, message: ${errData.message}, fieldName: ${errData.fieldName}`,\n {\n module: moduleName,\n method: methodName,\n trackingId: failure?.trackingId,\n }\n );\n }\n\n const err = new Error(reason ?? `Error while performing ${methodName}`);\n // @ts-ignore - add custom property to the error object for backward compatibility\n err.data = errData;\n\n return {\n error: err,\n reason,\n };\n};\n\n/**\n * Extracts error details from task API errors and logs them. Also uploads logs for the error.\n * This handles the specific error format returned by task API calls.\n *\n * @param error - The error object from task API calls with structure: {id: string, details: {trackingId: string, msg: {...}}}\n * @param methodName - The name of the method where the error occurred.\n * @param moduleName - The name of the module where the error occurred.\n * @returns AugmentedError containing structured error details on err.data for metrics and logging\n * @public\n * @example\n * const taskError = generateTaskErrorObject(error, 'transfer', 'TaskModule');\n * throw taskError.error;\n * @ignore\n */\nexport const generateTaskErrorObject = (\n error: any,\n methodName: string,\n moduleName: string\n): AugmentedError => {\n const trackingId = error?.details?.trackingId || error?.trackingId || '';\n const errorMsg = error?.details?.msg;\n\n const fallbackMessage =\n (error && typeof error.message === 'string' && error.message) ||\n `Error while performing ${methodName}`;\n const errorMessage = errorMsg?.errorMessage || fallbackMessage;\n const errorType =\n errorMsg?.errorType ||\n (error && typeof error.name === 'string' && error.name) ||\n 'Unknown Error';\n const errorData = errorMsg?.errorData || '';\n const reasonCode = errorMsg?.reasonCode || 0;\n\n // Log and upload for Task API formatted errors\n LoggerProxy.error(`${methodName} failed: ${errorMessage} (${errorType})`, {\n module: moduleName,\n method: methodName,\n trackingId,\n });\n WebexRequest.getInstance().uploadLogs({\n correlationId: trackingId,\n });\n\n const reason = `${errorType}: ${errorMessage}${errorData ? ` (${errorData})` : ''}`;\n const err: AugmentedError = new Error(reason);\n err.data = {\n message: errorMessage,\n errorType,\n errorData,\n reasonCode,\n trackingId,\n };\n\n return err;\n};\n\n/**\n * Creates an error details object suitable for use with the Err.Details class.\n *\n * @param errObj - The Webex request payload object.\n * @returns An instance of Err.Details with the generic failure message and extracted details.\n * @public\n * @example\n * const errDetails = createErrDetailsObject(webexRequestPayload);\n * @ignore\n */\nexport const createErrDetailsObject = (errObj: WebexRequestPayload) => {\n const details = getCommonErrorDetails(errObj);\n\n return new Err.Details('Service.reqs.generic.failure', details);\n};\n\n/*\n/**\n * Gets the consulted agent ID from the media object by finding the agent\n * in the consult media participants (excluding the current agent).\n *\n * @param media - The media object from the interaction\n * @param agentId - The current agent's ID to exclude from the search\n * @returns The consulted agent ID, or empty string if none found\n */\nexport const getConsultedAgentId = (media: Interaction['media'], agentId: string): string => {\n let consultParticipants: string[] = [];\n let consultedParticipantId = '';\n\n Object.keys(media).forEach((key) => {\n if (media[key].mType === STATE_CONSULT) {\n consultParticipants = media[key].participants;\n }\n });\n\n if (consultParticipants.includes(agentId)) {\n const id = consultParticipants.find((participant) => participant !== agentId);\n consultedParticipantId = id || consultedParticipantId;\n }\n\n return consultedParticipantId;\n};\n\n/**\n * Gets the destination agent ID for CBT (Capacity Based Team) scenarios.\n * CBT refers to teams created in Control Hub with capacity-based routing\n * (as opposed to agent-based routing). This handles cases where the consulted\n * participant is not directly in participants but can be found by matching\n * the dial number (dn).\n *\n * @param interaction - The interaction object\n * @param consultingAgent - The consulting agent identifier\n * @returns The destination agent ID for CBT scenarios, or empty string if none found\n */\nexport const getDestAgentIdForCBT = (interaction: Interaction, consultingAgent: string): string => {\n const participants = interaction.participants;\n let destAgentIdForCBT = '';\n\n // Check if this is a CBT scenario (consultingAgent exists but not directly in participants)\n if (consultingAgent && !participants[consultingAgent]) {\n const foundEntry = Object.entries(participants).find(\n ([, participant]: [string, Interaction['participants'][string]]) => {\n return (\n participant.pType.toLowerCase() === PARTICIPANT_TYPES.DN &&\n participant.type === PARTICIPANT_TYPES.AGENT &&\n participant.dn === consultingAgent\n );\n }\n );\n\n if (foundEntry) {\n destAgentIdForCBT = foundEntry[0];\n }\n }\n\n return destAgentIdForCBT;\n};\n\n/**\n * Calculates the destination agent ID for consult operations.\n *\n * @param interaction - The interaction object\n * @param agentId - The current agent's ID\n * @returns The destination agent ID\n */\nexport const calculateDestAgentId = (interaction: Interaction, agentId: string): string => {\n const consultingAgent = getConsultedAgentId(interaction.media, agentId);\n\n // Check if this is a CBT (Capacity Based Team) scenario\n // If not CBT, the function will return empty string and we'll use the normal flow\n const destAgentIdCBT = getDestAgentIdForCBT(interaction, consultingAgent);\n if (destAgentIdCBT) {\n return destAgentIdCBT;\n }\n\n const participant = interaction.participants[consultingAgent];\n if (!participant) {\n return '';\n }\n\n if (participant.type === PARTICIPANT_TYPES.EP_DN) {\n return (participant as InteractionParticipant & {epId?: string}).epId ?? '';\n }\n\n return participant.id ?? '';\n};\n\n/**\n * Calculates the destination agent ID for fetching destination type.\n *\n * @param interaction - The interaction object\n * @param agentId - The current agent's ID\n * @returns The destination agent ID for determining destination type\n */\nexport const calculateDestType = (interaction: Interaction, agentId: string): string => {\n const consultingAgent = getConsultedAgentId(interaction.media, agentId);\n\n // Check if this is a CBT (Capacity Based Team) scenario, otherwise use consultingAgent\n const destAgentIdCBT = getDestAgentIdForCBT(interaction, consultingAgent);\n const destinationaegntId = destAgentIdCBT || consultingAgent;\n const destAgentType = destinationaegntId\n ? interaction.participants[destinationaegntId]?.pType\n : undefined;\n if (destAgentType) {\n if (destAgentType === 'DN') {\n return CONSULT_TRANSFER_DESTINATION_TYPE.DIALNUMBER;\n }\n if (destAgentType === 'EP-DN') {\n return CONSULT_TRANSFER_DESTINATION_TYPE.ENTRYPOINT;\n }\n // Keep the existing destinationType if it's something else (like \"agent\" or \"Agent\")\n // Convert \"Agent\" to lowercase for consistency\n\n return destAgentType.toLowerCase();\n }\n\n return CONSULT_TRANSFER_DESTINATION_TYPE.AGENT;\n};\n\n/**\n * Gets the destination agent ID from participants.\n * Finds a participant who is not the current agent and is an agent type.\n *\n * @param participants - The participants object from interaction\n * @param agentId - The current agent's ID\n * @returns The destination agent ID, or undefined if none found\n */\nexport const buildConsultConferenceParamData = (\n dataPassed: consultConferencePayloadData,\n interactionIdPassed: string\n): {interactionId: string; data: ConsultConferenceData} => {\n const data: ConsultConferenceData = {\n ...('agentId' in dataPassed && {agentId: dataPassed.agentId}),\n to: dataPassed.destAgentId,\n destinationType: '',\n };\n\n if ('destinationType' in dataPassed) {\n const destinationType = String(dataPassed.destinationType || '').trim();\n const normalizedDestinationType = destinationType.toUpperCase().replace(/[-_\\s]/g, '');\n\n if (normalizedDestinationType === 'DN' || normalizedDestinationType === 'DIALNUMBER') {\n data.destinationType = DESTINATION_TYPE.DIALNUMBER;\n } else if (normalizedDestinationType === 'EPDN' || normalizedDestinationType === 'ENTRYPOINT') {\n data.destinationType = DESTINATION_TYPE.ENTRYPOINT;\n } else if (normalizedDestinationType === 'QUEUE') {\n data.destinationType = DESTINATION_TYPE.QUEUE;\n } else if (normalizedDestinationType === 'AGENT') {\n data.destinationType = DESTINATION_TYPE.AGENT;\n } else {\n data.destinationType = destinationType as ConsultConferenceData['destinationType'];\n }\n } else {\n data.destinationType = DESTINATION_TYPE.AGENT;\n }\n\n return {\n interactionId: interactionIdPassed,\n data,\n };\n};\n\n/**\n * Derives the consult transfer destination type based on task data.\n * This function determines the appropriate destination type for a consult transfer\n * by examining the destination type stored in the task data.\n *\n * @param taskData - The task data containing destination information\n * @returns The derived consult transfer destination type\n * @public\n */\nexport const deriveConsultTransferDestinationType = (\n taskData: TaskData\n): ConsultTransferDestinationType => {\n const destType = taskData?.destinationType;\n const normalizedDestType = String(destType || '')\n .toUpperCase()\n .replace(/[-_\\s]/g, '');\n\n // Map destination types to consult transfer destination types\n if (normalizedDestType === 'DN' || normalizedDestType === 'DIALNUMBER') {\n return CONSULT_TRANSFER_DESTINATION_TYPE.DIALNUMBER;\n }\n if (normalizedDestType === 'EPDN' || normalizedDestType === 'ENTRYPOINT') {\n return CONSULT_TRANSFER_DESTINATION_TYPE.ENTRYPOINT;\n }\n if (normalizedDestType === 'QUEUE') {\n return CONSULT_TRANSFER_DESTINATION_TYPE.QUEUE;\n }\n\n // Default to agent if no specific type matches\n return CONSULT_TRANSFER_DESTINATION_TYPE.AGENT;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,GAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAEA,IAAAE,YAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,aAAA,GAAAD,sBAAA,CAAAH,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AAUA,IAAAM,UAAA,GAAAN,OAAA;AAA6D,SAAAG,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAR,wBAAAQ,CAAA,EAAAG,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAZ,uBAAA,YAAAA,CAAAQ,CAAA,EAAAG,CAAA,SAAAA,CAAA,IAAAH,CAAA,IAAAA,CAAA,CAAAC,UAAA,SAAAD,CAAA,MAAAO,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAR,OAAA,EAAAF,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAS,CAAA,MAAAF,CAAA,GAAAJ,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAE,CAAA,CAAAI,GAAA,CAAAX,CAAA,UAAAO,CAAA,CAAAK,GAAA,CAAAZ,CAAA,GAAAO,CAAA,CAAAM,GAAA,CAAAb,CAAA,EAAAS,C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BAAyB,KAAK,OAAO,EAAE;MAChDrE,IAAI,CAACkE,eAAe,GAAGM,wBAAgB,CAACxB,KAAK;IAC/C,CAAC,MAAM;MACLhD,IAAI,CAACkE,eAAe,GAAGA,eAA2D;IACpF;EACF,CAAC,MAAM;IACLlE,IAAI,CAACkE,eAAe,GAAGM,wBAAgB,CAACxB,KAAK;EAC/C;EAEA,OAAO;IACL0B,aAAa,EAAEX,mBAAmB;IAClC/D;EACF,CAAC;AACH,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AARAhD,OAAA,CAAA6G,+BAAA,GAAAA,+BAAA;AASO,MAAMc,oCAAoC,GAC/CC,QAAkB,IACiB;EACnC,MAAMC,QAAQ,GAAGD,QAAQ,EAAEV,eAAe;EAC1C,MAAMY,kBAAkB,GAAGX,MAAM,CAACU,QAAQ,IAAI,EAAE,CAAC,CAC9CP,WAAW,CAAC,CAAC,CACbC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC;;EAEzB;EACA,IAAIO,kBAAkB,KAAK,IAAI,IAAIA,kBAAkB,KAAK,YAAY,EAAE;IACtE,OAAOpB,yCAAiC,CAACC,UAAU;EACrD;EACA,IAAImB,kBAAkB,KAAK,MAAM,IAAIA,kBAAkB,KAAK,YAAY,EAAE;IACxE,OAAOpB,yCAAiC,CAACE,UAAU;EACrD;EACA,IAAIkB,kBAAkB,KAAK,OAAO,EAAE;IAClC,OAAOpB,yCAAiC,CAACe,KAAK;EAChD;;EAEA;EACA,OAAOf,yCAAiC,CAACV,KAAK;AAChD,CAAC;AAAChG,OAAA,CAAA2H,oCAAA,GAAAA,oCAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["Err","_interopRequireWildcard","require","_types","_loggerProxy","_interopRequireDefault","_WebexRequest","_types2","_constants","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","isRecord","value","exports","getCommonErrorDetails","errObj","trackingId","headers","trackingid","TrackingID","msg","body","stripDialPlanChars","input","strippedChars","charsToStrip","Set","split","filter","c","join","isValidDialNumber","dialPlanEntries","LoggerProxy","warn","module","method","length","log","some","entry","sanitizedInput","regex","RegExp","test","name","isAllowedUrlHost","url","allowedDomains","hostname","URL","toLowerCase","domain","endsWith","error","getStationLoginErrorData","failure","loginOption","duplicateLocationMessage","LoginOption","EXTENSION","AGENT_DN","errorCodeMessageMap","DUPLICATE_LOCATION","message","fieldName","INVALID_DIAL_NUMBER","defaultMessage","defaultFieldName","reason","data","getErrorDetails","methodName","moduleName","errData","details","WebexRequest","getInstance","uploadLogs","correlationId","err","Error","generateTaskErrorObject","errorMsg","fallbackMessage","errorMessage","errorType","errorData","reasonCode","createErrDetailsObject","Details","getConsultedAgentId","media","agentId","consultParticipants","consultedParticipantId","keys","forEach","key","mType","STATE_CONSULT","participants","includes","id","find","participant","getDestAgentIdForCBT","interaction","consultingAgent","destAgentIdForCBT","foundEntry","entries","pType","PARTICIPANT_TYPES","DN","type","AGENT","dn","calculateDestAgentId","destAgentIdCBT","EP_DN","epId","calculateDestType","destinationaegntId","destAgentType","undefined","CONSULT_TRANSFER_DESTINATION_TYPE","DIALNUMBER","ENTRYPOINT","buildConsultConferenceParamData","dataPassed","interactionIdPassed","to","destAgentId","destinationType","String","trim","normalizedDestinationType","toUpperCase","replace","DESTINATION_TYPE","QUEUE","interactionId","deriveConsultTransferDestinationType","taskData","destType","normalizedDestType"],"sources":["Utils.ts"],"sourcesContent":["import * as Err from './Err';\nimport {LoginOption, WebexRequestPayload} from '../../types';\nimport {Failure, AugmentedError} from './GlobalTypes';\nimport LoggerProxy from '../../logger-proxy';\nimport WebexRequest from './WebexRequest';\nimport {\n ConsultConferenceData,\n consultConferencePayloadData,\n ConsultTransferDestinationType,\n TaskData,\n CONSULT_TRANSFER_DESTINATION_TYPE,\n DESTINATION_TYPE,\n Interaction,\n InteractionParticipant,\n} from '../task/types';\nimport {PARTICIPANT_TYPES, STATE_CONSULT} from './constants';\nimport {DialPlan} from '../config/types';\n\n/** Returns whether a value is a non-null object with string keys. */\nexport const isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' && value !== null;\n\n/**\n * Extracts common error details from a Webex request payload.\n *\n * @param errObj - The Webex request payload object.\n * @returns An object containing the tracking ID and message body.\n * @private\n * @ignore\n */\nconst getCommonErrorDetails = (errObj: WebexRequestPayload) => {\n return {\n trackingId: errObj?.headers?.trackingid || errObj?.headers?.TrackingID,\n msg: errObj?.body,\n };\n};\n\n/**\n * Strips characters defined in the dial plan entry from the input string.\n *\n * @param input - The dial number to sanitize\n * @param strippedChars - String of characters to remove from the input\n * @returns The sanitized input with specified characters removed\n */\nexport const stripDialPlanChars = (input: string, strippedChars: string): string => {\n if (!strippedChars) {\n return input;\n }\n\n const charsToStrip = new Set(strippedChars.split(''));\n\n return input\n .split('')\n .filter((c) => !charsToStrip.has(c))\n .join('');\n};\n\n/**\n * Validates a dial number against the provided dial plan regex patterns.\n * A number is valid if it matches at least one regex pattern in the dial plans.\n * Skips validation when no dial plan entries are configured, deferring to the server.\n *\n * @param input - The dial number to validate\n * @param dialPlanEntries - Array of dial plan entries containing regex patterns\n * @returns true if the input matches at least one dial plan regex pattern or no entries are configured, false otherwise\n */\nexport const isValidDialNumber = (\n input: string,\n dialPlanEntries: DialPlan['dialPlanEntity']\n): boolean => {\n if (!input) {\n LoggerProxy.warn('Dial number is empty or undefined.', {\n module: 'Utils',\n method: 'isValidDialNumber',\n });\n\n return false;\n }\n\n if (!dialPlanEntries || dialPlanEntries.length === 0) {\n LoggerProxy.log(\n 'No dial plan entries found. Skipping client-side validation, deferring to server.',\n {module: 'Utils', method: 'isValidDialNumber'}\n );\n\n return true;\n }\n\n return dialPlanEntries.some((entry) => {\n try {\n const sanitizedInput = stripDialPlanChars(input, entry.strippedChars);\n const regex = new RegExp(entry.regex);\n\n return regex.test(sanitizedInput);\n } catch (e) {\n LoggerProxy.warn(`Failed to validate dial number against entry \"${entry.name}\": ${e}`, {\n module: 'Utils',\n method: 'isValidDialNumber',\n });\n\n return false;\n }\n });\n};\n\n/**\n * Checks whether a URL's hostname is, or is a subdomain of, one of the allowed domains.\n *\n * @param url - The candidate URL to validate\n * @param allowedDomains - Domains (or domain suffixes) the URL's hostname must match\n * @returns true when the URL parses and its hostname matches an allowed domain, false otherwise\n */\nexport const isAllowedUrlHost = (\n url: string | undefined | null,\n allowedDomains: string[]\n): boolean => {\n if (!url) {\n return false;\n }\n\n try {\n const hostname = new URL(url).hostname.toLowerCase();\n\n return allowedDomains.some((domain) => hostname === domain || hostname.endsWith(`.${domain}`));\n } catch (error) {\n return false;\n }\n};\n\nexport const getStationLoginErrorData = (failure: Failure, loginOption: LoginOption) => {\n let duplicateLocationMessage = 'This value is already in use';\n\n if (loginOption === LoginOption.EXTENSION) {\n duplicateLocationMessage = 'This extension is already in use';\n }\n\n if (loginOption === LoginOption.AGENT_DN) {\n duplicateLocationMessage =\n 'Dial number is in use. Try a different one. For help, reach out to your administrator or support team.';\n }\n\n const errorCodeMessageMap = {\n DUPLICATE_LOCATION: {\n message: duplicateLocationMessage,\n fieldName: loginOption,\n },\n INVALID_DIAL_NUMBER: {\n message:\n 'Enter a valid dial number. For help, reach out to your administrator or support team.',\n fieldName: loginOption,\n },\n };\n\n const defaultMessage = 'An error occurred while logging in to the station';\n const defaultFieldName = 'generic';\n\n const reason = failure?.data?.reason || '';\n\n return {\n message: errorCodeMessageMap[reason]?.message || defaultMessage,\n fieldName: errorCodeMessageMap[reason]?.fieldName || defaultFieldName,\n };\n};\n\n/**\n * Extracts error details and logs the error. Also uploads logs for the error unless it is a silent relogin agent not found error.\n *\n * @param error - The error object, expected to have a `details` property of type Failure.\n * @param methodName - The name of the method where the error occurred.\n * @param moduleName - The name of the module where the error occurred.\n * @returns An object containing the error instance and the reason string.\n * @public\n * @example\n * const details = getErrorDetails(error, 'fetchData', 'DataModule');\n * if (details.error) { handleError(details.error); }\n * @ignore\n */\nexport const getErrorDetails = (error: any, methodName: string, moduleName: string) => {\n let errData = {message: '', fieldName: ''};\n\n const failure = error.details as Failure;\n const reason = failure?.data?.reason ?? `Error while performing ${methodName}`;\n\n if (!(reason === 'AGENT_NOT_FOUND' && methodName === 'silentRelogin')) {\n LoggerProxy.error(`${methodName} failed with reason: ${reason}`, {\n module: moduleName,\n method: methodName,\n trackingId: failure?.trackingId,\n });\n // we can add more conditions here if not needed for specific cases eg: silentReLogin\n WebexRequest.getInstance().uploadLogs({\n correlationId: failure?.trackingId,\n });\n }\n\n if (methodName === 'stationLogin') {\n errData = getStationLoginErrorData(failure, error.loginOption);\n\n LoggerProxy.error(\n `${methodName} failed with reason: ${reason}, message: ${errData.message}, fieldName: ${errData.fieldName}`,\n {\n module: moduleName,\n method: methodName,\n trackingId: failure?.trackingId,\n }\n );\n }\n\n const err = new Error(reason ?? `Error while performing ${methodName}`);\n // @ts-ignore - add custom property to the error object for backward compatibility\n err.data = errData;\n\n return {\n error: err,\n reason,\n };\n};\n\n/**\n * Extracts error details from task API errors and logs them. Also uploads logs for the error.\n * This handles the specific error format returned by task API calls.\n *\n * @param error - The error object from task API calls with structure: {id: string, details: {trackingId: string, msg: {...}}}\n * @param methodName - The name of the method where the error occurred.\n * @param moduleName - The name of the module where the error occurred.\n * @returns AugmentedError containing structured error details on err.data for metrics and logging\n * @public\n * @example\n * const taskError = generateTaskErrorObject(error, 'transfer', 'TaskModule');\n * throw taskError.error;\n * @ignore\n */\nexport const generateTaskErrorObject = (\n error: any,\n methodName: string,\n moduleName: string\n): AugmentedError => {\n const trackingId = error?.details?.trackingId || error?.trackingId || '';\n const errorMsg = error?.details?.msg;\n\n const fallbackMessage =\n (error && typeof error.message === 'string' && error.message) ||\n `Error while performing ${methodName}`;\n const errorMessage = errorMsg?.errorMessage || fallbackMessage;\n const errorType =\n errorMsg?.errorType ||\n (error && typeof error.name === 'string' && error.name) ||\n 'Unknown Error';\n const errorData = errorMsg?.errorData || '';\n const reasonCode = errorMsg?.reasonCode || 0;\n\n // Log and upload for Task API formatted errors\n LoggerProxy.error(`${methodName} failed: ${errorMessage} (${errorType})`, {\n module: moduleName,\n method: methodName,\n trackingId,\n });\n WebexRequest.getInstance().uploadLogs({\n correlationId: trackingId,\n });\n\n const reason = `${errorType}: ${errorMessage}${errorData ? ` (${errorData})` : ''}`;\n const err: AugmentedError = new Error(reason);\n err.data = {\n message: errorMessage,\n errorType,\n errorData,\n reasonCode,\n trackingId,\n };\n\n return err;\n};\n\n/**\n * Creates an error details object suitable for use with the Err.Details class.\n *\n * @param errObj - The Webex request payload object.\n * @returns An instance of Err.Details with the generic failure message and extracted details.\n * @public\n * @example\n * const errDetails = createErrDetailsObject(webexRequestPayload);\n * @ignore\n */\nexport const createErrDetailsObject = (errObj: WebexRequestPayload) => {\n const details = getCommonErrorDetails(errObj);\n\n return new Err.Details('Service.reqs.generic.failure', details);\n};\n\n/*\n/**\n * Gets the consulted agent ID from the media object by finding the agent\n * in the consult media participants (excluding the current agent).\n *\n * @param media - The media object from the interaction\n * @param agentId - The current agent's ID to exclude from the search\n * @returns The consulted agent ID, or empty string if none found\n */\nexport const getConsultedAgentId = (media: Interaction['media'], agentId: string): string => {\n let consultParticipants: string[] = [];\n let consultedParticipantId = '';\n\n Object.keys(media).forEach((key) => {\n if (media[key].mType === STATE_CONSULT) {\n consultParticipants = media[key].participants;\n }\n });\n\n if (consultParticipants.includes(agentId)) {\n const id = consultParticipants.find((participant) => participant !== agentId);\n consultedParticipantId = id || consultedParticipantId;\n }\n\n return consultedParticipantId;\n};\n\n/**\n * Gets the destination agent ID for CBT (Capacity Based Team) scenarios.\n * CBT refers to teams created in Control Hub with capacity-based routing\n * (as opposed to agent-based routing). This handles cases where the consulted\n * participant is not directly in participants but can be found by matching\n * the dial number (dn).\n *\n * @param interaction - The interaction object\n * @param consultingAgent - The consulting agent identifier\n * @returns The destination agent ID for CBT scenarios, or empty string if none found\n */\nexport const getDestAgentIdForCBT = (interaction: Interaction, consultingAgent: string): string => {\n const participants = interaction.participants;\n let destAgentIdForCBT = '';\n\n // Check if this is a CBT scenario (consultingAgent exists but not directly in participants)\n if (consultingAgent && !participants[consultingAgent]) {\n const foundEntry = Object.entries(participants).find(\n ([, participant]: [string, Interaction['participants'][string]]) => {\n return (\n participant.pType.toLowerCase() === PARTICIPANT_TYPES.DN &&\n participant.type === PARTICIPANT_TYPES.AGENT &&\n participant.dn === consultingAgent\n );\n }\n );\n\n if (foundEntry) {\n destAgentIdForCBT = foundEntry[0];\n }\n }\n\n return destAgentIdForCBT;\n};\n\n/**\n * Calculates the destination agent ID for consult operations.\n *\n * @param interaction - The interaction object\n * @param agentId - The current agent's ID\n * @returns The destination agent ID\n */\nexport const calculateDestAgentId = (interaction: Interaction, agentId: string): string => {\n const consultingAgent = getConsultedAgentId(interaction.media, agentId);\n\n // Check if this is a CBT (Capacity Based Team) scenario\n // If not CBT, the function will return empty string and we'll use the normal flow\n const destAgentIdCBT = getDestAgentIdForCBT(interaction, consultingAgent);\n if (destAgentIdCBT) {\n return destAgentIdCBT;\n }\n\n const participant = interaction.participants[consultingAgent];\n if (!participant) {\n return '';\n }\n\n if (participant.type === PARTICIPANT_TYPES.EP_DN) {\n return (participant as InteractionParticipant & {epId?: string}).epId ?? '';\n }\n\n return participant.id ?? '';\n};\n\n/**\n * Calculates the destination agent ID for fetching destination type.\n *\n * @param interaction - The interaction object\n * @param agentId - The current agent's ID\n * @returns The destination agent ID for determining destination type\n */\nexport const calculateDestType = (interaction: Interaction, agentId: string): string => {\n const consultingAgent = getConsultedAgentId(interaction.media, agentId);\n\n // Check if this is a CBT (Capacity Based Team) scenario, otherwise use consultingAgent\n const destAgentIdCBT = getDestAgentIdForCBT(interaction, consultingAgent);\n const destinationaegntId = destAgentIdCBT || consultingAgent;\n const destAgentType = destinationaegntId\n ? interaction.participants[destinationaegntId]?.pType\n : undefined;\n if (destAgentType) {\n if (destAgentType === 'DN') {\n return CONSULT_TRANSFER_DESTINATION_TYPE.DIALNUMBER;\n }\n if (destAgentType === 'EP-DN') {\n return CONSULT_TRANSFER_DESTINATION_TYPE.ENTRYPOINT;\n }\n // Keep the existing destinationType if it's something else (like \"agent\" or \"Agent\")\n // Convert \"Agent\" to lowercase for consistency\n\n return destAgentType.toLowerCase();\n }\n\n return CONSULT_TRANSFER_DESTINATION_TYPE.AGENT;\n};\n\n/**\n * Gets the destination agent ID from participants.\n * Finds a participant who is not the current agent and is an agent type.\n *\n * @param participants - The participants object from interaction\n * @param agentId - The current agent's ID\n * @returns The destination agent ID, or undefined if none found\n */\nexport const buildConsultConferenceParamData = (\n dataPassed: consultConferencePayloadData,\n interactionIdPassed: string\n): {interactionId: string; data: ConsultConferenceData} => {\n const data: ConsultConferenceData = {\n ...('agentId' in dataPassed && {agentId: dataPassed.agentId}),\n to: dataPassed.destAgentId,\n destinationType: '',\n };\n\n if ('destinationType' in dataPassed) {\n const destinationType = String(dataPassed.destinationType || '').trim();\n const normalizedDestinationType = destinationType.toUpperCase().replace(/[-_\\s]/g, '');\n\n if (normalizedDestinationType === 'DN' || normalizedDestinationType === 'DIALNUMBER') {\n data.destinationType = DESTINATION_TYPE.DIALNUMBER;\n } else if (normalizedDestinationType === 'EPDN' || normalizedDestinationType === 'ENTRYPOINT') {\n data.destinationType = DESTINATION_TYPE.ENTRYPOINT;\n } else if (normalizedDestinationType === 'QUEUE') {\n data.destinationType = DESTINATION_TYPE.QUEUE;\n } else if (normalizedDestinationType === 'AGENT') {\n data.destinationType = DESTINATION_TYPE.AGENT;\n } else {\n data.destinationType = destinationType as ConsultConferenceData['destinationType'];\n }\n } else {\n data.destinationType = DESTINATION_TYPE.AGENT;\n }\n\n return {\n interactionId: interactionIdPassed,\n data,\n };\n};\n\n/**\n * Derives the consult transfer destination type based on task data.\n * This function determines the appropriate destination type for a consult transfer\n * by examining the destination type stored in the task data.\n *\n * @param taskData - The task data containing destination information\n * @returns The derived consult transfer destination type\n * @public\n */\nexport const deriveConsultTransferDestinationType = (\n taskData: TaskData\n): ConsultTransferDestinationType => {\n const destType = taskData?.destinationType;\n const normalizedDestType = String(destType || '')\n .toUpperCase()\n .replace(/[-_\\s]/g, '');\n\n // Map destination types to consult transfer destination types\n if (normalizedDestType === 'DN' || normalizedDestType === 'DIALNUMBER') {\n return CONSULT_TRANSFER_DESTINATION_TYPE.DIALNUMBER;\n }\n if (normalizedDestType === 'EPDN' || normalizedDestType === 'ENTRYPOINT') {\n return CONSULT_TRANSFER_DESTINATION_TYPE.ENTRYPOINT;\n }\n if (normalizedDestType === 'QUEUE') {\n return CONSULT_TRANSFER_DESTINATION_TYPE.QUEUE;\n }\n\n // Default to agent if no specific type matches\n return CONSULT_TRANSFER_DESTINATION_TYPE.AGENT;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,GAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAEA,IAAAE,YAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,aAAA,GAAAD,sBAAA,CAAAH,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AAUA,IAAAM,UAAA,GAAAN,OAAA;AAA6D,SAAAG,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAR,wBAAAQ,CAAA,EAAAG,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAZ,uBAAA,YAAAA,CAAAQ,CAAA,EAAAG,CAAA,SAAAA,CAAA,IAAAH,CAAA,IAAAA,CAAA,CAAAC,UAAA,SAAAD,CAAA,MAAAO,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAR,OAAA,EAAAF,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAS,CAAA,MAAAF,CAAA,GAAAJ,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAE,CAAA,CAAAI,GAAA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B;EACA,IAAIO,kBAAkB,KAAK,IAAI,IAAIA,kBAAkB,KAAK,YAAY,EAAE;IACtE,OAAOpB,yCAAiC,CAACC,UAAU;EACrD;EACA,IAAImB,kBAAkB,KAAK,MAAM,IAAIA,kBAAkB,KAAK,YAAY,EAAE;IACxE,OAAOpB,yCAAiC,CAACE,UAAU;EACrD;EACA,IAAIkB,kBAAkB,KAAK,OAAO,EAAE;IAClC,OAAOpB,yCAAiC,CAACe,KAAK;EAChD;;EAEA;EACA,OAAOf,yCAAiC,CAACV,KAAK;AAChD,CAAC;AAACvG,OAAA,CAAAkI,oCAAA,GAAAA,oCAAA","ignoreList":[]}
|
|
@@ -113,21 +113,13 @@ class AqmReqs {
|
|
|
113
113
|
const notifFail = c.notifFail;
|
|
114
114
|
if ('errId' in notifFail) {
|
|
115
115
|
const error = new Err.Details(notifFail.errId, msg);
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
module: _constants2.AQM_REQS_FILE,
|
|
124
|
-
method: _constants.METHODS.CREATE_PROMISE
|
|
125
|
-
});
|
|
126
|
-
_loggerProxy.default.log(`Routing request failed: ${error}`, {
|
|
127
|
-
module: _constants2.AQM_REQS_FILE,
|
|
128
|
-
method: _constants.METHODS.CREATE_PROMISE
|
|
129
|
-
});
|
|
130
|
-
}
|
|
116
|
+
|
|
117
|
+
// The raw routing-failure payload/error is never logged verbatim; only a
|
|
118
|
+
// redacted, non-sensitive diagnostic is emitted regardless of redactSensitiveLogs.
|
|
119
|
+
_loggerProxy.default.log('Routing request failed (sensitive details redacted)', {
|
|
120
|
+
module: _constants2.AQM_REQS_FILE,
|
|
121
|
+
method: _constants.METHODS.CREATE_PROMISE
|
|
122
|
+
});
|
|
131
123
|
reject(error);
|
|
132
124
|
} else {
|
|
133
125
|
reject(notifFail.err(msg));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Err","_interopRequireWildcard","require","_types","_loggerProxy","_interopRequireDefault","_constants","_constants2","_WebexRequest","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","AqmReqs","pendingRequests","pendingNotifCancelrequest","constructor","webSocketManager","webexRequest","WebexRequest","getInstance","on","onMessage","bind","req","c","p","cbRes","makeAPIRequest","reqEmpty","createPromise","Promise","resolve","reject","keySuccess","bindPrint","notifSuccess","keyFail","notifFail","keyCancel","notifCancel","k","timeout","Details","key","msg","isClear","clear","check","bindCheck","handle","alternateBind","alternateBindKey","error","errId","redactSensitiveLogs","LoggerProxy","log","module","AQM_REQS_FILE","method","METHODS","CREATE_PROMISE","JSON","stringify","err","response","request","service","host","resource","url","data","HTTP_METHODS","POST","GET","body","then","res","catch","headers","Authorization","Message","window","setTimeout","TIMEOUT_REQ","result","keys","filter","prop","value","Array","isArray","join","slice","__typeMap","typeMapCheck","bindValue","msgValue","includes","typeMap","typeField","msgType","conditions","condition","field","event","parse","type","info","ON_MESSAGE","keepalive","isHandled","kReq","thisReq","kReqAlt","exports"],"sources":["aqm-reqs.ts"],"sourcesContent":["import {Msg} from './GlobalTypes';\nimport * as Err from './Err';\nimport {HTTP_METHODS, WebexRequestPayload} from '../../types';\nimport LoggerProxy from '../../logger-proxy';\nimport {CbRes, Conf, ConfEmpty, Pending, Req, Res, ResEmpty} from './types';\nimport {TIMEOUT_REQ, METHODS} from './constants';\nimport {AQM_REQS_FILE} from '../../constants';\nimport WebexRequest from './WebexRequest';\nimport {WebSocketManager} from './websocket/WebSocketManager';\n\nexport default class AqmReqs {\n private pendingRequests: Record<string, Pending> = {};\n private pendingNotifCancelrequest: Record<string, Pending> = {};\n private webexRequest: WebexRequest;\n private webSocketManager: WebSocketManager;\n\n constructor(webSocketManager: WebSocketManager) {\n this.webexRequest = WebexRequest.getInstance();\n this.webSocketManager = webSocketManager;\n this.webSocketManager.on('message', this.onMessage.bind(this));\n }\n\n /**\n * Creates a request function for an API call with parameters\n * @param c - The configuration for the request\n * @returns A function that makes the API request\n */\n req<TRes, TErr, TReq>(c: Conf<TRes, TErr, TReq>): Res<TRes, TReq> {\n return (p: TReq, cbRes?: CbRes<TRes>) => this.makeAPIRequest(c(p), cbRes);\n }\n\n /**\n * Creates a request function for an API call with no parameters\n * @param c - The configuration for the request\n * @returns A function that makes the API request\n */\n reqEmpty<TRes, TErr>(c: ConfEmpty<TRes, TErr>): ResEmpty<TRes> {\n return (cbRes?: CbRes<TRes>) => this.makeAPIRequest(c(), cbRes);\n }\n\n /**\n * Makes an API request\n * @param c - The request configuration\n * @param cbRes - The callback for the response\n * @returns A promise that resolves with the response or rejects with an error\n */\n private async makeAPIRequest<TRes, TErr>(c: Req<TRes, TErr>, cbRes?: CbRes<TRes>): Promise<TRes> {\n return this.createPromise(c, cbRes);\n }\n\n /**\n * Creates a promise for an API request\n * @param c - The request configuration\n * @param cbRes - The callback for the response\n * @returns A promise that resolves with the response or rejects with an error\n */\n private createPromise<TRes, TErr>(c: Req<TRes, TErr>, cbRes?: CbRes<TRes>) {\n return new Promise<TRes>((resolve, reject) => {\n const keySuccess = this.bindPrint(c.notifSuccess.bind);\n const keyFail = c.notifFail ? this.bindPrint(c.notifFail.bind) : null;\n const keyCancel = c.notifCancel?.bind ? this.bindPrint(c.notifCancel.bind) : null;\n let k = '';\n if (this.pendingRequests[keySuccess]) {\n k = keySuccess;\n }\n if (keyFail && this.pendingRequests[keyFail]) {\n k += keyFail;\n }\n if (k && c.timeout !== 'disabled') {\n reject(\n new Err.Details('Service.aqm.reqs.Pending', {\n key: k,\n msg: 'The request has been already created, multiple requests are not allowed.',\n })\n );\n\n return;\n }\n\n let isClear = false;\n const clear = () => {\n delete this.pendingRequests[keySuccess];\n if (keyFail) {\n delete this.pendingRequests[keyFail];\n }\n if (keyCancel) {\n delete this.pendingNotifCancelrequest[keyCancel];\n }\n isClear = true;\n };\n\n this.pendingRequests[keySuccess] = {\n check: (msg: Msg) => this.bindCheck(c.notifSuccess.bind, msg),\n handle: (msg: Msg) => {\n clear();\n resolve(msg as any);\n },\n };\n if (keyCancel) {\n this.pendingRequests[keySuccess].alternateBind = keyCancel;\n this.pendingNotifCancelrequest[keyCancel] = {\n check: (msg: Msg) => this.bindCheck(c.notifCancel?.bind, msg),\n handle: (msg: Msg) => {\n const alternateBindKey = this.pendingNotifCancelrequest[keyCancel].alternateBind;\n if (alternateBindKey) {\n this.pendingRequests[alternateBindKey].handle(msg);\n }\n },\n alternateBind: keySuccess,\n };\n }\n\n if (keyFail) {\n this.pendingRequests[keyFail] = {\n check: (msg: Msg) => this.bindCheck(c.notifFail!.bind, msg),\n handle: (msg: Msg) => {\n clear();\n const notifFail = c.notifFail!;\n if ('errId' in notifFail) {\n const error = new Err.Details(notifFail.errId, msg as any);\n\n if (c.redactSensitiveLogs) {\n LoggerProxy.log('Routing request failed (sensitive details redacted)', {\n module: AQM_REQS_FILE,\n method: METHODS.CREATE_PROMISE,\n });\n } else {\n LoggerProxy.log(`Routing request failed: ${JSON.stringify(msg)}`, {\n module: AQM_REQS_FILE,\n method: METHODS.CREATE_PROMISE,\n });\n LoggerProxy.log(`Routing request failed: ${error}`, {\n module: AQM_REQS_FILE,\n method: METHODS.CREATE_PROMISE,\n });\n }\n reject(error);\n } else {\n reject(notifFail.err(msg as any));\n }\n },\n };\n }\n let response: WebexRequestPayload | null = null;\n this.webexRequest\n .request({\n service: c.host ?? '',\n resource: c.url,\n // eslint-disable-next-line no-nested-ternary\n method: c.method ? c.method : c.data ? HTTP_METHODS.POST : HTTP_METHODS.GET,\n\n body: c.data,\n })\n .then((res: any) => {\n response = res;\n if (cbRes) {\n cbRes(res);\n }\n })\n .catch((error: WebexRequestPayload) => {\n clear();\n if (error?.headers) {\n error.headers.Authorization = '*';\n }\n if (error?.headers) {\n error.headers.Authorization = '*';\n }\n if (typeof c.err === 'function') {\n reject(c.err(error));\n } else if (typeof c.err === 'string') {\n reject(new Err.Message(c.err));\n } else {\n reject(new Err.Message('Service.aqm.reqs.GenericRequestError'));\n }\n });\n\n if (c.timeout !== 'disabled') {\n window.setTimeout(\n () => {\n if (isClear) {\n return;\n }\n clear();\n if (response?.headers) {\n response.headers.Authorization = '*';\n }\n if (c.redactSensitiveLogs) {\n LoggerProxy.error('Routing request timeout (sensitive details redacted)', {\n module: AQM_REQS_FILE,\n method: METHODS.CREATE_PROMISE,\n });\n } else {\n LoggerProxy.error(\n `Routing request timeout${keySuccess}${JSON.stringify(response)}${c.url}`,\n {\n module: AQM_REQS_FILE,\n method: METHODS.CREATE_PROMISE,\n }\n );\n }\n reject(\n new Err.Details('Service.aqm.reqs.Timeout', {\n key: keySuccess,\n response: response!,\n })\n );\n },\n c.timeout && c.timeout > 0 ? c.timeout : TIMEOUT_REQ\n );\n }\n });\n }\n\n /**\n * Converts a bind object to a string representation\n * @param bind - The bind object to convert\n * @returns A string representation of the bind object\n */\n private bindPrint(bind: any): string {\n let result = '';\n for (const key of Object.keys(bind).filter((prop) => prop !== '__typeMap')) {\n const value = bind[key];\n\n if (Array.isArray(value)) {\n result += `${key}=[${value.join(',')}],`;\n } else if (typeof value === 'object' && value !== null) {\n result += `${key}=(${this.bindPrint(value)}),`;\n } else {\n result += `${key}=${value},`;\n }\n }\n\n return result ? result.slice(0, -1) : result;\n }\n\n /**\n * Checks if a message matches a bind object\n * @param bind - The bind object to check against\n * @param msg - The message to check\n * @returns True if the message matches the bind object, false otherwise\n */\n private bindCheck(bind: any, msg: any): boolean {\n // Handle type-dependent field matching if __typeMap is present\n if (bind.__typeMap && typeof bind.__typeMap === 'object') {\n if (!AqmReqs.typeMapCheck(bind.__typeMap, msg)) {\n return false;\n }\n }\n\n for (const key of Object.keys(bind).filter((prop) => prop !== '__typeMap')) {\n const bindValue = bind[key];\n const msgValue = msg[key];\n\n if (Array.isArray(bindValue)) {\n // Check if the message value matches any of the values in the array\n if (!bindValue.includes(msgValue)) {\n return false;\n }\n } else if (typeof bindValue === 'object' && bindValue !== null) {\n if (typeof msgValue === 'object' && msgValue !== null) {\n if (!this.bindCheck(bindValue, msgValue)) {\n return false;\n }\n } else {\n return false;\n }\n } else if (!msgValue || msgValue !== bindValue) {\n return false;\n }\n }\n\n return true;\n }\n\n /**\n * Checks type-dependent field conditions defined in __typeMap.\n * @param typeMap - The type map to check against\n * @param msg - The message to check\n * @returns True if the message matches the type map, false otherwise\n * The typeMap has the shape:\n * { typeField: \"type\", conditions: { EventA: { field: value }, EventB: { field: value } } }\n * It reads msg[typeField] to determine which condition set to apply,\n * then verifies all fields in that condition match the message.\n */\n private static typeMapCheck(typeMap: any, msg: any): boolean {\n const typeField = typeMap.typeField || 'type';\n const msgType = msg[typeField];\n\n if (typeMap.conditions && typeMap.conditions[msgType]) {\n const condition = typeMap.conditions[msgType];\n for (const field of Object.keys(condition)) {\n if (!msg[field] || msg[field] !== condition[field]) {\n return false;\n }\n }\n\n return true;\n }\n\n return false;\n }\n\n /**\n * Handles incoming messages from the WebSocket (must be a lambda fn)\n * @param msg - The message to handle\n * @returns\n */\n private readonly onMessage = (msg: any) => {\n const event = JSON.parse(msg);\n if (event.type === 'Welcome') {\n LoggerProxy.info(`Welcome message from Notifs Websocket`, {\n module: AQM_REQS_FILE,\n method: METHODS.ON_MESSAGE,\n });\n\n return;\n }\n\n if (event.keepalive === 'true') {\n return;\n }\n\n if (event.type === 'AgentReloginFailed') {\n LoggerProxy.info('Silently handling the agent relogin fail', {\n module: AQM_REQS_FILE,\n method: METHODS.ON_MESSAGE,\n });\n }\n\n let isHandled = false;\n\n const kReq = Object.keys(this.pendingRequests);\n for (const thisReq of kReq) {\n const req = this.pendingRequests[thisReq];\n if (req.check(event)) {\n req.handle(event);\n isHandled = true;\n break;\n }\n }\n // pendingNotifCancelrequest stores the secondary bind key, checks for the secondary bind key and handles the event\n const kReqAlt = Object.keys(this.pendingNotifCancelrequest);\n for (const thisReq of kReqAlt) {\n const req = this.pendingNotifCancelrequest[thisReq];\n if (req.check(event)) {\n req.handle(event);\n isHandled = true;\n }\n }\n\n // TODO: add event emitter for unhandled events to replicate event.listen or .on\n\n if (!isHandled) {\n LoggerProxy.info(`event=missingEventHandler | [AqmReqs] missing routing message handler`, {\n module: AQM_REQS_FILE,\n method: METHODS.ON_MESSAGE,\n });\n }\n };\n}\n"],"mappings":";;;;;;AACA,IAAAA,GAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAC,sBAAA,CAAAH,OAAA;AAEA,IAAAI,UAAA,GAAAJ,OAAA;AACA,IAAAK,WAAA,GAAAL,OAAA;AACA,IAAAM,aAAA,GAAAH,sBAAA,CAAAH,OAAA;AAA0C,SAAAG,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAR,wBAAAQ,CAAA,EAAAG,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAZ,uBAAA,YAAAA,CAAAQ,CAAA,EAAAG,CAAA,SAAAA,CAAA,IAAAH,CAAA,IAAAA,CAAA,CAAAC,UAAA,SAAAD,CAAA,MAAAO,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAR,OAAA,EAAAF,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAS,CAAA,MAAAF,CAAA,GAAAJ,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAE,CAAA,CAAAI,GAAA,CAAAX,CAAA,UAAAO,CAAA,CAAAK,GAAA,CAAAZ,CAAA,GAAAO,CAAA,CAAAM,GAAA,CAAAb,CAAA,EAAAS,CAAA,gBAAAN,CAAA,IAAAH,CAAA,gBAAAG,CAAA,OAAAW,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAG,CAAA,OAAAK,CAAA,IAAAD,CAAA,GAAAS,MAAA,CAAAC,cAAA,KAAA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,IAAI,CAAC,IAAI,CAACxE,yBAAyB,CAAC;IAC3D,KAAK,MAAMmG,OAAO,IAAIC,OAAO,EAAE;MAC7B,MAAM3F,GAAG,GAAG,IAAI,CAACT,yBAAyB,CAACmG,OAAO,CAAC;MACnD,IAAI1F,GAAG,CAACwB,KAAK,CAAC0D,KAAK,CAAC,EAAE;QACpBlF,GAAG,CAAC0B,MAAM,CAACwD,KAAK,CAAC;QACjBM,SAAS,GAAG,IAAI;MAClB;IACF;;IAEA;;IAEA,IAAI,CAACA,SAAS,EAAE;MACdxD,oBAAW,CAACqD,IAAI,CAAC,uEAAuE,EAAE;QACxFnD,MAAM,EAAEC,yBAAa;QACrBC,MAAM,EAAEC,kBAAO,CAACiD;MAClB,CAAC,CAAC;IACJ;EACF,CAAC;AACH;AAACM,OAAA,CAAAxH,OAAA,GAAAiB,OAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["Err","_interopRequireWildcard","require","_types","_loggerProxy","_interopRequireDefault","_constants","_constants2","_WebexRequest","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","AqmReqs","pendingRequests","pendingNotifCancelrequest","constructor","webSocketManager","webexRequest","WebexRequest","getInstance","on","onMessage","bind","req","c","p","cbRes","makeAPIRequest","reqEmpty","createPromise","Promise","resolve","reject","keySuccess","bindPrint","notifSuccess","keyFail","notifFail","keyCancel","notifCancel","k","timeout","Details","key","msg","isClear","clear","check","bindCheck","handle","alternateBind","alternateBindKey","error","errId","LoggerProxy","log","module","AQM_REQS_FILE","method","METHODS","CREATE_PROMISE","err","response","request","service","host","resource","url","data","HTTP_METHODS","POST","GET","body","then","res","catch","headers","Authorization","Message","window","setTimeout","redactSensitiveLogs","JSON","stringify","TIMEOUT_REQ","result","keys","filter","prop","value","Array","isArray","join","slice","__typeMap","typeMapCheck","bindValue","msgValue","includes","typeMap","typeField","msgType","conditions","condition","field","event","parse","type","info","ON_MESSAGE","keepalive","isHandled","kReq","thisReq","kReqAlt","exports"],"sources":["aqm-reqs.ts"],"sourcesContent":["import {Msg} from './GlobalTypes';\nimport * as Err from './Err';\nimport {HTTP_METHODS, WebexRequestPayload} from '../../types';\nimport LoggerProxy from '../../logger-proxy';\nimport {CbRes, Conf, ConfEmpty, Pending, Req, Res, ResEmpty} from './types';\nimport {TIMEOUT_REQ, METHODS} from './constants';\nimport {AQM_REQS_FILE} from '../../constants';\nimport WebexRequest from './WebexRequest';\nimport {WebSocketManager} from './websocket/WebSocketManager';\n\nexport default class AqmReqs {\n private pendingRequests: Record<string, Pending> = {};\n private pendingNotifCancelrequest: Record<string, Pending> = {};\n private webexRequest: WebexRequest;\n private webSocketManager: WebSocketManager;\n\n constructor(webSocketManager: WebSocketManager) {\n this.webexRequest = WebexRequest.getInstance();\n this.webSocketManager = webSocketManager;\n this.webSocketManager.on('message', this.onMessage.bind(this));\n }\n\n /**\n * Creates a request function for an API call with parameters\n * @param c - The configuration for the request\n * @returns A function that makes the API request\n */\n req<TRes, TErr, TReq>(c: Conf<TRes, TErr, TReq>): Res<TRes, TReq> {\n return (p: TReq, cbRes?: CbRes<TRes>) => this.makeAPIRequest(c(p), cbRes);\n }\n\n /**\n * Creates a request function for an API call with no parameters\n * @param c - The configuration for the request\n * @returns A function that makes the API request\n */\n reqEmpty<TRes, TErr>(c: ConfEmpty<TRes, TErr>): ResEmpty<TRes> {\n return (cbRes?: CbRes<TRes>) => this.makeAPIRequest(c(), cbRes);\n }\n\n /**\n * Makes an API request\n * @param c - The request configuration\n * @param cbRes - The callback for the response\n * @returns A promise that resolves with the response or rejects with an error\n */\n private async makeAPIRequest<TRes, TErr>(c: Req<TRes, TErr>, cbRes?: CbRes<TRes>): Promise<TRes> {\n return this.createPromise(c, cbRes);\n }\n\n /**\n * Creates a promise for an API request\n * @param c - The request configuration\n * @param cbRes - The callback for the response\n * @returns A promise that resolves with the response or rejects with an error\n */\n private createPromise<TRes, TErr>(c: Req<TRes, TErr>, cbRes?: CbRes<TRes>) {\n return new Promise<TRes>((resolve, reject) => {\n const keySuccess = this.bindPrint(c.notifSuccess.bind);\n const keyFail = c.notifFail ? this.bindPrint(c.notifFail.bind) : null;\n const keyCancel = c.notifCancel?.bind ? this.bindPrint(c.notifCancel.bind) : null;\n let k = '';\n if (this.pendingRequests[keySuccess]) {\n k = keySuccess;\n }\n if (keyFail && this.pendingRequests[keyFail]) {\n k += keyFail;\n }\n if (k && c.timeout !== 'disabled') {\n reject(\n new Err.Details('Service.aqm.reqs.Pending', {\n key: k,\n msg: 'The request has been already created, multiple requests are not allowed.',\n })\n );\n\n return;\n }\n\n let isClear = false;\n const clear = () => {\n delete this.pendingRequests[keySuccess];\n if (keyFail) {\n delete this.pendingRequests[keyFail];\n }\n if (keyCancel) {\n delete this.pendingNotifCancelrequest[keyCancel];\n }\n isClear = true;\n };\n\n this.pendingRequests[keySuccess] = {\n check: (msg: Msg) => this.bindCheck(c.notifSuccess.bind, msg),\n handle: (msg: Msg) => {\n clear();\n resolve(msg as any);\n },\n };\n if (keyCancel) {\n this.pendingRequests[keySuccess].alternateBind = keyCancel;\n this.pendingNotifCancelrequest[keyCancel] = {\n check: (msg: Msg) => this.bindCheck(c.notifCancel?.bind, msg),\n handle: (msg: Msg) => {\n const alternateBindKey = this.pendingNotifCancelrequest[keyCancel].alternateBind;\n if (alternateBindKey) {\n this.pendingRequests[alternateBindKey].handle(msg);\n }\n },\n alternateBind: keySuccess,\n };\n }\n\n if (keyFail) {\n this.pendingRequests[keyFail] = {\n check: (msg: Msg) => this.bindCheck(c.notifFail!.bind, msg),\n handle: (msg: Msg) => {\n clear();\n const notifFail = c.notifFail!;\n if ('errId' in notifFail) {\n const error = new Err.Details(notifFail.errId, msg as any);\n\n // The raw routing-failure payload/error is never logged verbatim; only a\n // redacted, non-sensitive diagnostic is emitted regardless of redactSensitiveLogs.\n LoggerProxy.log('Routing request failed (sensitive details redacted)', {\n module: AQM_REQS_FILE,\n method: METHODS.CREATE_PROMISE,\n });\n reject(error);\n } else {\n reject(notifFail.err(msg as any));\n }\n },\n };\n }\n let response: WebexRequestPayload | null = null;\n this.webexRequest\n .request({\n service: c.host ?? '',\n resource: c.url,\n // eslint-disable-next-line no-nested-ternary\n method: c.method ? c.method : c.data ? HTTP_METHODS.POST : HTTP_METHODS.GET,\n\n body: c.data,\n })\n .then((res: any) => {\n response = res;\n if (cbRes) {\n cbRes(res);\n }\n })\n .catch((error: WebexRequestPayload) => {\n clear();\n if (error?.headers) {\n error.headers.Authorization = '*';\n }\n if (error?.headers) {\n error.headers.Authorization = '*';\n }\n if (typeof c.err === 'function') {\n reject(c.err(error));\n } else if (typeof c.err === 'string') {\n reject(new Err.Message(c.err));\n } else {\n reject(new Err.Message('Service.aqm.reqs.GenericRequestError'));\n }\n });\n\n if (c.timeout !== 'disabled') {\n window.setTimeout(\n () => {\n if (isClear) {\n return;\n }\n clear();\n if (response?.headers) {\n response.headers.Authorization = '*';\n }\n if (c.redactSensitiveLogs) {\n LoggerProxy.error('Routing request timeout (sensitive details redacted)', {\n module: AQM_REQS_FILE,\n method: METHODS.CREATE_PROMISE,\n });\n } else {\n LoggerProxy.error(\n `Routing request timeout${keySuccess}${JSON.stringify(response)}${c.url}`,\n {\n module: AQM_REQS_FILE,\n method: METHODS.CREATE_PROMISE,\n }\n );\n }\n reject(\n new Err.Details('Service.aqm.reqs.Timeout', {\n key: keySuccess,\n response: response!,\n })\n );\n },\n c.timeout && c.timeout > 0 ? c.timeout : TIMEOUT_REQ\n );\n }\n });\n }\n\n /**\n * Converts a bind object to a string representation\n * @param bind - The bind object to convert\n * @returns A string representation of the bind object\n */\n private bindPrint(bind: any): string {\n let result = '';\n for (const key of Object.keys(bind).filter((prop) => prop !== '__typeMap')) {\n const value = bind[key];\n\n if (Array.isArray(value)) {\n result += `${key}=[${value.join(',')}],`;\n } else if (typeof value === 'object' && value !== null) {\n result += `${key}=(${this.bindPrint(value)}),`;\n } else {\n result += `${key}=${value},`;\n }\n }\n\n return result ? result.slice(0, -1) : result;\n }\n\n /**\n * Checks if a message matches a bind object\n * @param bind - The bind object to check against\n * @param msg - The message to check\n * @returns True if the message matches the bind object, false otherwise\n */\n private bindCheck(bind: any, msg: any): boolean {\n // Handle type-dependent field matching if __typeMap is present\n if (bind.__typeMap && typeof bind.__typeMap === 'object') {\n if (!AqmReqs.typeMapCheck(bind.__typeMap, msg)) {\n return false;\n }\n }\n\n for (const key of Object.keys(bind).filter((prop) => prop !== '__typeMap')) {\n const bindValue = bind[key];\n const msgValue = msg[key];\n\n if (Array.isArray(bindValue)) {\n // Check if the message value matches any of the values in the array\n if (!bindValue.includes(msgValue)) {\n return false;\n }\n } else if (typeof bindValue === 'object' && bindValue !== null) {\n if (typeof msgValue === 'object' && msgValue !== null) {\n if (!this.bindCheck(bindValue, msgValue)) {\n return false;\n }\n } else {\n return false;\n }\n } else if (!msgValue || msgValue !== bindValue) {\n return false;\n }\n }\n\n return true;\n }\n\n /**\n * Checks type-dependent field conditions defined in __typeMap.\n * @param typeMap - The type map to check against\n * @param msg - The message to check\n * @returns True if the message matches the type map, false otherwise\n * The typeMap has the shape:\n * { typeField: \"type\", conditions: { EventA: { field: value }, EventB: { field: value } } }\n * It reads msg[typeField] to determine which condition set to apply,\n * then verifies all fields in that condition match the message.\n */\n private static typeMapCheck(typeMap: any, msg: any): boolean {\n const typeField = typeMap.typeField || 'type';\n const msgType = msg[typeField];\n\n if (typeMap.conditions && typeMap.conditions[msgType]) {\n const condition = typeMap.conditions[msgType];\n for (const field of Object.keys(condition)) {\n if (!msg[field] || msg[field] !== condition[field]) {\n return false;\n }\n }\n\n return true;\n }\n\n return false;\n }\n\n /**\n * Handles incoming messages from the WebSocket (must be a lambda fn)\n * @param msg - The message to handle\n * @returns\n */\n private readonly onMessage = (msg: any) => {\n const event = JSON.parse(msg);\n if (event.type === 'Welcome') {\n LoggerProxy.info(`Welcome message from Notifs Websocket`, {\n module: AQM_REQS_FILE,\n method: METHODS.ON_MESSAGE,\n });\n\n return;\n }\n\n if (event.keepalive === 'true') {\n return;\n }\n\n if (event.type === 'AgentReloginFailed') {\n LoggerProxy.info('Silently handling the agent relogin fail', {\n module: AQM_REQS_FILE,\n method: METHODS.ON_MESSAGE,\n });\n }\n\n let isHandled = false;\n\n const kReq = Object.keys(this.pendingRequests);\n for (const thisReq of kReq) {\n const req = this.pendingRequests[thisReq];\n if (req.check(event)) {\n req.handle(event);\n isHandled = true;\n break;\n }\n }\n // pendingNotifCancelrequest stores the secondary bind key, checks for the secondary bind key and handles the event\n const kReqAlt = Object.keys(this.pendingNotifCancelrequest);\n for (const thisReq of kReqAlt) {\n const req = this.pendingNotifCancelrequest[thisReq];\n if (req.check(event)) {\n req.handle(event);\n isHandled = true;\n }\n }\n\n // TODO: add event emitter for unhandled events to replicate event.listen or .on\n\n if (!isHandled) {\n LoggerProxy.info(`event=missingEventHandler | [AqmReqs] missing routing message handler`, {\n module: AQM_REQS_FILE,\n method: METHODS.ON_MESSAGE,\n });\n }\n };\n}\n"],"mappings":";;;;;;AACA,IAAAA,GAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAC,sBAAA,CAAAH,OAAA;AAEA,IAAAI,UAAA,GAAAJ,OAAA;AACA,IAAAK,WAAA,GAAAL,OAAA;AACA,IAAAM,aAAA,GAAAH,sBAAA,CAAAH,OAAA;AAA0C,SAAAG,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAR,wBAAAQ,CAAA,EAAAG,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAZ,uBAAA,YAAAA,CAAAQ,CAAA,EAAAG,CAAA,SAAAA,CAAA,IAAAH,CAAA,IAAAA,CAAA,CAAAC,UAAA,SAAAD,CAAA,MAAAO,CAAA,EAAAC,CA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,GAAG,IAAI;QAChB;MACF;IACF;IACA;IACA,MAAMG,OAAO,GAAGzG,MAAM,CAAC6E,IAAI,CAAC,IAAI,CAACxE,yBAAyB,CAAC;IAC3D,KAAK,MAAMmG,OAAO,IAAIC,OAAO,EAAE;MAC7B,MAAM3F,GAAG,GAAG,IAAI,CAACT,yBAAyB,CAACmG,OAAO,CAAC;MACnD,IAAI1F,GAAG,CAACwB,KAAK,CAAC0D,KAAK,CAAC,EAAE;QACpBlF,GAAG,CAAC0B,MAAM,CAACwD,KAAK,CAAC;QACjBM,SAAS,GAAG,IAAI;MAClB;IACF;;IAEA;;IAEA,IAAI,CAACA,SAAS,EAAE;MACdzD,oBAAW,CAACsD,IAAI,CAAC,uEAAuE,EAAE;QACxFpD,MAAM,EAAEC,yBAAa;QACrBC,MAAM,EAAEC,kBAAO,CAACkD;MAClB,CAAC,CAAC;IACJ;EACF,CAAC;AACH;AAACM,OAAA,CAAAxH,OAAA,GAAAiB,OAAA","ignoreList":[]}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.WS_DISCONNECT_ALLOWED = exports.WELCOME_TIMEOUT = exports.TIMEOUT_REQ = exports.STATE_CONSULT = exports.RTD_PING_EVENT = exports.PING_API_URL = exports.PARTICIPANT_TYPES = exports.NOTIFS_RESOLVE_DELAY = exports.METHODS = exports.LOST_CONNECTION_RECOVERY_TIMEOUT = exports.KEEPALIVE_WORKER_INTERVAL = exports.CONNECTIVITY_CHECK_INTERVAL = exports.CLOSE_SOCKET_TIMEOUT_DURATION = exports.CLOSE_SOCKET_TIMEOUT = void 0;
|
|
6
|
+
exports.WS_DISCONNECT_ALLOWED = exports.WELCOME_TIMEOUT = exports.TIMEOUT_REQ = exports.STATE_CONSULT = exports.RTD_PING_EVENT = exports.PING_API_URL = exports.PARTICIPANT_TYPES = exports.NOTIFS_RESOLVE_DELAY = exports.METHODS = exports.LOST_CONNECTION_RECOVERY_TIMEOUT = exports.KEEPALIVE_WORKER_INTERVAL = exports.CONNECTIVITY_CHECK_INTERVAL = exports.CLOSE_SOCKET_TIMEOUT_DURATION = exports.CLOSE_SOCKET_TIMEOUT = exports.ALLOWED_ROUTING_NOTIFS_DOMAINS = void 0;
|
|
7
7
|
/**
|
|
8
8
|
* Interval in milliseconds for sending keepalive pings to the worker.
|
|
9
9
|
* @ignore
|
|
@@ -86,6 +86,14 @@ const PARTICIPANT_TYPES = exports.PARTICIPANT_TYPES = {
|
|
|
86
86
|
/** Interaction state for consultation */
|
|
87
87
|
const STATE_CONSULT = exports.STATE_CONSULT = 'consult';
|
|
88
88
|
|
|
89
|
+
/**
|
|
90
|
+
* Trusted domains for the RoutingNotifs WebSocket connection. A `webSocketUrl` returned by the
|
|
91
|
+
* subscribe/register API is only opened when its hostname matches one of these domains exactly
|
|
92
|
+
* or is a subdomain of one of them.
|
|
93
|
+
* @ignore
|
|
94
|
+
*/
|
|
95
|
+
const ALLOWED_ROUTING_NOTIFS_DOMAINS = exports.ALLOWED_ROUTING_NOTIFS_DOMAINS = ['cisco.com', 'ciscoccservice.com'];
|
|
96
|
+
|
|
89
97
|
// Method names for core services
|
|
90
98
|
const METHODS = exports.METHODS = {
|
|
91
99
|
// WebexRequest methods
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["KEEPALIVE_WORKER_INTERVAL","exports","NOTIFS_RESOLVE_DELAY","CLOSE_SOCKET_TIMEOUT_DURATION","PING_API_URL","WELCOME_TIMEOUT","RTD_PING_EVENT","TIMEOUT_REQ","LOST_CONNECTION_RECOVERY_TIMEOUT","WS_DISCONNECT_ALLOWED","CONNECTIVITY_CHECK_INTERVAL","CLOSE_SOCKET_TIMEOUT","PARTICIPANT_TYPES","EP_DN","DN","AGENT","STATE_CONSULT","METHODS","REQUEST","UPLOAD_LOGS","GET_ERROR_DETAILS","GET_COMMON_ERROR_DETAILS","CREATE_ERR_DETAILS_OBJECT","REQ","REQ_EMPTY","MAKE_API_REQUEST","CREATE_PROMISE","BIND_PRINT","BIND_CHECK","ON_MESSAGE","INIT_WEB_SOCKET","CLOSE","HANDLE_CONNECTION_LOST","REGISTER","CONNECT","WEB_SOCKET_ON_CLOSE_HANDLER","SETUP_EVENT_LISTENERS","DISPATCH_CONNECTION_EVENT","CS_HANDLE_CONNECTION_LOST","CLEAR_TIMER_ON_RESTORE_FAILED","HANDLE_RESTORE_FAILED","UPDATE_CONNECTION_DATA","SET_CONNECTION_PROP","ON_PING","HANDLE_SOCKET_CLOSE","ON_SOCKET_CLOSE"],"sources":["constants.ts"],"sourcesContent":["/**\n * Interval in milliseconds for sending keepalive pings to the worker.\n * @ignore\n */\nexport const KEEPALIVE_WORKER_INTERVAL = 4000;\n\n/**\n * Delay in milliseconds before resolving notification handlers.\n * @ignore\n */\nexport const NOTIFS_RESOLVE_DELAY = 1200;\n\n/**\n * Timeout duration in milliseconds before forcefully closing a WebSocket connection.\n * @ignore\n */\nexport const CLOSE_SOCKET_TIMEOUT_DURATION = 16000;\n\n/**\n * API endpoint used for connectivity or health checks.\n * @ignore\n */\nexport const PING_API_URL = '/health';\n\n/**\n * Timeout in milliseconds to wait for a welcome message after socket connection.\n * @ignore\n */\nexport const WELCOME_TIMEOUT = 30000;\n\n/**\n * Event name used for real-time device (RTD) ping status.\n * @ignore\n */\nexport const RTD_PING_EVENT = 'rtd-online-status';\n\n/**\n * Timeout in milliseconds for individual HTTP requests.\n * @ignore\n */\nexport const TIMEOUT_REQ = 20000;\n\n/**\n * Duration in milliseconds to wait before attempting lost connection recovery.\n * @ignore\n */\nexport const LOST_CONNECTION_RECOVERY_TIMEOUT = 50000;\n\n/**\n * Duration in milliseconds after which a WebSocket disconnect is considered allowed or expected.\n * @ignore\n */\nexport const WS_DISCONNECT_ALLOWED = 8000;\n\n/**\n * Interval in milliseconds to check for connectivity status.\n * @ignore\n */\nexport const CONNECTIVITY_CHECK_INTERVAL = 5000;\n\n/**\n * Timeout in milliseconds for cleanly closing the WebSocket.\n * @ignore\n */\nexport const CLOSE_SOCKET_TIMEOUT = 16000;\n\n/**\n * Constants for participant types, destination types, and interaction states\n * @ignore\n */\nexport const PARTICIPANT_TYPES = {\n /** Participant type for Entry Point Dial Number */\n EP_DN: 'EpDn',\n /** Participant type for dial number */\n DN: 'dn',\n /** Participant type for Agent */\n AGENT: 'Agent',\n};\n\n/** Interaction state for consultation */\nexport const STATE_CONSULT = 'consult';\n\n// Method names for core services\nexport const METHODS = {\n // WebexRequest methods\n REQUEST: 'request',\n UPLOAD_LOGS: 'uploadLogs',\n\n // Utils methods\n GET_ERROR_DETAILS: 'getErrorDetails',\n GET_COMMON_ERROR_DETAILS: 'getCommonErrorDetails',\n CREATE_ERR_DETAILS_OBJECT: 'createErrDetailsObject',\n\n // AqmReqs methods\n REQ: 'req',\n REQ_EMPTY: 'reqEmpty',\n MAKE_API_REQUEST: 'makeAPIRequest',\n CREATE_PROMISE: 'createPromise',\n BIND_PRINT: 'bindPrint',\n BIND_CHECK: 'bindCheck',\n ON_MESSAGE: 'onMessage',\n\n // WebSocketManager methods\n INIT_WEB_SOCKET: 'initWebSocket',\n CLOSE: 'close',\n HANDLE_CONNECTION_LOST: 'handleConnectionLost',\n REGISTER: 'register',\n CONNECT: 'connect',\n WEB_SOCKET_ON_CLOSE_HANDLER: 'webSocketOnCloseHandler',\n\n // ConnectionService methods\n SETUP_EVENT_LISTENERS: 'setupEventListeners',\n DISPATCH_CONNECTION_EVENT: 'dispatchConnectionEvent',\n CS_HANDLE_CONNECTION_LOST: 'handleConnectionLost',\n CLEAR_TIMER_ON_RESTORE_FAILED: 'clearTimerOnRestoreFailed',\n HANDLE_RESTORE_FAILED: 'handleRestoreFailed',\n UPDATE_CONNECTION_DATA: 'updateConnectionData',\n SET_CONNECTION_PROP: 'setConnectionProp',\n ON_PING: 'onPing',\n HANDLE_SOCKET_CLOSE: 'handleSocketClose',\n ON_SOCKET_CLOSE: 'onSocketClose',\n};\n"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E_DELAY","CLOSE_SOCKET_TIMEOUT_DURATION","PING_API_URL","WELCOME_TIMEOUT","RTD_PING_EVENT","TIMEOUT_REQ","LOST_CONNECTION_RECOVERY_TIMEOUT","WS_DISCONNECT_ALLOWED","CONNECTIVITY_CHECK_INTERVAL","CLOSE_SOCKET_TIMEOUT","PARTICIPANT_TYPES","EP_DN","DN","AGENT","STATE_CONSULT","ALLOWED_ROUTING_NOTIFS_DOMAINS","METHODS","REQUEST","UPLOAD_LOGS","GET_ERROR_DETAILS","GET_COMMON_ERROR_DETAILS","CREATE_ERR_DETAILS_OBJECT","REQ","REQ_EMPTY","MAKE_API_REQUEST","CREATE_PROMISE","BIND_PRINT","BIND_CHECK","ON_MESSAGE","INIT_WEB_SOCKET","CLOSE","HANDLE_CONNECTION_LOST","REGISTER","CONNECT","WEB_SOCKET_ON_CLOSE_HANDLER","SETUP_EVENT_LISTENERS","DISPATCH_CONNECTION_EVENT","CS_HANDLE_CONNECTION_LOST","CLEAR_TIMER_ON_RESTORE_FAILED","HANDLE_RESTORE_FAILED","UPDATE_CONNECTION_DATA","SET_CONNECTION_PROP","ON_PING","HANDLE_SOCKET_CLOSE","ON_SOCKET_CLOSE"],"sources":["constants.ts"],"sourcesContent":["/**\n * Interval in milliseconds for sending keepalive pings to the worker.\n * @ignore\n */\nexport const KEEPALIVE_WORKER_INTERVAL = 4000;\n\n/**\n * Delay in milliseconds before resolving notification handlers.\n * @ignore\n */\nexport const NOTIFS_RESOLVE_DELAY = 1200;\n\n/**\n * Timeout duration in milliseconds before forcefully closing a WebSocket connection.\n * @ignore\n */\nexport const CLOSE_SOCKET_TIMEOUT_DURATION = 16000;\n\n/**\n * API endpoint used for connectivity or health checks.\n * @ignore\n */\nexport const PING_API_URL = '/health';\n\n/**\n * Timeout in milliseconds to wait for a welcome message after socket connection.\n * @ignore\n */\nexport const WELCOME_TIMEOUT = 30000;\n\n/**\n * Event name used for real-time device (RTD) ping status.\n * @ignore\n */\nexport const RTD_PING_EVENT = 'rtd-online-status';\n\n/**\n * Timeout in milliseconds for individual HTTP requests.\n * @ignore\n */\nexport const TIMEOUT_REQ = 20000;\n\n/**\n * Duration in milliseconds to wait before attempting lost connection recovery.\n * @ignore\n */\nexport const LOST_CONNECTION_RECOVERY_TIMEOUT = 50000;\n\n/**\n * Duration in milliseconds after which a WebSocket disconnect is considered allowed or expected.\n * @ignore\n */\nexport const WS_DISCONNECT_ALLOWED = 8000;\n\n/**\n * Interval in milliseconds to check for connectivity status.\n * @ignore\n */\nexport const CONNECTIVITY_CHECK_INTERVAL = 5000;\n\n/**\n * Timeout in milliseconds for cleanly closing the WebSocket.\n * @ignore\n */\nexport const CLOSE_SOCKET_TIMEOUT = 16000;\n\n/**\n * Constants for participant types, destination types, and interaction states\n * @ignore\n */\nexport const PARTICIPANT_TYPES = {\n /** Participant type for Entry Point Dial Number */\n EP_DN: 'EpDn',\n /** Participant type for dial number */\n DN: 'dn',\n /** Participant type for Agent */\n AGENT: 'Agent',\n};\n\n/** Interaction state for consultation */\nexport const STATE_CONSULT = 'consult';\n\n/**\n * Trusted domains for the RoutingNotifs WebSocket connection. A `webSocketUrl` returned by the\n * subscribe/register API is only opened when its hostname matches one of these domains exactly\n * or is a subdomain of one of them.\n * @ignore\n */\nexport const ALLOWED_ROUTING_NOTIFS_DOMAINS = ['cisco.com', 'ciscoccservice.com'];\n\n// Method names for core services\nexport const METHODS = {\n // WebexRequest methods\n REQUEST: 'request',\n UPLOAD_LOGS: 'uploadLogs',\n\n // Utils methods\n GET_ERROR_DETAILS: 'getErrorDetails',\n GET_COMMON_ERROR_DETAILS: 'getCommonErrorDetails',\n CREATE_ERR_DETAILS_OBJECT: 'createErrDetailsObject',\n\n // AqmReqs methods\n REQ: 'req',\n REQ_EMPTY: 'reqEmpty',\n MAKE_API_REQUEST: 'makeAPIRequest',\n CREATE_PROMISE: 'createPromise',\n BIND_PRINT: 'bindPrint',\n BIND_CHECK: 'bindCheck',\n ON_MESSAGE: 'onMessage',\n\n // WebSocketManager methods\n INIT_WEB_SOCKET: 'initWebSocket',\n CLOSE: 'close',\n HANDLE_CONNECTION_LOST: 'handleConnectionLost',\n REGISTER: 'register',\n CONNECT: 'connect',\n WEB_SOCKET_ON_CLOSE_HANDLER: 'webSocketOnCloseHandler',\n\n // ConnectionService methods\n SETUP_EVENT_LISTENERS: 'setupEventListeners',\n DISPATCH_CONNECTION_EVENT: 'dispatchConnectionEvent',\n CS_HANDLE_CONNECTION_LOST: 'handleConnectionLost',\n CLEAR_TIMER_ON_RESTORE_FAILED: 'clearTimerOnRestoreFailed',\n HANDLE_RESTORE_FAILED: 'handleRestoreFailed',\n UPDATE_CONNECTION_DATA: 'updateConnectionData',\n SET_CONNECTION_PROP: 'setConnectionProp',\n ON_PING: 'onPing',\n HANDLE_SOCKET_CLOSE: 'handleSocketClose',\n ON_SOCKET_CLOSE: 'onSocketClose',\n};\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACO,MAAMA,yBAAyB,GAAAC,OAAA,CAAAD,yBAAA,GAAG,IAAI;;AAE7C;AACA;AACA;AACA;AACO,MAAME,oBAAoB,GAAAD,OAAA,CAAAC,oBAAA,GAAG,IAAI;;AAExC;AACA;AACA;AACA;AACO,MAAMC,6BAA6B,GAAAF,OAAA,CAAAE,6BAAA,GAAG,KAAK;;AAElD;AACA;AACA;AACA;AACO,MAAMC,YAAY,GAAAH,OAAA,CAAAG,YAAA,GAAG,SAAS;;AAErC;AACA;AACA;AACA;AACO,MAAMC,eAAe,GAAAJ,OAAA,CAAAI,eAAA,GAAG,KAAK;;AAEpC;AACA;AACA;AACA;AACO,MAAMC,cAAc,GAAAL,OAAA,CAAAK,cAAA,GAAG,mBAAmB;;AAEjD;AACA;AACA;AACA;AACO,MAAMC,WAAW,GAAAN,OAAA,CAAAM,WAAA,GAAG,KAAK;;AAEhC;AACA;AACA;AACA;AACO,MAAMC,gCAAgC,GAAAP,OAAA,CAAAO,gCAAA,GAAG,KAAK;;AAErD;AACA;AACA;AACA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yB,EAAE,sBAAsB;EACjDC,6BAA6B,EAAE,2BAA2B;EAC1DC,qBAAqB,EAAE,qBAAqB;EAC5CC,sBAAsB,EAAE,sBAAsB;EAC9CC,mBAAmB,EAAE,mBAAmB;EACxCC,OAAO,EAAE,QAAQ;EACjBC,mBAAmB,EAAE,mBAAmB;EACxCC,eAAe,EAAE;AACnB,CAAC","ignoreList":[]}
|
|
@@ -12,6 +12,7 @@ var _loggerProxy = _interopRequireDefault(require("../../../logger-proxy"));
|
|
|
12
12
|
var _keepalive = _interopRequireDefault(require("./keepalive.worker"));
|
|
13
13
|
var _constants2 = require("../constants");
|
|
14
14
|
var _constants3 = require("../../../constants");
|
|
15
|
+
var _Utils = require("../Utils");
|
|
15
16
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
17
|
/**
|
|
17
18
|
* WebSocketManager handles the WebSocket connection for Contact Center operations.
|
|
@@ -100,7 +101,22 @@ class WebSocketManager extends _events.default {
|
|
|
100
101
|
'X-ORGANIZATION-ID': orgId
|
|
101
102
|
} : undefined
|
|
102
103
|
});
|
|
103
|
-
|
|
104
|
+
const {
|
|
105
|
+
webSocketUrl
|
|
106
|
+
} = subscribeResponse.body;
|
|
107
|
+
|
|
108
|
+
// Only a `wss` URL whose hostname is, or is a subdomain of, one of the allow-listed
|
|
109
|
+
// RoutingNotifs domains is considered trusted.
|
|
110
|
+
let isWssUrl = false;
|
|
111
|
+
try {
|
|
112
|
+
isWssUrl = !!webSocketUrl && new URL(webSocketUrl).protocol === 'wss:';
|
|
113
|
+
} catch (error) {
|
|
114
|
+
isWssUrl = false;
|
|
115
|
+
}
|
|
116
|
+
if (!isWssUrl || !(0, _Utils.isAllowedUrlHost)(webSocketUrl, _constants2.ALLOWED_ROUTING_NOTIFS_DOMAINS)) {
|
|
117
|
+
throw new Error('Rejected webSocketUrl from RoutingNotifs registration: scheme or host not allow-listed');
|
|
118
|
+
}
|
|
119
|
+
this.url = webSocketUrl;
|
|
104
120
|
} catch (e) {
|
|
105
121
|
_loggerProxy.default.error(`Register API Failed, Request to RoutingNotifs websocket registration API failed ${e}`, {
|
|
106
122
|
module: _constants3.WEB_SOCKET_MANAGER_FILE,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_events","_interopRequireDefault","require","_types","_constants","_types2","_loggerProxy","_keepalive","_constants2","_constants3","e","__esModule","default","WebSocketManager","EventEmitter","url","welcomePromiseResolve","constructor","options","webex","shouldReconnect","websocket","isSocketClosed","isWelcomeReceived","forceCloseWebSocketOnTimeout","isConnectionLost","workerScriptBlob","Blob","workerScript","type","keepaliveWorker","Worker","URL","createObjectURL","initWebSocket","body","connectionConfig","resource","register","error","LoggerProxy","module","WEB_SOCKET_MANAGER_FILE","method","METHODS","INIT_WEB_SOCKET","Promise","resolve","reject","connect","catch","close","reason","postMessage","log","CLOSE","handleConnectionLost","event","isIntEnv","internal","services","isIntegrationEnvironment","orgId","credentials","getOrgId","REGISTER","subscribeResponse","request","service","WCC_API_GATEWAY","HTTP_METHODS","POST","headers","undefined","webSocketUrl","CONNECT","WebSocket","onopen","send","JSON","stringify","keepalive","onmessage","keepAliveEvent","data","intervalDuration","KEEPALIVE_WORKER_INTERVAL","closeSocketTimeout","CLOSE_SOCKET_TIMEOUT","onerror","onclose","webSocketOnCloseHandler","emit","eventData","parse","CC_EVENTS","WELCOME","issueReason","onlineStatus","navigator","onLine","WEB_SOCKET_ON_CLOSE_HANDLER","exports","_default"],"sources":["WebSocketManager.ts"],"sourcesContent":["import EventEmitter from 'events';\nimport {WebexSDK, SubscribeRequest, HTTP_METHODS} from '../../../types';\nimport {WCC_API_GATEWAY} from '../../constants';\nimport {ConnectionLostDetails} from './types';\nimport {CC_EVENTS, SubscribeResponse, WelcomeResponse} from '../../config/types';\nimport LoggerProxy from '../../../logger-proxy';\nimport workerScript from './keepalive.worker';\nimport {KEEPALIVE_WORKER_INTERVAL, CLOSE_SOCKET_TIMEOUT, METHODS} from '../constants';\nimport {WEB_SOCKET_MANAGER_FILE} from '../../../constants';\n\n/**\n * WebSocketManager handles the WebSocket connection for Contact Center operations.\n * It manages the connection lifecycle, including registration, reconnection, and message handling.\n * It also utilizes a Web Worker to manage keepalive messages and socket closure.\n * @ignore\n */\nexport class WebSocketManager extends EventEmitter {\n private websocket: WebSocket;\n shouldReconnect: boolean;\n isSocketClosed: boolean;\n private isWelcomeReceived: boolean;\n private url: string | null = null;\n private forceCloseWebSocketOnTimeout: boolean;\n private isConnectionLost: boolean;\n private webex: WebexSDK;\n private welcomePromiseResolve:\n | ((value: WelcomeResponse | PromiseLike<WelcomeResponse>) => void)\n | null = null;\n\n private keepaliveWorker: Worker;\n\n constructor(options: {webex: WebexSDK}) {\n super();\n const {webex} = options;\n this.webex = webex;\n this.shouldReconnect = true;\n this.websocket = {} as WebSocket;\n this.isSocketClosed = false;\n this.isWelcomeReceived = false;\n this.forceCloseWebSocketOnTimeout = false;\n this.isConnectionLost = false;\n\n const workerScriptBlob = new Blob([workerScript], {type: 'application/javascript'});\n this.keepaliveWorker = new Worker(URL.createObjectURL(workerScriptBlob));\n }\n\n async initWebSocket(options: {\n body: SubscribeRequest;\n resource: string;\n }): Promise<WelcomeResponse> {\n const {body: connectionConfig, resource} = options;\n try {\n await this.register(connectionConfig, resource);\n } catch (error) {\n LoggerProxy.error(`[WebSocketStatus] | Error in registering Websocket ${error}`, {\n module: WEB_SOCKET_MANAGER_FILE,\n method: METHODS.INIT_WEB_SOCKET,\n });\n throw error;\n }\n\n return new Promise((resolve, reject) => {\n this.welcomePromiseResolve = resolve;\n this.connect().catch((error) => {\n LoggerProxy.error(`[WebSocketStatus] | Error in connecting Websocket ${error}`, {\n module: WEB_SOCKET_MANAGER_FILE,\n method: METHODS.INIT_WEB_SOCKET,\n });\n reject(error);\n });\n });\n }\n\n close(shouldReconnect: boolean, reason = 'Unknown') {\n if (!this.isSocketClosed && this.shouldReconnect) {\n this.shouldReconnect = shouldReconnect;\n this.websocket.close();\n this.keepaliveWorker.postMessage({type: 'terminate'});\n LoggerProxy.log(\n `[WebSocketStatus] | event=webSocketClose | WebSocket connection closed manually REASON: ${reason}`,\n {module: WEB_SOCKET_MANAGER_FILE, method: METHODS.CLOSE}\n );\n }\n }\n\n handleConnectionLost(event: ConnectionLostDetails) {\n this.isConnectionLost = event.isConnectionLost;\n }\n\n private async register(connectionConfig: SubscribeRequest, resource: string) {\n try {\n // X-ORGANIZATION-ID header is only required for INT environments\n const isIntEnv = this.webex.internal?.services?.isIntegrationEnvironment() || false;\n const orgId = this.webex.credentials.getOrgId();\n\n if (isIntEnv && orgId) {\n LoggerProxy.log(`[WebSocketManager] Adding X-ORGANIZATION-ID header for INT environment`, {\n module: WEB_SOCKET_MANAGER_FILE,\n method: METHODS.REGISTER,\n });\n }\n\n const subscribeResponse: SubscribeResponse = await this.webex.request({\n service: WCC_API_GATEWAY,\n resource,\n method: HTTP_METHODS.POST,\n body: connectionConfig,\n headers: isIntEnv && orgId ? {'X-ORGANIZATION-ID': orgId} : undefined,\n });\n this.url = subscribeResponse.body.webSocketUrl;\n } catch (e) {\n LoggerProxy.error(\n `Register API Failed, Request to RoutingNotifs websocket registration API failed ${e}`,\n {module: WEB_SOCKET_MANAGER_FILE, method: METHODS.REGISTER}\n );\n throw e;\n }\n }\n\n private async connect() {\n if (!this.url) {\n return undefined;\n }\n LoggerProxy.log(\n `[WebSocketStatus] | event=webSocketConnecting | Connecting to WebSocket: ${this.url}`,\n {module: WEB_SOCKET_MANAGER_FILE, method: METHODS.CONNECT}\n );\n this.websocket = new WebSocket(this.url);\n\n return new Promise((resolve, reject) => {\n this.websocket.onopen = () => {\n this.isSocketClosed = false;\n this.shouldReconnect = true;\n\n this.websocket.send(JSON.stringify({keepalive: 'true'}));\n this.keepaliveWorker.onmessage = (keepAliveEvent: {data: any}) => {\n if (keepAliveEvent?.data?.type === 'keepalive') {\n this.websocket.send(JSON.stringify({keepalive: 'true'}));\n }\n\n if (keepAliveEvent?.data?.type === 'closeSocket' && this.isConnectionLost) {\n this.forceCloseWebSocketOnTimeout = true;\n this.close(true, 'WebSocket did not auto close within 16 secs');\n LoggerProxy.error(\n '[webSocketTimeout] | event=webSocketTimeout | WebSocket connection closed forcefully',\n {module: WEB_SOCKET_MANAGER_FILE, method: METHODS.CONNECT}\n );\n }\n };\n\n this.keepaliveWorker.postMessage({\n type: 'start',\n intervalDuration: KEEPALIVE_WORKER_INTERVAL, // Keepalive interval\n isSocketClosed: this.isSocketClosed,\n closeSocketTimeout: CLOSE_SOCKET_TIMEOUT, // Close socket timeout\n });\n };\n\n this.websocket.onerror = (event: any) => {\n LoggerProxy.error(\n `[WebSocketStatus] | event=socketConnectionFailed | WebSocket connection failed ${event}`,\n {module: WEB_SOCKET_MANAGER_FILE, method: METHODS.CONNECT}\n );\n reject();\n };\n\n this.websocket.onclose = async (event: any) => {\n this.webSocketOnCloseHandler(event);\n };\n\n this.websocket.onmessage = (e: MessageEvent) => {\n this.emit('message', e.data);\n const eventData = JSON.parse(e.data);\n\n if (eventData.type === CC_EVENTS.WELCOME) {\n this.isWelcomeReceived = true;\n if (this.welcomePromiseResolve) {\n this.welcomePromiseResolve(eventData.data as WelcomeResponse);\n this.welcomePromiseResolve = null;\n }\n }\n\n if (eventData.type === 'AGENT_MULTI_LOGIN') {\n this.close(false, 'multiLogin');\n LoggerProxy.error(\n '[WebSocketStatus] | event=agentMultiLogin | WebSocket connection closed by agent multiLogin',\n {module: WEB_SOCKET_MANAGER_FILE, method: METHODS.CONNECT}\n );\n }\n };\n });\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n private async webSocketOnCloseHandler(event: any) {\n this.isSocketClosed = true;\n this.keepaliveWorker.postMessage({type: 'terminate'});\n if (this.shouldReconnect) {\n this.emit('socketClose');\n let issueReason;\n if (this.forceCloseWebSocketOnTimeout) {\n issueReason = 'WebSocket auto close timed out. Forcefully closed websocket.';\n } else {\n const onlineStatus = navigator.onLine;\n issueReason = !onlineStatus\n ? 'network issue'\n : 'missing keepalive from either desktop or notif service';\n }\n LoggerProxy.error(\n `[WebSocketStatus] | event=webSocketClose | WebSocket connection closed REASON: ${issueReason}`,\n {module: WEB_SOCKET_MANAGER_FILE, method: METHODS.WEB_SOCKET_ON_CLOSE_HANDLER}\n );\n this.forceCloseWebSocketOnTimeout = false;\n }\n }\n}\n\nexport default WebSocketManager;\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AAEA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,UAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,WAAA,GAAAN,OAAA;AACA,IAAAO,WAAA,GAAAP,OAAA;AAA2D,SAAAD,uBAAAS,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE3D;AACA;AACA;AACA;AACA;AACA;AACO,MAAMG,gBAAgB,SAASC,eAAY,CAAC;EAKzCC,GAAG,GAAkB,IAAI;EAIzBC,qBAAqB,GAElB,IAAI;EAIfC,WAAWA,CAACC,OAA0B,EAAE;IACtC,KAAK,CAAC,CAAC;IACP,MAAM;MAACC;IAAK,CAAC,GAAGD,OAAO;IACvB,IAAI,CAACC,KAAK,GAAGA,KAAK;IAClB,IAAI,CAACC,eAAe,GAAG,IAAI;IAC3B,IAAI,CAACC,SAAS,GAAG,CAAC,CAAc;IAChC,IAAI,CAACC,cAAc,GAAG,KAAK;IAC3B,IAAI,CAACC,iBAAiB,GAAG,KAAK;IAC9B,IAAI,CAACC,4BAA4B,GAAG,KAAK;IACzC,IAAI,CAACC,gBAAgB,GAAG,KAAK;IAE7B,MAAMC,gBAAgB,GAAG,IAAIC,IAAI,CAAC,CAACC,kBAAY,CAAC,EAAE;MAACC,IAAI,EAAE;IAAwB,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B;YAAEC,MAAM,EAAEC,mBAAO,CAAC+B;UAAO,CAC3D,CAAC;QACH;MACF,CAAC;IACH,CAAC,CAAC;EACJ;;EAEA;EACA,MAAcgB,uBAAuBA,CAAClC,KAAU,EAAE;IAChD,IAAI,CAACnC,cAAc,GAAG,IAAI;IAC1B,IAAI,CAACQ,eAAe,CAACuB,WAAW,CAAC;MAACxB,IAAI,EAAE;IAAW,CAAC,CAAC;IACrD,IAAI,IAAI,CAACT,eAAe,EAAE;MACxB,IAAI,CAACwE,IAAI,CAAC,aAAa,CAAC;MACxB,IAAIK,WAAW;MACf,IAAI,IAAI,CAACzE,4BAA4B,EAAE;QACrCyE,WAAW,GAAG,8DAA8D;MAC9E,CAAC,MAAM;QACL,MAAMC,YAAY,GAAGC,SAAS,CAACC,MAAM;QACrCH,WAAW,GAAG,CAACC,YAAY,GACvB,eAAe,GACf,wDAAwD;MAC9D;MACA1D,oBAAW,CAACD,KAAK,CACf,kFAAkF0D,WAAW,EAAE,EAC/F;QAACxD,MAAM,EAAEC,mCAAuB;QAAEC,MAAM,EAAEC,mBAAO,CAACyD;MAA2B,CAC/E,CAAC;MACD,IAAI,CAAC7E,4BAA4B,GAAG,KAAK;IAC3C;EACF;AACF;AAAC8E,OAAA,CAAAzF,gBAAA,GAAAA,gBAAA;AAAA,IAAA0F,QAAA,GAAAD,OAAA,CAAA1F,OAAA,GAEcC,gBAAgB","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_events","_interopRequireDefault","require","_types","_constants","_types2","_loggerProxy","_keepalive","_constants2","_constants3","_Utils","e","__esModule","default","WebSocketManager","EventEmitter","url","welcomePromiseResolve","constructor","options","webex","shouldReconnect","websocket","isSocketClosed","isWelcomeReceived","forceCloseWebSocketOnTimeout","isConnectionLost","workerScriptBlob","Blob","workerScript","type","keepaliveWorker","Worker","URL","createObjectURL","initWebSocket","body","connectionConfig","resource","register","error","LoggerProxy","module","WEB_SOCKET_MANAGER_FILE","method","METHODS","INIT_WEB_SOCKET","Promise","resolve","reject","connect","catch","close","reason","postMessage","log","CLOSE","handleConnectionLost","event","isIntEnv","internal","services","isIntegrationEnvironment","orgId","credentials","getOrgId","REGISTER","subscribeResponse","request","service","WCC_API_GATEWAY","HTTP_METHODS","POST","headers","undefined","webSocketUrl","isWssUrl","protocol","isAllowedUrlHost","ALLOWED_ROUTING_NOTIFS_DOMAINS","Error","CONNECT","WebSocket","onopen","send","JSON","stringify","keepalive","onmessage","keepAliveEvent","data","intervalDuration","KEEPALIVE_WORKER_INTERVAL","closeSocketTimeout","CLOSE_SOCKET_TIMEOUT","onerror","onclose","webSocketOnCloseHandler","emit","eventData","parse","CC_EVENTS","WELCOME","issueReason","onlineStatus","navigator","onLine","WEB_SOCKET_ON_CLOSE_HANDLER","exports","_default"],"sources":["WebSocketManager.ts"],"sourcesContent":["import EventEmitter from 'events';\nimport {WebexSDK, SubscribeRequest, HTTP_METHODS} from '../../../types';\nimport {WCC_API_GATEWAY} from '../../constants';\nimport {ConnectionLostDetails} from './types';\nimport {CC_EVENTS, SubscribeResponse, WelcomeResponse} from '../../config/types';\nimport LoggerProxy from '../../../logger-proxy';\nimport workerScript from './keepalive.worker';\nimport {\n KEEPALIVE_WORKER_INTERVAL,\n CLOSE_SOCKET_TIMEOUT,\n METHODS,\n ALLOWED_ROUTING_NOTIFS_DOMAINS,\n} from '../constants';\nimport {WEB_SOCKET_MANAGER_FILE} from '../../../constants';\nimport {isAllowedUrlHost} from '../Utils';\n\n/**\n * WebSocketManager handles the WebSocket connection for Contact Center operations.\n * It manages the connection lifecycle, including registration, reconnection, and message handling.\n * It also utilizes a Web Worker to manage keepalive messages and socket closure.\n * @ignore\n */\nexport class WebSocketManager extends EventEmitter {\n private websocket: WebSocket;\n shouldReconnect: boolean;\n isSocketClosed: boolean;\n private isWelcomeReceived: boolean;\n private url: string | null = null;\n private forceCloseWebSocketOnTimeout: boolean;\n private isConnectionLost: boolean;\n private webex: WebexSDK;\n private welcomePromiseResolve:\n | ((value: WelcomeResponse | PromiseLike<WelcomeResponse>) => void)\n | null = null;\n\n private keepaliveWorker: Worker;\n\n constructor(options: {webex: WebexSDK}) {\n super();\n const {webex} = options;\n this.webex = webex;\n this.shouldReconnect = true;\n this.websocket = {} as WebSocket;\n this.isSocketClosed = false;\n this.isWelcomeReceived = false;\n this.forceCloseWebSocketOnTimeout = false;\n this.isConnectionLost = false;\n\n const workerScriptBlob = new Blob([workerScript], {type: 'application/javascript'});\n this.keepaliveWorker = new Worker(URL.createObjectURL(workerScriptBlob));\n }\n\n async initWebSocket(options: {\n body: SubscribeRequest;\n resource: string;\n }): Promise<WelcomeResponse> {\n const {body: connectionConfig, resource} = options;\n try {\n await this.register(connectionConfig, resource);\n } catch (error) {\n LoggerProxy.error(`[WebSocketStatus] | Error in registering Websocket ${error}`, {\n module: WEB_SOCKET_MANAGER_FILE,\n method: METHODS.INIT_WEB_SOCKET,\n });\n throw error;\n }\n\n return new Promise((resolve, reject) => {\n this.welcomePromiseResolve = resolve;\n this.connect().catch((error) => {\n LoggerProxy.error(`[WebSocketStatus] | Error in connecting Websocket ${error}`, {\n module: WEB_SOCKET_MANAGER_FILE,\n method: METHODS.INIT_WEB_SOCKET,\n });\n reject(error);\n });\n });\n }\n\n close(shouldReconnect: boolean, reason = 'Unknown') {\n if (!this.isSocketClosed && this.shouldReconnect) {\n this.shouldReconnect = shouldReconnect;\n this.websocket.close();\n this.keepaliveWorker.postMessage({type: 'terminate'});\n LoggerProxy.log(\n `[WebSocketStatus] | event=webSocketClose | WebSocket connection closed manually REASON: ${reason}`,\n {module: WEB_SOCKET_MANAGER_FILE, method: METHODS.CLOSE}\n );\n }\n }\n\n handleConnectionLost(event: ConnectionLostDetails) {\n this.isConnectionLost = event.isConnectionLost;\n }\n\n private async register(connectionConfig: SubscribeRequest, resource: string) {\n try {\n // X-ORGANIZATION-ID header is only required for INT environments\n const isIntEnv = this.webex.internal?.services?.isIntegrationEnvironment() || false;\n const orgId = this.webex.credentials.getOrgId();\n\n if (isIntEnv && orgId) {\n LoggerProxy.log(`[WebSocketManager] Adding X-ORGANIZATION-ID header for INT environment`, {\n module: WEB_SOCKET_MANAGER_FILE,\n method: METHODS.REGISTER,\n });\n }\n\n const subscribeResponse: SubscribeResponse = await this.webex.request({\n service: WCC_API_GATEWAY,\n resource,\n method: HTTP_METHODS.POST,\n body: connectionConfig,\n headers: isIntEnv && orgId ? {'X-ORGANIZATION-ID': orgId} : undefined,\n });\n const {webSocketUrl} = subscribeResponse.body;\n\n // Only a `wss` URL whose hostname is, or is a subdomain of, one of the allow-listed\n // RoutingNotifs domains is considered trusted.\n let isWssUrl = false;\n\n try {\n isWssUrl = !!webSocketUrl && new URL(webSocketUrl).protocol === 'wss:';\n } catch (error) {\n isWssUrl = false;\n }\n\n if (!isWssUrl || !isAllowedUrlHost(webSocketUrl, ALLOWED_ROUTING_NOTIFS_DOMAINS)) {\n throw new Error(\n 'Rejected webSocketUrl from RoutingNotifs registration: scheme or host not allow-listed'\n );\n }\n\n this.url = webSocketUrl;\n } catch (e) {\n LoggerProxy.error(\n `Register API Failed, Request to RoutingNotifs websocket registration API failed ${e}`,\n {module: WEB_SOCKET_MANAGER_FILE, method: METHODS.REGISTER}\n );\n throw e;\n }\n }\n\n private async connect() {\n if (!this.url) {\n return undefined;\n }\n LoggerProxy.log(\n `[WebSocketStatus] | event=webSocketConnecting | Connecting to WebSocket: ${this.url}`,\n {module: WEB_SOCKET_MANAGER_FILE, method: METHODS.CONNECT}\n );\n this.websocket = new WebSocket(this.url);\n\n return new Promise((resolve, reject) => {\n this.websocket.onopen = () => {\n this.isSocketClosed = false;\n this.shouldReconnect = true;\n\n this.websocket.send(JSON.stringify({keepalive: 'true'}));\n this.keepaliveWorker.onmessage = (keepAliveEvent: {data: any}) => {\n if (keepAliveEvent?.data?.type === 'keepalive') {\n this.websocket.send(JSON.stringify({keepalive: 'true'}));\n }\n\n if (keepAliveEvent?.data?.type === 'closeSocket' && this.isConnectionLost) {\n this.forceCloseWebSocketOnTimeout = true;\n this.close(true, 'WebSocket did not auto close within 16 secs');\n LoggerProxy.error(\n '[webSocketTimeout] | event=webSocketTimeout | WebSocket connection closed forcefully',\n {module: WEB_SOCKET_MANAGER_FILE, method: METHODS.CONNECT}\n );\n }\n };\n\n this.keepaliveWorker.postMessage({\n type: 'start',\n intervalDuration: KEEPALIVE_WORKER_INTERVAL, // Keepalive interval\n isSocketClosed: this.isSocketClosed,\n closeSocketTimeout: CLOSE_SOCKET_TIMEOUT, // Close socket timeout\n });\n };\n\n this.websocket.onerror = (event: any) => {\n LoggerProxy.error(\n `[WebSocketStatus] | event=socketConnectionFailed | WebSocket connection failed ${event}`,\n {module: WEB_SOCKET_MANAGER_FILE, method: METHODS.CONNECT}\n );\n reject();\n };\n\n this.websocket.onclose = async (event: any) => {\n this.webSocketOnCloseHandler(event);\n };\n\n this.websocket.onmessage = (e: MessageEvent) => {\n this.emit('message', e.data);\n const eventData = JSON.parse(e.data);\n\n if (eventData.type === CC_EVENTS.WELCOME) {\n this.isWelcomeReceived = true;\n if (this.welcomePromiseResolve) {\n this.welcomePromiseResolve(eventData.data as WelcomeResponse);\n this.welcomePromiseResolve = null;\n }\n }\n\n if (eventData.type === 'AGENT_MULTI_LOGIN') {\n this.close(false, 'multiLogin');\n LoggerProxy.error(\n '[WebSocketStatus] | event=agentMultiLogin | WebSocket connection closed by agent multiLogin',\n {module: WEB_SOCKET_MANAGER_FILE, method: METHODS.CONNECT}\n );\n }\n };\n });\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n private async webSocketOnCloseHandler(event: any) {\n this.isSocketClosed = true;\n this.keepaliveWorker.postMessage({type: 'terminate'});\n if (this.shouldReconnect) {\n this.emit('socketClose');\n let issueReason;\n if (this.forceCloseWebSocketOnTimeout) {\n issueReason = 'WebSocket auto close timed out. Forcefully closed websocket.';\n } else {\n const onlineStatus = navigator.onLine;\n issueReason = !onlineStatus\n ? 'network issue'\n : 'missing keepalive from either desktop or notif service';\n }\n LoggerProxy.error(\n `[WebSocketStatus] | event=webSocketClose | WebSocket connection closed REASON: ${issueReason}`,\n {module: WEB_SOCKET_MANAGER_FILE, method: METHODS.WEB_SOCKET_ON_CLOSE_HANDLER}\n );\n this.forceCloseWebSocketOnTimeout = false;\n }\n }\n}\n\nexport default WebSocketManager;\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AAEA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,UAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,WAAA,GAAAN,OAAA;AAMA,IAAAO,WAAA,GAAAP,OAAA;AACA,IAAAQ,MAAA,GAAAR,OAAA;AAA0C,SAAAD,uBAAAU,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE1C;AACA;AACA;AACA;AACA;AACA;AACO,MAAMG,gBAAgB,SAASC,eAAY,CAAC;EAKzCC,GAAG,GAAkB,IAAI;EAIzBC,qBAAqB,GAElB,IAAI;EAIfC,WAAWA,CAACC,OAA0B,EAAE;IACtC,KAAK,CAAC,CAAC;IACP,MAAM;MAACC;IAAK,CAAC,GAAGD,OAAO;IACvB,IAAI,CAACC,KAAK,GAAGA,KAAK;IAClB,IAAI,CAACC,eAAe,GAAG,IAAI;IAC3B,IAAI,CAACC,SAAS,GAAG,CAAC,CAAc;IAChC,IAAI,CAACC,cAAc,GAAG,KAAK;IAC3B,IAAI,CAACC,iBAAiB,GAAG,KAAK;IAC9B,IAAI,CAACC,4BAA4B,GAAG,KAAK;IACzC,IAAI,CAACC,gBAAgB,GAAG,KAAK;IAE7B,MAAMC,gBAAgB,GAAG,IAAIC,IAAI,CAAC,CAACC,kBAAY,CAAC,EAAE;MAACC,IAAI,EAAE;IA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A,GAAAD,OAAA,CAAA/F,OAAA,GAEcC,gBAAgB","ignoreList":[]}
|
|
@@ -17,6 +17,15 @@ export declare class ApiAIAssistant {
|
|
|
17
17
|
private createWellnessError;
|
|
18
18
|
constructor(webex: WebexSDK, wellnessContextProvider?: WellnessBreakContextProvider);
|
|
19
19
|
setAIFeatureFlags(aiFeature: AIFeatureFlags): void;
|
|
20
|
+
/**
|
|
21
|
+
* Validates a caller-supplied identifier (agentId/interactionId) before it is used to
|
|
22
|
+
* construct a request. Accepts a non-empty alphanumeric identifier that may contain
|
|
23
|
+
* hyphens or underscores.
|
|
24
|
+
* @param value - the identifier to validate
|
|
25
|
+
* @returns {boolean} true when the identifier is a non-empty, well-formed string
|
|
26
|
+
* @private
|
|
27
|
+
*/
|
|
28
|
+
private isValidTranscriptIdentifier;
|
|
20
29
|
private sendWellnessBreakAction;
|
|
21
30
|
/**
|
|
22
31
|
* Requests an Agent Wellness Break.
|
|
@@ -28,6 +28,15 @@ export declare const WCC_CALLING_RTMS_DOMAIN = "wcc-calling-rtms-domain";
|
|
|
28
28
|
* @ignore
|
|
29
29
|
*/
|
|
30
30
|
export declare const DEFAULT_RTMS_DOMAIN = "rtw.prod-us1.rtmsprod.net";
|
|
31
|
+
/**
|
|
32
|
+
* Trusted domain suffix for RTMS hosts returned by the u2c service catalog. A catalog-provided
|
|
33
|
+
* RTMS host is only used when its hostname is, or is a subdomain of, this domain; otherwise
|
|
34
|
+
* `DEFAULT_RTMS_DOMAIN` is used.
|
|
35
|
+
* @type {string}
|
|
36
|
+
* @public
|
|
37
|
+
* @ignore
|
|
38
|
+
*/
|
|
39
|
+
export declare const ALLOWED_RTMS_DOMAIN = "rtmsprod.net";
|
|
31
40
|
/**
|
|
32
41
|
* Timeout in milliseconds for WebSocket events.
|
|
33
42
|
* @type {number}
|
|
@@ -23,6 +23,14 @@ export declare const stripDialPlanChars: (input: string, strippedChars: string)
|
|
|
23
23
|
* @returns true if the input matches at least one dial plan regex pattern or no entries are configured, false otherwise
|
|
24
24
|
*/
|
|
25
25
|
export declare const isValidDialNumber: (input: string, dialPlanEntries: DialPlan['dialPlanEntity']) => boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Checks whether a URL's hostname is, or is a subdomain of, one of the allowed domains.
|
|
28
|
+
*
|
|
29
|
+
* @param url - The candidate URL to validate
|
|
30
|
+
* @param allowedDomains - Domains (or domain suffixes) the URL's hostname must match
|
|
31
|
+
* @returns true when the URL parses and its hostname matches an allowed domain, false otherwise
|
|
32
|
+
*/
|
|
33
|
+
export declare const isAllowedUrlHost: (url: string | undefined | null, allowedDomains: string[]) => boolean;
|
|
26
34
|
export declare const getStationLoginErrorData: (failure: Failure, loginOption: LoginOption) => {
|
|
27
35
|
message: any;
|
|
28
36
|
fieldName: any;
|
|
@@ -67,6 +67,13 @@ export declare const PARTICIPANT_TYPES: {
|
|
|
67
67
|
};
|
|
68
68
|
/** Interaction state for consultation */
|
|
69
69
|
export declare const STATE_CONSULT = "consult";
|
|
70
|
+
/**
|
|
71
|
+
* Trusted domains for the RoutingNotifs WebSocket connection. A `webSocketUrl` returned by the
|
|
72
|
+
* subscribe/register API is only opened when its hostname matches one of these domains exactly
|
|
73
|
+
* or is a subdomain of one of them.
|
|
74
|
+
* @ignore
|
|
75
|
+
*/
|
|
76
|
+
export declare const ALLOWED_ROUTING_NOTIFS_DOMAINS: string[];
|
|
70
77
|
export declare const METHODS: {
|
|
71
78
|
REQUEST: string;
|
|
72
79
|
UPLOAD_LOGS: string;
|
package/dist/webex.js
CHANGED
package/package.json
CHANGED
package/src/cc.ts
CHANGED
|
@@ -87,6 +87,13 @@ import type {
|
|
|
87
87
|
ContactServiceQueueSearchParams,
|
|
88
88
|
} from './types';
|
|
89
89
|
|
|
90
|
+
/**
|
|
91
|
+
* Typed allow-list of server-controlled websocket event names this SDK re-emits verbatim.
|
|
92
|
+
* Guards against emitting an arbitrary/unknown `data.type` supplied by the websocket payload.
|
|
93
|
+
* @ignore
|
|
94
|
+
*/
|
|
95
|
+
const CC_EVENT_ALLOW_LIST = new Set<string>(Object.values(CC_EVENTS));
|
|
96
|
+
|
|
90
97
|
/**
|
|
91
98
|
* The main Contact Center plugin class that enables integration with Webex Contact Center.
|
|
92
99
|
*
|
|
@@ -1552,8 +1559,14 @@ export default class ContactCenter extends WebexPlugin implements IContactCenter
|
|
|
1552
1559
|
*/
|
|
1553
1560
|
private handleWebsocketMessage = (event: string) => {
|
|
1554
1561
|
const eventData = JSON.parse(event);
|
|
1555
|
-
// Re-emit all the events related to agent except keep-alives
|
|
1556
|
-
|
|
1562
|
+
// Re-emit all the events related to agent except keep-alives. Only event names present in
|
|
1563
|
+
// the typed CC_EVENTS allow-list are emitted; unknown/server-injected types are ignored.
|
|
1564
|
+
if (
|
|
1565
|
+
!eventData.keepalive &&
|
|
1566
|
+
eventData.data &&
|
|
1567
|
+
eventData.data.type &&
|
|
1568
|
+
CC_EVENT_ALLOW_LIST.has(eventData.data.type)
|
|
1569
|
+
) {
|
|
1557
1570
|
// @ts-ignore
|
|
1558
1571
|
this.emit(eventData.data.type, eventData.data);
|
|
1559
1572
|
}
|