@webex/plugin-meetings 3.0.0-stream-classes.3 → 3.0.0-stream-classes.5

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.
Files changed (77) hide show
  1. package/dist/breakouts/breakout.js +1 -1
  2. package/dist/breakouts/index.js +1 -1
  3. package/dist/constants.js +5 -1
  4. package/dist/constants.js.map +1 -1
  5. package/dist/interpretation/index.js +1 -1
  6. package/dist/interpretation/siLanguage.js +1 -1
  7. package/dist/locus-info/index.js +25 -1
  8. package/dist/locus-info/index.js.map +1 -1
  9. package/dist/locus-info/parser.js +5 -0
  10. package/dist/locus-info/parser.js.map +1 -1
  11. package/dist/meeting/index.js +72 -15
  12. package/dist/meeting/index.js.map +1 -1
  13. package/dist/meeting/locusMediaRequest.js +1 -1
  14. package/dist/meeting/locusMediaRequest.js.map +1 -1
  15. package/dist/meeting/request.js +24 -14
  16. package/dist/meeting/request.js.map +1 -1
  17. package/dist/meeting/util.js +33 -3
  18. package/dist/meeting/util.js.map +1 -1
  19. package/dist/meetings/index.js +3 -4
  20. package/dist/meetings/index.js.map +1 -1
  21. package/dist/metrics/constants.js +4 -1
  22. package/dist/metrics/constants.js.map +1 -1
  23. package/dist/multistream/remoteMediaManager.js +46 -9
  24. package/dist/multistream/remoteMediaManager.js.map +1 -1
  25. package/dist/reachability/index.js +2 -11
  26. package/dist/reachability/index.js.map +1 -1
  27. package/dist/reachability/request.js.map +1 -1
  28. package/dist/reconnection-manager/index.js +26 -22
  29. package/dist/reconnection-manager/index.js.map +1 -1
  30. package/dist/roap/index.js +5 -7
  31. package/dist/roap/index.js.map +1 -1
  32. package/dist/roap/request.js +1 -0
  33. package/dist/roap/request.js.map +1 -1
  34. package/dist/roap/turnDiscovery.js +3 -4
  35. package/dist/roap/turnDiscovery.js.map +1 -1
  36. package/dist/types/constants.d.ts +1 -0
  37. package/dist/types/meeting/index.d.ts +16 -2
  38. package/dist/types/meeting/locusMediaRequest.d.ts +1 -2
  39. package/dist/types/meeting/request.d.ts +2 -1
  40. package/dist/types/meeting/util.d.ts +9 -1
  41. package/dist/types/metrics/constants.d.ts +3 -0
  42. package/dist/types/multistream/remoteMediaManager.d.ts +9 -1
  43. package/dist/types/reachability/index.d.ts +0 -6
  44. package/dist/types/reachability/request.d.ts +1 -1
  45. package/dist/types/roap/request.d.ts +2 -1
  46. package/package.json +1 -1
  47. package/src/constants.ts +3 -2
  48. package/src/locus-info/index.ts +33 -2
  49. package/src/locus-info/parser.ts +7 -0
  50. package/src/meeting/index.ts +59 -16
  51. package/src/meeting/locusMediaRequest.ts +2 -3
  52. package/src/meeting/request.ts +16 -6
  53. package/src/meeting/util.ts +36 -2
  54. package/src/meetings/index.ts +2 -2
  55. package/src/metrics/constants.ts +3 -0
  56. package/src/multistream/remoteMediaManager.ts +41 -4
  57. package/src/reachability/index.ts +4 -10
  58. package/src/reachability/request.ts +1 -1
  59. package/src/reconnection-manager/index.ts +13 -11
  60. package/src/roap/index.ts +2 -4
  61. package/src/roap/request.ts +2 -1
  62. package/src/roap/turnDiscovery.ts +2 -3
  63. package/test/integration/spec/converged-space-meetings.js +7 -7
  64. package/test/integration/spec/journey.js +85 -103
  65. package/test/integration/spec/space-meeting.js +9 -9
  66. package/test/unit/spec/locus-info/index.js +118 -1
  67. package/test/unit/spec/meeting/index.js +95 -30
  68. package/test/unit/spec/meeting/locusMediaRequest.ts +1 -2
  69. package/test/unit/spec/meeting/request.js +23 -0
  70. package/test/unit/spec/meeting/utils.js +73 -4
  71. package/test/unit/spec/meetings/index.js +68 -3
  72. package/test/unit/spec/multistream/remoteMediaManager.ts +10 -2
  73. package/test/unit/spec/reachability/index.ts +8 -8
  74. package/test/unit/spec/reconnection-manager/index.js +21 -0
  75. package/test/unit/spec/roap/index.ts +5 -1
  76. package/test/unit/spec/roap/turnDiscovery.ts +11 -4
  77. package/test/utils/integrationTestUtils.js +4 -4
@@ -1 +1 @@
1
- {"version":3,"names":["MAX_OOO_DELTA_COUNT","OOO_DELTA_WAIT_TIME","OOO_DELTA_WAIT_TIME_RANDOM_DELAY","Parser","deltaCompareFunc","left","right","loci","LT","GT","extract","extractComparisonState","isSequenceEmpty","result","compareSequence","baseSequence","queue","SortedQueue","status","onDeltaAction","workingCopy","syncTimer","incomingFullDto","isLoci","LoggerProxy","logger","info","comparisonResult","compareFullDtoSequence","USE_INCOMING","newLoci","isValid","size","processDeltaEvent","action","locus","enqueue","triggerSync","reason","stopSyncTimer","pause","DESYNC","timeout","Math","random","setTimeout","clearTimeout","WAIT","dequeue","isValidLocus","nextEvent","compare","lociComparison","debug","needToWait","startSyncTimer","locus2string","sequence","entries","length","at","current","incoming","comparison","min","max","currentIsNotUnique","unique","incomingIsNotUnique","currentTotalRange","end","incomingTotalRange","EQ","currentIsUnique","incomingIsUnique","currentUniqueMin","incomingUniqueMin","currentHasNoRange","start","incomingHasNoRange","neitherSeqHasRange","hasUniqOverlap","list","some","seq","currentUniqOverlap","incomingUniqOverlap","debugInfo","pack","packComparisonResult","compareDelta","compareToAction","slice","USE_CURRENT","local","getMetaData","delta","getUniqueSequences","rules","checkSequenceOverlap","checkUnequalRanges","checkForUniqueEntries","checkIfOutOfSync","rule","ERROR","lociComparisonResult","split","first","last","rangeStart","rangeEnd","baseLoci","otherLoci","diff","getNumbersOutOfRange","output","filter","num","sort","a","b","hasEmptyEntries","hasEmptyRange","hasProp","prop","Object","prototype","hasOwnProperty","call","newData","oldData","debugCode","mStr","strings","join","replace","resolutionMap","debugMap","SO001","title","description","logic","SO002","UR001","UR002","UR003","UE001","UE002","OOS001","OOS002","OOS003","debugObj","resolution"],"sources":["parser.ts"],"sourcesContent":["import {difference} from 'lodash';\n\nimport SortedQueue from '../common/queue';\nimport LoggerProxy from '../common/logs/logger-proxy';\n\nconst MAX_OOO_DELTA_COUNT = 5; // when we receive an out-of-order delta and the queue builds up to MAX_OOO_DELTA_COUNT, we do a sync with Locus\nconst OOO_DELTA_WAIT_TIME = 10000; // [ms] minimum wait time before we do a sync if we get out-of-order deltas\nconst OOO_DELTA_WAIT_TIME_RANDOM_DELAY = 5000; // [ms] max random delay added to OOO_DELTA_WAIT_TIME\n\ntype LocusDeltaDto = {\n baseSequence: {\n rangeStart: number;\n rangeEnd: number;\n entries: number[];\n };\n sequence: {\n rangeStart: number;\n rangeEnd: number;\n entries: number[];\n };\n syncUrl: string;\n};\n\n/**\n * Locus Delta Parser\n * @private\n * https://sqbu-github.cisco.com/WebExSquared/cloud-apps/wiki/Locus-Delta-Events\n */\nexport default class Parser {\n // processing status\n status:\n | 'IDLE' // not doing anything\n | 'PAUSED' // paused, because we are doing a sync\n | 'WORKING' // processing a delta event\n | 'BLOCKED'; // received an out-of-order delta, so waiting for the missing one\n\n // loci comparison states\n static loci = {\n EQ: 'EQUAL',\n GT: 'GREATER_THAN',\n LT: 'LESS_THAN',\n DESYNC: 'DESYNC',\n USE_INCOMING: 'USE_INCOMING',\n USE_CURRENT: 'USE_CURRENT',\n WAIT: 'WAIT',\n ERROR: 'ERROR',\n };\n\n queue: SortedQueue<LocusDeltaDto>;\n workingCopy: any;\n syncTimer: null | number | NodeJS.Timeout;\n\n /**\n * @constructs Parser\n */\n constructor() {\n const deltaCompareFunc = (left: LocusDeltaDto, right: LocusDeltaDto) => {\n const {LT, GT} = Parser.loci;\n const {extractComparisonState: extract} = Parser;\n\n if (Parser.isSequenceEmpty(left)) {\n return -1;\n }\n if (Parser.isSequenceEmpty(right)) {\n return 1;\n }\n const result = extract(Parser.compareSequence(left.baseSequence, right.baseSequence));\n\n if (result === LT) {\n return -1;\n }\n if (result === GT) {\n return 1;\n }\n\n return 0;\n };\n\n this.queue = new SortedQueue<LocusDeltaDto>(deltaCompareFunc);\n this.status = 'IDLE';\n this.onDeltaAction = null;\n this.workingCopy = null;\n this.syncTimer = null;\n }\n\n /**\n * Returns a debug string representing a locus delta - useful for logging\n *\n * @param {LocusDeltaDto} locus Locus delta\n * @returns {string}\n */\n static locus2string(locus: LocusDeltaDto) {\n if (!locus.sequence?.entries) {\n return 'invalid';\n }\n\n return locus.sequence.entries.length ? `seq=${locus.sequence.entries.at(-1)}` : 'empty';\n }\n\n /**\n * Checks if two sequences overlap in time,\n * the sequence with the higher minimum value is greater.\n * Chooses sequence with most recent data.\n * @param {Types~Locus} current\n * @param {Types~Locus} incoming\n * @returns {string} loci comparison state\n */\n static checkSequenceOverlap(current, incoming) {\n let comparison = null;\n\n // if earliest working copy sequence is more recent than last incoming sequence\n if (current.min > incoming.max) {\n // choose left side (current)\n comparison = `${Parser.loci.GT}:SO001`;\n }\n // if last working copy sequence is before the earliest incoming sequence\n else if (current.max < incoming.min) {\n // choose right side (incoming)\n comparison = `${Parser.loci.LT}:SO002`;\n }\n\n // if no match above, defaults to null\n return comparison;\n }\n\n /**\n * Checks if two sequences have unequal ranges.\n * Chooses sequence with most larger range.\n * @param {Types~Locus} current\n * @param {Types~Locus} incoming\n * @returns {object} loci comparison\n */\n static checkUnequalRanges(current, incoming) {\n let comparison = null;\n const currentIsNotUnique = current.unique.length === 0;\n const incomingIsNotUnique = incoming.unique.length === 0;\n const currentTotalRange = current.end - current.min;\n const incomingTotalRange = incoming.end - incoming.min;\n\n // no unique values for both loci\n if (currentIsNotUnique && incomingIsNotUnique) {\n // current working copy loci has a larger range\n if (currentTotalRange > incomingTotalRange) {\n // choose left side (current)\n comparison = `${Parser.loci.GT}:UR001`;\n }\n // incoming delta loci has a larger range\n else if (currentTotalRange < incomingTotalRange) {\n // choose right side (incoming)\n comparison = `${Parser.loci.LT}:UR002`;\n } else {\n // with no unique entries and with ranges either absent or\n // of the same size, the sequences are considered equal.\n comparison = `${Parser.loci.EQ}:UR003`;\n }\n }\n\n return comparison;\n }\n\n /**\n * Checks if either sequences has unique entries.\n * Entries are considered unique if they do not overlap\n * with other Loci sequences or range values.\n * Chooses sequence with the unique entries.\n * @param {Types~Locus} current\n * @param {Types~Locus} incoming\n * @returns {string} loci comparison state\n */\n static checkForUniqueEntries(current, incoming) {\n let comparison = null;\n const currentIsUnique = current.unique.length > 0;\n const incomingIsUnique = incoming.unique.length > 0;\n\n // current has unique entries and incoming does not\n if (currentIsUnique && !incomingIsUnique) {\n // choose left side (current)\n comparison = `${Parser.loci.GT}:UE001`;\n }\n // current has no unique entries but incoming does\n else if (!currentIsUnique && incomingIsUnique) {\n // choose right side (incoming)\n comparison = `${Parser.loci.LT}:UE002`;\n }\n\n return comparison;\n }\n\n /**\n * Checks both Locus Delta objects to see if they are\n * out of sync with one another. If so sends a DESYNC\n * request to the server.\n * @param {Types~Locus} current\n * @param {Types~Locus} incoming\n * @returns {string} loci comparison state\n */\n static checkIfOutOfSync(current, incoming) {\n let comparison = null;\n const currentUniqueMin = current.unique[0];\n const incomingUniqueMin = incoming.unique[0];\n\n const currentHasNoRange = !current.start && !current.end;\n const incomingHasNoRange = !incoming.start && !incoming.end;\n const neitherSeqHasRange = currentHasNoRange && incomingHasNoRange;\n\n const hasUniqOverlap = (list, min, max) => list.some((seq) => min < seq && seq < max);\n // current unique entries overlap the total range of incoming\n const currentUniqOverlap = hasUniqOverlap(current.unique, incoming.min, incoming.max);\n // vice-versa, incoming unique entries overlap the total range of current\n const incomingUniqOverlap = hasUniqOverlap(incoming.unique, current.min, current.max);\n\n if (neitherSeqHasRange || currentUniqOverlap || incomingUniqOverlap) {\n // outputs string indicating which condition occurred. ex: 0,1,0\n const debugInfo = `${+neitherSeqHasRange},${+currentUniqOverlap},${+incomingUniqOverlap}`;\n\n // send DESYNC to server\n comparison = `${Parser.loci.DESYNC}:OOS001:${debugInfo}`;\n } else if (currentUniqueMin > incomingUniqueMin) {\n // choose left side (current)\n comparison = `${Parser.loci.GT}:OOS002`;\n } else {\n // choose right side (incoming)\n comparison = `${Parser.loci.LT}:OOS003`;\n }\n\n return comparison;\n }\n\n /**\n * Compares two loci to determine which one contains the most recent state\n * @instance\n * @memberof Locus\n * @param {Types~Locus} current\n * @param {Types~Locus} incoming\n * @returns {string} loci comparison state\n */\n static compare(current, incoming) {\n const {isSequenceEmpty} = Parser;\n const {extractComparisonState: extract} = Parser;\n const {packComparisonResult: pack} = Parser;\n\n if (isSequenceEmpty(current) || isSequenceEmpty(incoming)) {\n return pack(Parser.loci.USE_INCOMING, 'C001');\n }\n\n if (incoming.baseSequence) {\n return pack(Parser.compareDelta(current, incoming), 'C002');\n }\n\n const result = Parser.compareSequence(current.sequence, incoming.sequence);\n const action = Parser.compareToAction(extract(result));\n\n return pack(action, result);\n }\n\n /**\n * Compares two loci sequences (with delta params) and indicates what action\n * to take.\n * @instance\n * @memberof Locus\n * @param {Types~Locus} current\n * @param {Types~Locus} incoming\n * @private\n * @returns {string} loci comparison state\n */\n private static compareDelta(current, incoming) {\n const {LT, GT, EQ, DESYNC, USE_INCOMING, WAIT} = Parser.loci;\n\n const {extractComparisonState: extract} = Parser;\n const {packComparisonResult: pack} = Parser;\n\n const result = Parser.compareSequence(current.sequence, incoming.sequence);\n let comparison = extract(result);\n\n if (comparison !== LT) {\n return pack(Parser.compareToAction(comparison), result);\n }\n\n comparison = Parser.compareSequence(current.sequence, incoming.baseSequence);\n\n switch (extract(comparison)) {\n case GT:\n case EQ:\n comparison = USE_INCOMING;\n break;\n\n case LT:\n if (extract(Parser.compareSequence(incoming.baseSequence, incoming.sequence)) === EQ) {\n // special case where Locus sends a delta with baseSequence === sequence to trigger a sync,\n // because the delta event is too large to be sent over mercury connection\n comparison = DESYNC;\n } else {\n // the incoming locus has baseSequence from the future, so it is out-of-order,\n // we are missing 1 or more locus that should be in front of it, we need to wait for it\n comparison = WAIT;\n }\n break;\n default:\n comparison = DESYNC;\n }\n\n return pack(comparison, result);\n }\n\n /**\n * Compares Locus sequences - it should be called only for full Locus DTOs, not deltas\n *\n * @param {Types~Locus} current Current working copy\n * @param {Types~Locus} incomingFullDto New Full Locus DTO\n * @returns {string} either Parser.loci.USE_INCOMING or Parser.loci.USE_CURRENT\n */\n static compareFullDtoSequence(current, incomingFullDto) {\n if (Parser.isSequenceEmpty(current) || Parser.isSequenceEmpty(incomingFullDto)) {\n return Parser.loci.USE_INCOMING;\n }\n\n // the sequence.entries list will always contain at least 1 entry\n // https://sqbu-github.cisco.com/WebExSquared/cloud-apps/wiki/Locus-Sequence-Comparison-Algorithm\n\n return incomingFullDto.sequence.entries.slice(-1)[0] > current.sequence.entries.slice(-1)[0]\n ? Parser.loci.USE_INCOMING\n : Parser.loci.USE_CURRENT;\n }\n\n /**\n * Returns true if the incoming full locus DTO is newer than the current working copy\n *\n * @param {Types~Locus} incomingFullDto New Full Locus DTO\n * @returns {string} either Parser.loci.USE_INCOMING or Parser.loci.USE_CURRENT\n */\n isNewFullLocus(incomingFullDto) {\n if (!Parser.isLoci(incomingFullDto)) {\n LoggerProxy.logger.info('Locus-info:parser#isNewFullLocus --> Ignoring non-locus object.');\n\n return false;\n }\n\n if (!this.workingCopy) {\n // we don't have a working copy yet, so any full locus is better than nothing\n return true;\n }\n\n const comparisonResult = Parser.compareFullDtoSequence(this.workingCopy, incomingFullDto);\n\n return comparisonResult === Parser.loci.USE_INCOMING;\n }\n\n /**\n * Compares Locus sequences\n * @param {Types~Locus} current Current working copy\n * @param {Types~Locus} incoming New Locus delta\n * @returns {string}\n */\n static compareSequence(current, incoming) {\n // Locus sequence comparison rules in order of priority.\n // https://sqbu-github.cisco.com/WebExSquared/cloud-apps/wiki/Locus-Sequence-Comparison-Algorithm\n\n const local: any = Parser.getMetaData(current);\n const delta: any = Parser.getMetaData(incoming);\n\n // update loci metadata\n local.unique = Parser.getUniqueSequences(local, delta);\n delta.unique = Parser.getUniqueSequences(delta, local);\n\n // Locus sequence comparison rules\n // order matters\n const rules = [\n Parser.checkSequenceOverlap,\n Parser.checkUnequalRanges,\n Parser.checkForUniqueEntries,\n Parser.checkIfOutOfSync,\n ];\n\n for (const rule of rules) {\n // Rule only returns a value if the rule applies,\n // otherwise returns null.\n const result = rule(local, delta);\n\n if (result) {\n return result;\n }\n }\n\n // error, none of rules above applied\n // should never get here as last rule\n // should be catch all.\n return Parser.loci.ERROR;\n }\n\n /**\n * Transates the result of a sequence comparison into an intended behavior\n * @param {string} result\n * @returns {string} Locus comparison action\n */\n static compareToAction(result: string) {\n const {DESYNC, EQ, ERROR, GT, LT, USE_CURRENT, USE_INCOMING} = Parser.loci;\n\n let action = ERROR;\n\n switch (result) {\n case EQ:\n case GT:\n action = USE_CURRENT;\n break;\n case LT:\n action = USE_INCOMING;\n break;\n case DESYNC:\n action = DESYNC;\n break;\n default:\n LoggerProxy.logger.info(\n `Locus-info:parser#compareToAction --> Error: ${result} is not a recognized sequence comparison result.`\n );\n }\n\n return action;\n }\n\n /**\n * Extracts a loci comparison from a string of data.\n * @param {string} lociComparisonResult Comparison result with extra data\n * @returns {string} Comparison of EQ, LT, GT, or DESYNC.\n */\n static extractComparisonState(lociComparisonResult: string) {\n return lociComparisonResult.split(':')[0];\n }\n\n /**\n * @typedef {object} LociMetadata\n * @property {number} start - Starting sequence number\n * @property {number} end - Ending sequence number\n * @property {number} first - First sequence number\n * @property {number} last - Last sequence number\n * @property {number} min - Minimum sequence number\n * @property {number} max - Maximum sequence number\n * @property {number} entries - Loci sequence entries\n */\n\n /**\n * Metadata for Locus delta\n * @param {Array.<number>} sequence Locus delta sequence\n * @returns {LociMetadata} Locus Delta Metadata\n */\n static getMetaData(sequence: any) {\n const {entries} = sequence;\n const first = entries[0];\n const last = entries.slice(-1)[0];\n\n // rangeStart or rangeEnd is 0 if a range doesn't exist\n const start = sequence.rangeStart;\n const end = sequence.rangeEnd;\n\n // sequence data\n return {\n start,\n end,\n first,\n last,\n // Rule is: rangeStart <= rangeEnd <= min(entries)\n min: start || first,\n // Grab last entry if exist else default to rangeEnd\n max: last || end,\n // keep reference to actual sequence entries\n entries,\n };\n }\n\n /**\n * Compares two Locus delta objects and notes unique\n * values contained within baseLoci.\n * @param {LociMetadata} baseLoci\n * @param {LociMetadata} otherLoci\n * @returns {Array.<number>} List of unique sequences\n */\n static getUniqueSequences(baseLoci: any, otherLoci: any) {\n const diff: any = difference(baseLoci.entries, otherLoci.entries);\n\n const {start, end} = otherLoci;\n\n return Parser.getNumbersOutOfRange(diff, start, end);\n }\n\n /**\n * Returns an array of numbers outside of a given range.\n * @param {Array.<number>} list Array to filter\n * @param {number} rangeStart Start of range\n * @param {number} rangeEnd End of range\n * @returns {Array.<number>} Array of numbers sorted ASC\n */\n static getNumbersOutOfRange(list: Array<number>, rangeStart: number, rangeEnd: number) {\n // Collect all numbers if number is outside of specified range\n const output = list.filter((num) => num < rangeStart || num > rangeEnd);\n\n // sort ascending\n return output.sort((a, b) => a - b);\n }\n\n /**\n * Checks if newLoci or workingCopy is invalid.\n * @param {Types~Locus} newLoci\n * @returns {boolean}\n */\n isValidLocus(newLoci) {\n let isValid = false;\n const {isLoci} = Parser;\n\n // one or both objects are not locus delta events\n if (!isLoci(this.workingCopy) || !isLoci(newLoci)) {\n LoggerProxy.logger.info(\n 'Locus-info:parser#processDeltaEvent --> Ignoring non-locus object. workingCopy:',\n this.workingCopy,\n 'newLoci:',\n newLoci\n );\n } else {\n isValid = true;\n }\n\n return isValid;\n }\n\n /**\n * Determines if a paricular locus's sequence is empty\n * @param {Types~Locus} locus\n * @returns {bool}\n */\n static isSequenceEmpty(locus) {\n const {sequence} = locus;\n const hasEmptyEntries = !sequence.entries?.length;\n const hasEmptyRange = sequence.rangeStart === 0 && sequence.rangeEnd === 0;\n\n return hasEmptyEntries && hasEmptyRange;\n }\n\n /**\n * Determines if an object has basic\n * structure of a locus object.\n * @param {Types~Locus} loci\n * @returns {boolean}\n */\n static isLoci(loci) {\n if (!loci || !loci.sequence) {\n return false;\n }\n const hasProp = (prop) => Object.prototype.hasOwnProperty.call(loci.sequence, prop);\n\n if (hasProp('rangeStart') && hasProp('rangeEnd')) {\n return true;\n }\n\n return false;\n }\n\n /**\n * Processes next event in queue,\n * if queue is empty sets status to idle.\n * @returns {undefined}\n */\n nextEvent() {\n if (this.status === 'PAUSED') {\n LoggerProxy.logger.info('Locus-info:parser#nextEvent --> Locus parser paused.');\n\n return;\n }\n\n if (this.status === 'BLOCKED') {\n LoggerProxy.logger.info(\n 'Locus-info:parser#nextEvent --> Locus parser blocked by out-of-order delta.'\n );\n\n return;\n }\n\n // continue processing until queue is empty\n if (this.queue.size() > 0) {\n this.processDeltaEvent();\n } else {\n this.status = 'IDLE';\n }\n }\n\n /**\n * Function handler for delta actions,\n * is set by instance callee.\n * @param {string} action Locus delta action\n * @param {Types~Locus} locus Locus delta\n * @returns {undefined}\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n onDeltaAction(action: string, locus) {}\n\n /**\n * Event handler for locus delta events\n * @param {Types~Locus} loci Locus Delta\n * @returns {undefined}\n */\n onDeltaEvent(loci) {\n // enqueue the new loci\n this.queue.enqueue(loci);\n\n if (this.onDeltaAction) {\n if (this.status === 'BLOCKED') {\n if (this.queue.size() > MAX_OOO_DELTA_COUNT) {\n this.triggerSync('queue too big, blocked on out-of-order delta');\n } else {\n this.processDeltaEvent();\n }\n } else if (this.status === 'IDLE') {\n // Update status, ensure we only process one event at a time.\n this.status = 'WORKING';\n\n this.processDeltaEvent();\n }\n }\n }\n\n /**\n * Appends new data onto a string of existing data.\n * @param {string} newData\n * @param {string} oldData\n * @returns {string}\n */\n static packComparisonResult(newData: string, oldData: string) {\n return `${newData}:${oldData}`;\n }\n\n /**\n * Pause locus processing\n * @returns {undefined}\n */\n pause() {\n this.status = 'PAUSED';\n LoggerProxy.logger.info('Locus-info:parser#pause --> Locus parser paused.');\n }\n\n /**\n * Triggers a sync with Locus\n *\n * @param {string} reason used just for logging\n * @returns {undefined}\n */\n private triggerSync(reason: string) {\n LoggerProxy.logger.info(`Locus-info:parser#triggerSync --> doing sync, reason: ${reason}`);\n this.stopSyncTimer();\n this.pause();\n this.onDeltaAction(Parser.loci.DESYNC, this.workingCopy);\n }\n\n /**\n * Starts a timer with a random delay. When that timer expires we will do a sync.\n *\n * The main purpose of this timer is to handle a case when we get some out-of-order deltas,\n * so we start waiting to receive the missing delta. If that delta never arrives, this timer\n * will trigger a sync with Locus.\n *\n * @returns {undefined}\n */\n private startSyncTimer() {\n if (this.syncTimer === null) {\n const timeout = OOO_DELTA_WAIT_TIME + Math.random() * OOO_DELTA_WAIT_TIME_RANDOM_DELAY;\n\n this.syncTimer = setTimeout(() => {\n this.syncTimer = null;\n this.triggerSync('timer expired, blocked on out-of-order delta');\n }, timeout);\n }\n }\n\n /**\n * Stops the timer for triggering a sync\n *\n * @returns {undefined}\n */\n private stopSyncTimer() {\n if (this.syncTimer !== null) {\n clearTimeout(this.syncTimer);\n this.syncTimer = null;\n }\n }\n\n /**\n * Processes next locus delta in the queue,\n * continues until the queue is empty\n * or cleared.\n * @returns {undefined}\n */\n processDeltaEvent() {\n const {DESYNC, USE_INCOMING, WAIT} = Parser.loci;\n const {extractComparisonState: extract} = Parser;\n const newLoci = this.queue.dequeue();\n\n if (!this.isValidLocus(newLoci)) {\n this.nextEvent();\n\n return;\n }\n\n const result = Parser.compare(this.workingCopy, newLoci);\n const lociComparison = extract(result);\n\n // limited debugging, use chrome extension\n // for full debugging.\n LoggerProxy.logger.debug(`Locus-info:parser#processDeltaEvent --> Locus Debug: ${result}`);\n\n let needToWait = false;\n\n if (lociComparison === DESYNC) {\n // wait for desync response\n this.pause();\n } else if (lociComparison === USE_INCOMING) {\n // update working copy for future comparisons.\n // Note: The working copy of parser gets updated in .onFullLocus()\n // and here when USE_INCOMING locus.\n this.workingCopy = newLoci;\n } else if (lociComparison === WAIT) {\n // we've taken newLoci from the front of the queue, so put it back there as we have to wait\n // for the one that should be in front of it, before we can process it\n this.queue.enqueue(newLoci);\n needToWait = true;\n }\n\n if (needToWait) {\n this.status = 'BLOCKED';\n this.startSyncTimer();\n } else {\n this.stopSyncTimer();\n\n if (this.status === 'BLOCKED') {\n // we are not blocked anymore\n this.status = 'WORKING';\n\n LoggerProxy.logger.info(\n `Locus-info:parser#processDeltaEvent --> received delta that we were waiting for ${Parser.locus2string(\n newLoci\n )}, not blocked anymore`\n );\n }\n }\n\n if (this.onDeltaAction) {\n LoggerProxy.logger.info(\n `Locus-info:parser#processDeltaEvent --> Locus Delta ${Parser.locus2string(\n newLoci\n )}, Action: ${lociComparison}`\n );\n\n this.onDeltaAction(lociComparison, newLoci);\n }\n\n this.nextEvent();\n }\n\n /**\n * Resume from a paused state\n * @returns {undefined}\n */\n resume() {\n LoggerProxy.logger.info('Locus-info:parser#resume --> Locus parser resumed.');\n this.status = 'WORKING';\n this.nextEvent();\n }\n\n /**\n * Gets related debug info for given error code\n * @param {string} debugCode Debug code\n * @param {string} comparison Locus comparison string\n * @returns {object} Debug message\n */\n static getDebugMessage(debugCode: string, comparison: string) {\n // removes extra spaces from multiline string\n const mStr = (strings) => strings.join('').replace(/\\s{2,}/g, ' ');\n\n const resolutionMap = {\n EQ: `${Parser.loci.LT}: is equal (current == incoming).`,\n LT: `${Parser.loci.LT}: choose right side (incoming).`,\n GT: `${Parser.loci.GT}: choose left side (current).`,\n };\n\n const debugMap = {\n SO001: {\n title: 'checkSequenceOverlap-001',\n description: mStr`Occurs if earliest working copy sequence is more \\\n recent than last incoming sequence.`,\n logic: 'current.min > incoming.max',\n },\n\n SO002: {\n title: 'checkSequenceOverlap-002',\n description: mStr`Occurs if last working copy sequence is before the \\\n earliest incoming sequence.`,\n logic: 'current.max < incoming.min',\n },\n\n UR001: {\n title: 'checkUnequalRanges-001',\n description: mStr`Occurs if there are no unique values for both loci, \\\n and the current working copy loci has a larger range.`,\n logic: 'currentTotalRange > incomingTotalRange',\n },\n\n UR002: {\n title: 'checkUnequalRanges-002',\n description: mStr`Occurs if there are no unique values for both loci, \\\n and the incoming delta loci has a larger range.`,\n logic: 'currentTotalRange < incomingTotalRange',\n },\n\n UR003: {\n title: 'checkUnequalRanges-003',\n description: mStr`Occurs if there are no unique values for both loci, \\\n and with ranges either absent or of the same size, the sequences \\\n are considered equal.`,\n logic: 'currentTotalRange == incomingTotalRange',\n },\n\n UE001: {\n title: 'checkForUniqueEntries-001',\n description: mStr`Occurs if current loci has unique entries and \\\n incoming does not. Entries are considered unique if they \\\n do not overlap with other Loci sequences or range values.`,\n logic: 'currentIsUnique && !incomingIsUnique',\n },\n\n UE002: {\n title: 'checkForUniqueEntries-002',\n description: mStr`Occurs if current has no unique entries but \\\n incoming does. Entries are considered unique if they \\\n do not overlap with other Loci sequences or range values.`,\n logic: '!currentIsUnique && incomingIsUnique',\n },\n\n OOS001: {\n title: 'checkIfOutOfSync-001',\n description: mStr`Occurs if neither sequence has a range, or \\\n if the current loci unique entries overlap the total range of the \\\n incoming sequence, or if the incoming unique entries overlap \\\n the total range of current sequence.`,\n logic: 'neitherSeqHasRange || currentUniqOverlap || incomingUniqOverlap',\n },\n\n OOS002: {\n title: 'checkIfOutOfSync-002',\n description: mStr`Occurs if the minimum value from sequences that are \\\n unique to the current loci is greater than the minimum value from \\\n sequences that are unique to the incoming loci.`,\n logic: 'currentUniqueMin > incomingUniqueMin',\n },\n\n OOS003: {\n title: 'checkIfOutOfSync-003',\n description: mStr`Occurs if none of the comparison rules applied. \\\n It is a catch all.`,\n logic: 'else (catch all)',\n },\n };\n\n const debugObj = debugMap[debugCode];\n\n debugObj.title = `Debug: ${debugObj.title}`;\n debugObj.resolution = resolutionMap[comparison];\n\n return debugObj;\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAEA;AACA;AAAsD;AAEtD,IAAMA,mBAAmB,GAAG,CAAC,CAAC,CAAC;AAC/B,IAAMC,mBAAmB,GAAG,KAAK,CAAC,CAAC;AACnC,IAAMC,gCAAgC,GAAG,IAAI,CAAC,CAAC;AAgB/C;AACA;AACA;AACA;AACA;AAJA,IAKqBC,MAAM;EACzB;;EAKe;;EAEf;;EAgBA;AACF;AACA;EACE,kBAAc;IAAA;IAAA;IAAA;IAAA;IAAA;IACZ,IAAMC,gBAAgB,GAAG,SAAnBA,gBAAgB,CAAIC,IAAmB,EAAEC,KAAoB,EAAK;MACtE,mBAAiBH,MAAM,CAACI,IAAI;QAArBC,EAAE,gBAAFA,EAAE;QAAEC,EAAE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CAAC;QAEDS,MAAM,EAAE;UACNX,KAAK,EAAE,sBAAsB;UAC7BC,WAAW,EAAER,IAAI,yPACI;UACrBS,KAAK,EAAE;QACT;MACF,CAAC;MAED,IAAMU,QAAQ,GAAGd,QAAQ,CAACN,SAAS,CAAC;MAEpCoB,QAAQ,CAACZ,KAAK,oBAAaY,QAAQ,CAACZ,KAAK,CAAE;MAC3CY,QAAQ,CAACC,UAAU,GAAGhB,aAAa,CAACzE,UAAU,CAAC;MAE/C,OAAOwF,QAAQ;IACjB;EAAC;EAAA;AAAA;AAAA;AAAA,8BAn0BkBpJ,MAAM,UASX;EACZqE,EAAE,EAAE,OAAO;EACX/D,EAAE,EAAE,cAAc;EAClBD,EAAE,EAAE,WAAW;EACfiC,MAAM,EAAE,QAAQ;EAChBZ,YAAY,EAAE,cAAc;EAC5BgE,WAAW,EAAE,aAAa;EAC1B9C,IAAI,EAAE,MAAM;EACZyD,KAAK,EAAE;AACT,CAAC"}
1
+ {"version":3,"names":["MAX_OOO_DELTA_COUNT","OOO_DELTA_WAIT_TIME","OOO_DELTA_WAIT_TIME_RANDOM_DELAY","Parser","deltaCompareFunc","left","right","loci","LT","GT","extract","extractComparisonState","isSequenceEmpty","result","compareSequence","baseSequence","queue","SortedQueue","status","onDeltaAction","workingCopy","syncTimer","incomingFullDto","isLoci","LoggerProxy","logger","info","comparisonResult","compareFullDtoSequence","USE_INCOMING","newLoci","isValid","size","processDeltaEvent","action","locus","enqueue","triggerSync","reason","stopSyncTimer","pause","DESYNC","timeout","Math","random","setTimeout","clearTimeout","WAIT","dequeue","isValidLocus","nextEvent","compare","lociComparison","debug","needToWait","startSyncTimer","locus2string","sequence","entries","length","at","current","incoming","comparison","min","max","currentIsNotUnique","unique","incomingIsNotUnique","currentTotalRange","end","incomingTotalRange","EQ","currentIsUnique","incomingIsUnique","currentUniqueMin","incomingUniqueMin","currentHasNoRange","start","incomingHasNoRange","neitherSeqHasRange","hasUniqOverlap","list","some","seq","currentUniqOverlap","incomingUniqOverlap","debugInfo","pack","packComparisonResult","compareDelta","compareToAction","Metrics","sendBehavioralMetric","BEHAVIORAL_METRICS","LOCUS_DELTA_OUT_OF_ORDER","stack","Error","slice","USE_CURRENT","local","getMetaData","delta","getUniqueSequences","rules","checkSequenceOverlap","checkUnequalRanges","checkForUniqueEntries","checkIfOutOfSync","rule","ERROR","lociComparisonResult","split","first","last","rangeStart","rangeEnd","baseLoci","otherLoci","diff","getNumbersOutOfRange","output","filter","num","sort","a","b","hasEmptyEntries","hasEmptyRange","hasProp","prop","Object","prototype","hasOwnProperty","call","newData","oldData","debugCode","mStr","strings","join","replace","resolutionMap","debugMap","SO001","title","description","logic","SO002","UR001","UR002","UR003","UE001","UE002","OOS001","OOS002","OOS003","debugObj","resolution"],"sources":["parser.ts"],"sourcesContent":["import {difference} from 'lodash';\n\nimport SortedQueue from '../common/queue';\nimport LoggerProxy from '../common/logs/logger-proxy';\n\nimport Metrics from '../metrics';\nimport BEHAVIORAL_METRICS from '../metrics/constants';\n\nconst MAX_OOO_DELTA_COUNT = 5; // when we receive an out-of-order delta and the queue builds up to MAX_OOO_DELTA_COUNT, we do a sync with Locus\nconst OOO_DELTA_WAIT_TIME = 10000; // [ms] minimum wait time before we do a sync if we get out-of-order deltas\nconst OOO_DELTA_WAIT_TIME_RANDOM_DELAY = 5000; // [ms] max random delay added to OOO_DELTA_WAIT_TIME\n\ntype LocusDeltaDto = {\n baseSequence: {\n rangeStart: number;\n rangeEnd: number;\n entries: number[];\n };\n sequence: {\n rangeStart: number;\n rangeEnd: number;\n entries: number[];\n };\n syncUrl: string;\n};\n\n/**\n * Locus Delta Parser\n * @private\n * https://sqbu-github.cisco.com/WebExSquared/cloud-apps/wiki/Locus-Delta-Events\n */\nexport default class Parser {\n // processing status\n status:\n | 'IDLE' // not doing anything\n | 'PAUSED' // paused, because we are doing a sync\n | 'WORKING' // processing a delta event\n | 'BLOCKED'; // received an out-of-order delta, so waiting for the missing one\n\n // loci comparison states\n static loci = {\n EQ: 'EQUAL',\n GT: 'GREATER_THAN',\n LT: 'LESS_THAN',\n DESYNC: 'DESYNC',\n USE_INCOMING: 'USE_INCOMING',\n USE_CURRENT: 'USE_CURRENT',\n WAIT: 'WAIT',\n ERROR: 'ERROR',\n };\n\n queue: SortedQueue<LocusDeltaDto>;\n workingCopy: any;\n syncTimer: null | number | NodeJS.Timeout;\n\n /**\n * @constructs Parser\n */\n constructor() {\n const deltaCompareFunc = (left: LocusDeltaDto, right: LocusDeltaDto) => {\n const {LT, GT} = Parser.loci;\n const {extractComparisonState: extract} = Parser;\n\n if (Parser.isSequenceEmpty(left)) {\n return -1;\n }\n if (Parser.isSequenceEmpty(right)) {\n return 1;\n }\n const result = extract(Parser.compareSequence(left.baseSequence, right.baseSequence));\n\n if (result === LT) {\n return -1;\n }\n if (result === GT) {\n return 1;\n }\n\n return 0;\n };\n\n this.queue = new SortedQueue<LocusDeltaDto>(deltaCompareFunc);\n this.status = 'IDLE';\n this.onDeltaAction = null;\n this.workingCopy = null;\n this.syncTimer = null;\n }\n\n /**\n * Returns a debug string representing a locus delta - useful for logging\n *\n * @param {LocusDeltaDto} locus Locus delta\n * @returns {string}\n */\n static locus2string(locus: LocusDeltaDto) {\n if (!locus.sequence?.entries) {\n return 'invalid';\n }\n\n return locus.sequence.entries.length ? `seq=${locus.sequence.entries.at(-1)}` : 'empty';\n }\n\n /**\n * Checks if two sequences overlap in time,\n * the sequence with the higher minimum value is greater.\n * Chooses sequence with most recent data.\n * @param {Types~Locus} current\n * @param {Types~Locus} incoming\n * @returns {string} loci comparison state\n */\n static checkSequenceOverlap(current, incoming) {\n let comparison = null;\n\n // if earliest working copy sequence is more recent than last incoming sequence\n if (current.min > incoming.max) {\n // choose left side (current)\n comparison = `${Parser.loci.GT}:SO001`;\n }\n // if last working copy sequence is before the earliest incoming sequence\n else if (current.max < incoming.min) {\n // choose right side (incoming)\n comparison = `${Parser.loci.LT}:SO002`;\n }\n\n // if no match above, defaults to null\n return comparison;\n }\n\n /**\n * Checks if two sequences have unequal ranges.\n * Chooses sequence with most larger range.\n * @param {Types~Locus} current\n * @param {Types~Locus} incoming\n * @returns {object} loci comparison\n */\n static checkUnequalRanges(current, incoming) {\n let comparison = null;\n const currentIsNotUnique = current.unique.length === 0;\n const incomingIsNotUnique = incoming.unique.length === 0;\n const currentTotalRange = current.end - current.min;\n const incomingTotalRange = incoming.end - incoming.min;\n\n // no unique values for both loci\n if (currentIsNotUnique && incomingIsNotUnique) {\n // current working copy loci has a larger range\n if (currentTotalRange > incomingTotalRange) {\n // choose left side (current)\n comparison = `${Parser.loci.GT}:UR001`;\n }\n // incoming delta loci has a larger range\n else if (currentTotalRange < incomingTotalRange) {\n // choose right side (incoming)\n comparison = `${Parser.loci.LT}:UR002`;\n } else {\n // with no unique entries and with ranges either absent or\n // of the same size, the sequences are considered equal.\n comparison = `${Parser.loci.EQ}:UR003`;\n }\n }\n\n return comparison;\n }\n\n /**\n * Checks if either sequences has unique entries.\n * Entries are considered unique if they do not overlap\n * with other Loci sequences or range values.\n * Chooses sequence with the unique entries.\n * @param {Types~Locus} current\n * @param {Types~Locus} incoming\n * @returns {string} loci comparison state\n */\n static checkForUniqueEntries(current, incoming) {\n let comparison = null;\n const currentIsUnique = current.unique.length > 0;\n const incomingIsUnique = incoming.unique.length > 0;\n\n // current has unique entries and incoming does not\n if (currentIsUnique && !incomingIsUnique) {\n // choose left side (current)\n comparison = `${Parser.loci.GT}:UE001`;\n }\n // current has no unique entries but incoming does\n else if (!currentIsUnique && incomingIsUnique) {\n // choose right side (incoming)\n comparison = `${Parser.loci.LT}:UE002`;\n }\n\n return comparison;\n }\n\n /**\n * Checks both Locus Delta objects to see if they are\n * out of sync with one another. If so sends a DESYNC\n * request to the server.\n * @param {Types~Locus} current\n * @param {Types~Locus} incoming\n * @returns {string} loci comparison state\n */\n static checkIfOutOfSync(current, incoming) {\n let comparison = null;\n const currentUniqueMin = current.unique[0];\n const incomingUniqueMin = incoming.unique[0];\n\n const currentHasNoRange = !current.start && !current.end;\n const incomingHasNoRange = !incoming.start && !incoming.end;\n const neitherSeqHasRange = currentHasNoRange && incomingHasNoRange;\n\n const hasUniqOverlap = (list, min, max) => list.some((seq) => min < seq && seq < max);\n // current unique entries overlap the total range of incoming\n const currentUniqOverlap = hasUniqOverlap(current.unique, incoming.min, incoming.max);\n // vice-versa, incoming unique entries overlap the total range of current\n const incomingUniqOverlap = hasUniqOverlap(incoming.unique, current.min, current.max);\n\n if (neitherSeqHasRange || currentUniqOverlap || incomingUniqOverlap) {\n // outputs string indicating which condition occurred. ex: 0,1,0\n const debugInfo = `${+neitherSeqHasRange},${+currentUniqOverlap},${+incomingUniqOverlap}`;\n\n // send DESYNC to server\n comparison = `${Parser.loci.DESYNC}:OOS001:${debugInfo}`;\n } else if (currentUniqueMin > incomingUniqueMin) {\n // choose left side (current)\n comparison = `${Parser.loci.GT}:OOS002`;\n } else {\n // choose right side (incoming)\n comparison = `${Parser.loci.LT}:OOS003`;\n }\n\n return comparison;\n }\n\n /**\n * Compares two loci to determine which one contains the most recent state\n * @instance\n * @memberof Locus\n * @param {Types~Locus} current\n * @param {Types~Locus} incoming\n * @returns {string} loci comparison state\n */\n static compare(current, incoming) {\n const {isSequenceEmpty} = Parser;\n const {extractComparisonState: extract} = Parser;\n const {packComparisonResult: pack} = Parser;\n\n if (isSequenceEmpty(current) || isSequenceEmpty(incoming)) {\n return pack(Parser.loci.USE_INCOMING, 'C001');\n }\n\n if (incoming.baseSequence) {\n return pack(Parser.compareDelta(current, incoming), 'C002');\n }\n\n const result = Parser.compareSequence(current.sequence, incoming.sequence);\n const action = Parser.compareToAction(extract(result));\n\n return pack(action, result);\n }\n\n /**\n * Compares two loci sequences (with delta params) and indicates what action\n * to take.\n * @instance\n * @memberof Locus\n * @param {Types~Locus} current\n * @param {Types~Locus} incoming\n * @private\n * @returns {string} loci comparison state\n */\n private static compareDelta(current, incoming) {\n const {LT, GT, EQ, DESYNC, USE_INCOMING, WAIT} = Parser.loci;\n\n const {extractComparisonState: extract} = Parser;\n const {packComparisonResult: pack} = Parser;\n\n const result = Parser.compareSequence(current.sequence, incoming.sequence);\n let comparison = extract(result);\n\n if (comparison !== LT) {\n return pack(Parser.compareToAction(comparison), result);\n }\n\n comparison = Parser.compareSequence(current.sequence, incoming.baseSequence);\n\n switch (extract(comparison)) {\n case GT:\n case EQ:\n comparison = USE_INCOMING;\n break;\n\n case LT:\n if (extract(Parser.compareSequence(incoming.baseSequence, incoming.sequence)) === EQ) {\n // special case where Locus sends a delta with baseSequence === sequence to trigger a sync,\n // because the delta event is too large to be sent over mercury connection\n comparison = DESYNC;\n } else {\n // the incoming locus has baseSequence from the future, so it is out-of-order,\n // we are missing 1 or more locus that should be in front of it, we need to wait for it\n comparison = WAIT;\n\n Metrics.sendBehavioralMetric(BEHAVIORAL_METRICS.LOCUS_DELTA_OUT_OF_ORDER, {\n stack: new Error().stack,\n });\n }\n break;\n default:\n comparison = DESYNC;\n }\n\n return pack(comparison, result);\n }\n\n /**\n * Compares Locus sequences - it should be called only for full Locus DTOs, not deltas\n *\n * @param {Types~Locus} current Current working copy\n * @param {Types~Locus} incomingFullDto New Full Locus DTO\n * @returns {string} either Parser.loci.USE_INCOMING or Parser.loci.USE_CURRENT\n */\n static compareFullDtoSequence(current, incomingFullDto) {\n if (Parser.isSequenceEmpty(current) || Parser.isSequenceEmpty(incomingFullDto)) {\n return Parser.loci.USE_INCOMING;\n }\n\n // the sequence.entries list will always contain at least 1 entry\n // https://sqbu-github.cisco.com/WebExSquared/cloud-apps/wiki/Locus-Sequence-Comparison-Algorithm\n\n return incomingFullDto.sequence.entries.slice(-1)[0] > current.sequence.entries.slice(-1)[0]\n ? Parser.loci.USE_INCOMING\n : Parser.loci.USE_CURRENT;\n }\n\n /**\n * Returns true if the incoming full locus DTO is newer than the current working copy\n *\n * @param {Types~Locus} incomingFullDto New Full Locus DTO\n * @returns {string} either Parser.loci.USE_INCOMING or Parser.loci.USE_CURRENT\n */\n isNewFullLocus(incomingFullDto) {\n if (!Parser.isLoci(incomingFullDto)) {\n LoggerProxy.logger.info('Locus-info:parser#isNewFullLocus --> Ignoring non-locus object.');\n\n return false;\n }\n\n if (!this.workingCopy) {\n // we don't have a working copy yet, so any full locus is better than nothing\n return true;\n }\n\n const comparisonResult = Parser.compareFullDtoSequence(this.workingCopy, incomingFullDto);\n\n return comparisonResult === Parser.loci.USE_INCOMING;\n }\n\n /**\n * Compares Locus sequences\n * @param {Types~Locus} current Current working copy\n * @param {Types~Locus} incoming New Locus delta\n * @returns {string}\n */\n static compareSequence(current, incoming) {\n // Locus sequence comparison rules in order of priority.\n // https://sqbu-github.cisco.com/WebExSquared/cloud-apps/wiki/Locus-Sequence-Comparison-Algorithm\n\n const local: any = Parser.getMetaData(current);\n const delta: any = Parser.getMetaData(incoming);\n\n // update loci metadata\n local.unique = Parser.getUniqueSequences(local, delta);\n delta.unique = Parser.getUniqueSequences(delta, local);\n\n // Locus sequence comparison rules\n // order matters\n const rules = [\n Parser.checkSequenceOverlap,\n Parser.checkUnequalRanges,\n Parser.checkForUniqueEntries,\n Parser.checkIfOutOfSync,\n ];\n\n for (const rule of rules) {\n // Rule only returns a value if the rule applies,\n // otherwise returns null.\n const result = rule(local, delta);\n\n if (result) {\n return result;\n }\n }\n\n // error, none of rules above applied\n // should never get here as last rule\n // should be catch all.\n return Parser.loci.ERROR;\n }\n\n /**\n * Transates the result of a sequence comparison into an intended behavior\n * @param {string} result\n * @returns {string} Locus comparison action\n */\n static compareToAction(result: string) {\n const {DESYNC, EQ, ERROR, GT, LT, USE_CURRENT, USE_INCOMING} = Parser.loci;\n\n let action = ERROR;\n\n switch (result) {\n case EQ:\n case GT:\n action = USE_CURRENT;\n break;\n case LT:\n action = USE_INCOMING;\n break;\n case DESYNC:\n action = DESYNC;\n break;\n default:\n LoggerProxy.logger.info(\n `Locus-info:parser#compareToAction --> Error: ${result} is not a recognized sequence comparison result.`\n );\n }\n\n return action;\n }\n\n /**\n * Extracts a loci comparison from a string of data.\n * @param {string} lociComparisonResult Comparison result with extra data\n * @returns {string} Comparison of EQ, LT, GT, or DESYNC.\n */\n static extractComparisonState(lociComparisonResult: string) {\n return lociComparisonResult.split(':')[0];\n }\n\n /**\n * @typedef {object} LociMetadata\n * @property {number} start - Starting sequence number\n * @property {number} end - Ending sequence number\n * @property {number} first - First sequence number\n * @property {number} last - Last sequence number\n * @property {number} min - Minimum sequence number\n * @property {number} max - Maximum sequence number\n * @property {number} entries - Loci sequence entries\n */\n\n /**\n * Metadata for Locus delta\n * @param {Array.<number>} sequence Locus delta sequence\n * @returns {LociMetadata} Locus Delta Metadata\n */\n static getMetaData(sequence: any) {\n const {entries} = sequence;\n const first = entries[0];\n const last = entries.slice(-1)[0];\n\n // rangeStart or rangeEnd is 0 if a range doesn't exist\n const start = sequence.rangeStart;\n const end = sequence.rangeEnd;\n\n // sequence data\n return {\n start,\n end,\n first,\n last,\n // Rule is: rangeStart <= rangeEnd <= min(entries)\n min: start || first,\n // Grab last entry if exist else default to rangeEnd\n max: last || end,\n // keep reference to actual sequence entries\n entries,\n };\n }\n\n /**\n * Compares two Locus delta objects and notes unique\n * values contained within baseLoci.\n * @param {LociMetadata} baseLoci\n * @param {LociMetadata} otherLoci\n * @returns {Array.<number>} List of unique sequences\n */\n static getUniqueSequences(baseLoci: any, otherLoci: any) {\n const diff: any = difference(baseLoci.entries, otherLoci.entries);\n\n const {start, end} = otherLoci;\n\n return Parser.getNumbersOutOfRange(diff, start, end);\n }\n\n /**\n * Returns an array of numbers outside of a given range.\n * @param {Array.<number>} list Array to filter\n * @param {number} rangeStart Start of range\n * @param {number} rangeEnd End of range\n * @returns {Array.<number>} Array of numbers sorted ASC\n */\n static getNumbersOutOfRange(list: Array<number>, rangeStart: number, rangeEnd: number) {\n // Collect all numbers if number is outside of specified range\n const output = list.filter((num) => num < rangeStart || num > rangeEnd);\n\n // sort ascending\n return output.sort((a, b) => a - b);\n }\n\n /**\n * Checks if newLoci or workingCopy is invalid.\n * @param {Types~Locus} newLoci\n * @returns {boolean}\n */\n isValidLocus(newLoci) {\n let isValid = false;\n const {isLoci} = Parser;\n\n // one or both objects are not locus delta events\n if (!isLoci(this.workingCopy) || !isLoci(newLoci)) {\n LoggerProxy.logger.info(\n 'Locus-info:parser#processDeltaEvent --> Ignoring non-locus object. workingCopy:',\n this.workingCopy,\n 'newLoci:',\n newLoci\n );\n } else {\n isValid = true;\n }\n\n return isValid;\n }\n\n /**\n * Determines if a paricular locus's sequence is empty\n * @param {Types~Locus} locus\n * @returns {bool}\n */\n static isSequenceEmpty(locus) {\n const {sequence} = locus;\n const hasEmptyEntries = !sequence.entries?.length;\n const hasEmptyRange = sequence.rangeStart === 0 && sequence.rangeEnd === 0;\n\n return hasEmptyEntries && hasEmptyRange;\n }\n\n /**\n * Determines if an object has basic\n * structure of a locus object.\n * @param {Types~Locus} loci\n * @returns {boolean}\n */\n static isLoci(loci) {\n if (!loci || !loci.sequence) {\n return false;\n }\n const hasProp = (prop) => Object.prototype.hasOwnProperty.call(loci.sequence, prop);\n\n if (hasProp('rangeStart') && hasProp('rangeEnd')) {\n return true;\n }\n\n return false;\n }\n\n /**\n * Processes next event in queue,\n * if queue is empty sets status to idle.\n * @returns {undefined}\n */\n nextEvent() {\n if (this.status === 'PAUSED') {\n LoggerProxy.logger.info('Locus-info:parser#nextEvent --> Locus parser paused.');\n\n return;\n }\n\n if (this.status === 'BLOCKED') {\n LoggerProxy.logger.info(\n 'Locus-info:parser#nextEvent --> Locus parser blocked by out-of-order delta.'\n );\n\n return;\n }\n\n // continue processing until queue is empty\n if (this.queue.size() > 0) {\n this.processDeltaEvent();\n } else {\n this.status = 'IDLE';\n }\n }\n\n /**\n * Function handler for delta actions,\n * is set by instance callee.\n * @param {string} action Locus delta action\n * @param {Types~Locus} locus Locus delta\n * @returns {undefined}\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n onDeltaAction(action: string, locus) {}\n\n /**\n * Event handler for locus delta events\n * @param {Types~Locus} loci Locus Delta\n * @returns {undefined}\n */\n onDeltaEvent(loci) {\n // enqueue the new loci\n this.queue.enqueue(loci);\n\n if (this.onDeltaAction) {\n if (this.status === 'BLOCKED') {\n if (this.queue.size() > MAX_OOO_DELTA_COUNT) {\n this.triggerSync('queue too big, blocked on out-of-order delta');\n } else {\n this.processDeltaEvent();\n }\n } else if (this.status === 'IDLE') {\n // Update status, ensure we only process one event at a time.\n this.status = 'WORKING';\n\n this.processDeltaEvent();\n }\n }\n }\n\n /**\n * Appends new data onto a string of existing data.\n * @param {string} newData\n * @param {string} oldData\n * @returns {string}\n */\n static packComparisonResult(newData: string, oldData: string) {\n return `${newData}:${oldData}`;\n }\n\n /**\n * Pause locus processing\n * @returns {undefined}\n */\n pause() {\n this.status = 'PAUSED';\n LoggerProxy.logger.info('Locus-info:parser#pause --> Locus parser paused.');\n }\n\n /**\n * Triggers a sync with Locus\n *\n * @param {string} reason used just for logging\n * @returns {undefined}\n */\n private triggerSync(reason: string) {\n LoggerProxy.logger.info(`Locus-info:parser#triggerSync --> doing sync, reason: ${reason}`);\n this.stopSyncTimer();\n this.pause();\n this.onDeltaAction(Parser.loci.DESYNC, this.workingCopy);\n }\n\n /**\n * Starts a timer with a random delay. When that timer expires we will do a sync.\n *\n * The main purpose of this timer is to handle a case when we get some out-of-order deltas,\n * so we start waiting to receive the missing delta. If that delta never arrives, this timer\n * will trigger a sync with Locus.\n *\n * @returns {undefined}\n */\n private startSyncTimer() {\n if (this.syncTimer === null) {\n const timeout = OOO_DELTA_WAIT_TIME + Math.random() * OOO_DELTA_WAIT_TIME_RANDOM_DELAY;\n\n this.syncTimer = setTimeout(() => {\n this.syncTimer = null;\n this.triggerSync('timer expired, blocked on out-of-order delta');\n }, timeout);\n }\n }\n\n /**\n * Stops the timer for triggering a sync\n *\n * @returns {undefined}\n */\n private stopSyncTimer() {\n if (this.syncTimer !== null) {\n clearTimeout(this.syncTimer);\n this.syncTimer = null;\n }\n }\n\n /**\n * Processes next locus delta in the queue,\n * continues until the queue is empty\n * or cleared.\n * @returns {undefined}\n */\n processDeltaEvent() {\n const {DESYNC, USE_INCOMING, WAIT} = Parser.loci;\n const {extractComparisonState: extract} = Parser;\n const newLoci = this.queue.dequeue();\n\n if (!this.isValidLocus(newLoci)) {\n this.nextEvent();\n\n return;\n }\n\n const result = Parser.compare(this.workingCopy, newLoci);\n const lociComparison = extract(result);\n\n // limited debugging, use chrome extension\n // for full debugging.\n LoggerProxy.logger.debug(`Locus-info:parser#processDeltaEvent --> Locus Debug: ${result}`);\n\n let needToWait = false;\n\n if (lociComparison === DESYNC) {\n // wait for desync response\n this.pause();\n } else if (lociComparison === USE_INCOMING) {\n // update working copy for future comparisons.\n // Note: The working copy of parser gets updated in .onFullLocus()\n // and here when USE_INCOMING locus.\n this.workingCopy = newLoci;\n } else if (lociComparison === WAIT) {\n // we've taken newLoci from the front of the queue, so put it back there as we have to wait\n // for the one that should be in front of it, before we can process it\n this.queue.enqueue(newLoci);\n needToWait = true;\n }\n\n if (needToWait) {\n this.status = 'BLOCKED';\n this.startSyncTimer();\n } else {\n this.stopSyncTimer();\n\n if (this.status === 'BLOCKED') {\n // we are not blocked anymore\n this.status = 'WORKING';\n\n LoggerProxy.logger.info(\n `Locus-info:parser#processDeltaEvent --> received delta that we were waiting for ${Parser.locus2string(\n newLoci\n )}, not blocked anymore`\n );\n }\n }\n\n if (this.onDeltaAction) {\n LoggerProxy.logger.info(\n `Locus-info:parser#processDeltaEvent --> Locus Delta ${Parser.locus2string(\n newLoci\n )}, Action: ${lociComparison}`\n );\n\n this.onDeltaAction(lociComparison, newLoci);\n }\n\n this.nextEvent();\n }\n\n /**\n * Resume from a paused state\n * @returns {undefined}\n */\n resume() {\n LoggerProxy.logger.info('Locus-info:parser#resume --> Locus parser resumed.');\n this.status = 'WORKING';\n this.nextEvent();\n }\n\n /**\n * Gets related debug info for given error code\n * @param {string} debugCode Debug code\n * @param {string} comparison Locus comparison string\n * @returns {object} Debug message\n */\n static getDebugMessage(debugCode: string, comparison: string) {\n // removes extra spaces from multiline string\n const mStr = (strings) => strings.join('').replace(/\\s{2,}/g, ' ');\n\n const resolutionMap = {\n EQ: `${Parser.loci.LT}: is equal (current == incoming).`,\n LT: `${Parser.loci.LT}: choose right side (incoming).`,\n GT: `${Parser.loci.GT}: choose left side (current).`,\n };\n\n const debugMap = {\n SO001: {\n title: 'checkSequenceOverlap-001',\n description: mStr`Occurs if earliest working copy sequence is more \\\n recent than last incoming sequence.`,\n logic: 'current.min > incoming.max',\n },\n\n SO002: {\n title: 'checkSequenceOverlap-002',\n description: mStr`Occurs if last working copy sequence is before the \\\n earliest incoming sequence.`,\n logic: 'current.max < incoming.min',\n },\n\n UR001: {\n title: 'checkUnequalRanges-001',\n description: mStr`Occurs if there are no unique values for both loci, \\\n and the current working copy loci has a larger range.`,\n logic: 'currentTotalRange > incomingTotalRange',\n },\n\n UR002: {\n title: 'checkUnequalRanges-002',\n description: mStr`Occurs if there are no unique values for both loci, \\\n and the incoming delta loci has a larger range.`,\n logic: 'currentTotalRange < incomingTotalRange',\n },\n\n UR003: {\n title: 'checkUnequalRanges-003',\n description: mStr`Occurs if there are no unique values for both loci, \\\n and with ranges either absent or of the same size, the sequences \\\n are considered equal.`,\n logic: 'currentTotalRange == incomingTotalRange',\n },\n\n UE001: {\n title: 'checkForUniqueEntries-001',\n description: mStr`Occurs if current loci has unique entries and \\\n incoming does not. Entries are considered unique if they \\\n do not overlap with other Loci sequences or range values.`,\n logic: 'currentIsUnique && !incomingIsUnique',\n },\n\n UE002: {\n title: 'checkForUniqueEntries-002',\n description: mStr`Occurs if current has no unique entries but \\\n incoming does. Entries are considered unique if they \\\n do not overlap with other Loci sequences or range values.`,\n logic: '!currentIsUnique && incomingIsUnique',\n },\n\n OOS001: {\n title: 'checkIfOutOfSync-001',\n description: mStr`Occurs if neither sequence has a range, or \\\n if the current loci unique entries overlap the total range of the \\\n incoming sequence, or if the incoming unique entries overlap \\\n the total range of current sequence.`,\n logic: 'neitherSeqHasRange || currentUniqOverlap || incomingUniqOverlap',\n },\n\n OOS002: {\n title: 'checkIfOutOfSync-002',\n description: mStr`Occurs if the minimum value from sequences that are \\\n unique to the current loci is greater than the minimum value from \\\n sequences that are unique to the incoming loci.`,\n logic: 'currentUniqueMin > incomingUniqueMin',\n },\n\n OOS003: {\n title: 'checkIfOutOfSync-003',\n description: mStr`Occurs if none of the comparison rules applied. \\\n It is a catch all.`,\n logic: 'else (catch all)',\n },\n };\n\n const debugObj = debugMap[debugCode];\n\n debugObj.title = `Debug: ${debugObj.title}`;\n debugObj.resolution = resolutionMap[comparison];\n\n return debugObj;\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAEA;AACA;AAEA;AACA;AAAsD;AAEtD,IAAMA,mBAAmB,GAAG,CAAC,CAAC,CAAC;AAC/B,IAAMC,mBAAmB,GAAG,KAAK,CAAC,CAAC;AACnC,IAAMC,gCAAgC,GAAG,IAAI,CAAC,CAAC;AAgB/C;AACA;AACA;AACA;AACA;AAJA,IAKqBC,MAAM;EACzB;;EAKe;;EAEf;;EAgBA;AACF;AACA;EACE,kBAAc;IAAA;IAAA;IAAA;IAAA;IAAA;IACZ,IAAMC,gBAAgB,GAAG,SAAnBA,gBAAgB,CAAIC,IAAmB,EAAEC,KAAoB,EAAK;MACtE,mBAAiBH,MAAM,CAACI,IAAI;QAArBC,EAAE,gBAAFA,EAAE;QAAEC,EAAE,gBAAFA,EAAE;MACb,IAA+BC,OAAO,GAAIP,MAAM,CAAzCQ,sBAAsB;MAE7B,IAAIR,MAAM,CAACS,eAAe,CAACP,IAAI,CAAC,EAAE;QAChC,OAAO,CAAC,CAAC;MACX;MACA,IAAIF,MAAM,CAACS,eAAe,CAACN,KAAK,CAAC,EAAE;QACjC,OAAO,CAAC;MACV;MACA,IAAMO,MAAM,GAAGH,OAAO,CAACP,MAAM,CAACW,eAAe,CAACT,IAAI,CAACU,YAAY,EAAET,KAAK,CAACS,YAAY,CAAC,CAAC;MAErF,IAAIF,MAAM,KAAKL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,QAAQ,CAACC,UAAU,GAAGhB,aAAa,CAAC/E,UAAU,CAAC;MAE/C,OAAO8F,QAAQ;IACjB;EAAC;EAAA;AAAA;AAAA;AAAA,8BAv0BkB1J,MAAM,UASX;EACZqE,EAAE,EAAE,OAAO;EACX/D,EAAE,EAAE,cAAc;EAClBD,EAAE,EAAE,WAAW;EACfiC,MAAM,EAAE,QAAQ;EAChBZ,YAAY,EAAE,cAAc;EAC5BsE,WAAW,EAAE,aAAa;EAC1BpD,IAAI,EAAE,MAAM;EACZ+D,KAAK,EAAE;AACT,CAAC"}
@@ -472,6 +472,7 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
472
472
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "meetingNumber", void 0);
473
473
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "meetingState", void 0);
474
474
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "permissionToken", void 0);
475
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "permissionTokenPayload", void 0);
475
476
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "resourceId", void 0);
476
477
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "resourceUrl", void 0);
477
478
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "selfId", void 0);
@@ -723,7 +724,9 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
723
724
  icePhase: 'IN_MEETING',
724
725
  errors: [
725
726
  // @ts-ignore
726
- _this.webex.internal.newMetrics.callDiagnosticMetrics.getErrorPayloadForClientErrorCode(_internalPluginMetrics.CALL_DIAGNOSTIC_CONFIG.ICE_FAILURE_CLIENT_CODE)]
727
+ _this.webex.internal.newMetrics.callDiagnosticMetrics.getErrorPayloadForClientErrorCode({
728
+ clientErrorCode: _internalPluginMetrics.CALL_DIAGNOSTIC_CONFIG.ICE_FAILURE_CLIENT_CODE
729
+ })]
727
730
  },
728
731
  options: {
729
732
  meetingId: _this.id
@@ -3270,7 +3273,8 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
3270
3273
  }
3271
3274
  this.owner = ((_locusMeetingObject6 = locusMeetingObject) === null || _locusMeetingObject6 === void 0 ? void 0 : _locusMeetingObject6.info.owner) || (webexMeetingInfo === null || webexMeetingInfo === void 0 ? void 0 : webexMeetingInfo.owner) || (webexMeetingInfo === null || webexMeetingInfo === void 0 ? void 0 : webexMeetingInfo.hostId) || this.owner;
3272
3275
  this.permissionToken = webexMeetingInfo === null || webexMeetingInfo === void 0 ? void 0 : webexMeetingInfo.permissionToken;
3273
- this.setSelfUserPolicies(this.permissionToken);
3276
+ this.setPermissionTokenPayload(webexMeetingInfo === null || webexMeetingInfo === void 0 ? void 0 : webexMeetingInfo.permissionToken);
3277
+ this.setSelfUserPolicies();
3274
3278
  // Need to populate environment when sending CA event
3275
3279
  this.environment = ((_locusMeetingObject7 = locusMeetingObject) === null || _locusMeetingObject7 === void 0 ? void 0 : _locusMeetingObject7.info.channel) || (webexMeetingInfo === null || webexMeetingInfo === void 0 ? void 0 : webexMeetingInfo.channel);
3276
3280
  }
@@ -3485,14 +3489,25 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
3485
3489
 
3486
3490
  /**
3487
3491
  * Sets the self user policies based on the contents of the permission token
3488
- * @param {String} permissionToken
3489
3492
  * @returns {void}
3490
3493
  */
3491
3494
  }, {
3492
3495
  key: "setSelfUserPolicies",
3493
- value: function setSelfUserPolicies(permissionToken) {
3494
- var _jwt$decode, _jwt$decode$permissio;
3495
- this.selfUserPolicies = (_jwt$decode = _jsonwebtoken.default.decode(permissionToken)) === null || _jwt$decode === void 0 ? void 0 : (_jwt$decode$permissio = _jwt$decode.permission) === null || _jwt$decode$permissio === void 0 ? void 0 : _jwt$decode$permissio.userPolicies;
3496
+ value: function setSelfUserPolicies() {
3497
+ var _this$permissionToken, _this$permissionToken2;
3498
+ this.selfUserPolicies = (_this$permissionToken = this.permissionTokenPayload) === null || _this$permissionToken === void 0 ? void 0 : (_this$permissionToken2 = _this$permissionToken.permission) === null || _this$permissionToken2 === void 0 ? void 0 : _this$permissionToken2.userPolicies;
3499
+ }
3500
+
3501
+ /**
3502
+ * Sets the permission token payload on the class instance
3503
+ *
3504
+ * @param {String} permissionToken
3505
+ * @returns {void}
3506
+ */
3507
+ }, {
3508
+ key: "setPermissionTokenPayload",
3509
+ value: function setPermissionTokenPayload(permissionToken) {
3510
+ this.permissionTokenPayload = _jsonwebtoken.default.decode(permissionToken);
3496
3511
  }
3497
3512
 
3498
3513
  /**
@@ -5378,7 +5393,9 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
5378
5393
  icePhase: 'JOIN_MEETING_FINAL',
5379
5394
  errors: [
5380
5395
  // @ts-ignore
5381
- _this39.webex.internal.newMetrics.callDiagnosticMetrics.getErrorPayloadForClientErrorCode(_internalPluginMetrics.CALL_DIAGNOSTIC_CONFIG.ICE_FAILURE_CLIENT_CODE)]
5396
+ _this39.webex.internal.newMetrics.callDiagnosticMetrics.getErrorPayloadForClientErrorCode({
5397
+ clientErrorCode: _internalPluginMetrics.CALL_DIAGNOSTIC_CONFIG.ICE_FAILURE_CLIENT_CODE
5398
+ })]
5382
5399
  },
5383
5400
  options: {
5384
5401
  meetingId: _this39.id
@@ -5394,6 +5411,7 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
5394
5411
  }).then(function () {
5395
5412
  return _this39.mediaProperties.getCurrentConnectionType();
5396
5413
  }).then(function (connectionType) {
5414
+ var _this39$remoteMediaMa;
5397
5415
  _metrics.default.sendBehavioralMetric(_constants2.default.ADD_MEDIA_SUCCESS, {
5398
5416
  correlation_id: _this39.correlationId,
5399
5417
  locus_id: _this39.locusUrl.split('/').pop(),
@@ -5407,8 +5425,13 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
5407
5425
  meetingId: _this39.id
5408
5426
  }
5409
5427
  });
5428
+ _loggerProxy.default.logger.info("".concat(LOG_HEADER, " successfully established media connection, type=").concat(connectionType));
5429
+
5430
+ // We can log ReceiveSlot SSRCs only after the SDP exchange, so doing it here:
5431
+ (_this39$remoteMediaMa = _this39.remoteMediaManager) === null || _this39$remoteMediaMa === void 0 ? void 0 : _this39$remoteMediaMa.logAllReceiveSlots();
5410
5432
  }).catch(function (error) {
5411
5433
  var _this39$mediaProperti, _this39$mediaProperti2, _this39$mediaProperti3, _this39$mediaProperti4, _this39$mediaProperti5, _this39$mediaProperti6, _this39$mediaProperti7, _this39$mediaProperti8, _this39$mediaProperti9, _this39$mediaProperti10, _this39$mediaProperti11, _this39$mediaProperti12, _this39$mediaProperti13, _this39$mediaProperti14, _this39$mediaProperti15, _this39$mediaProperti16, _this39$mediaProperti17, _this39$mediaProperti18, _this39$mediaProperti19, _this39$mediaProperti20, _this39$mediaProperti21;
5434
+ _loggerProxy.default.logger.error("".concat(LOG_HEADER, " failed to establish media connection: "), error);
5412
5435
  _metrics.default.sendBehavioralMetric(_constants2.default.ADD_MEDIA_FAILURE, {
5413
5436
  correlation_id: _this39.correlationId,
5414
5437
  locus_id: _this39.locusUrl.split('/').pop(),
@@ -5431,7 +5454,6 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
5431
5454
  _this39.closePeerConnections();
5432
5455
  _this39.unsetPeerConnections();
5433
5456
  }
5434
- _loggerProxy.default.logger.error("".concat(LOG_HEADER, " Error adding media failed to initiate PC and send request, "), error);
5435
5457
 
5436
5458
  // Upload logs on error while adding media
5437
5459
  _triggerProxy.default.trigger(_this39, {
@@ -5529,12 +5551,25 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
5529
5551
  }
5530
5552
  return _context17.abrupt("return", this.enqueueMediaUpdate(MEDIA_UPDATE_TYPE.UPDATE_MEDIA, options));
5531
5553
  case 5:
5532
- if (!(this.isMultistream && (shareAudioEnabled !== undefined || shareVideoEnabled !== undefined))) {
5533
- _context17.next = 7;
5554
+ if (!this.isMultistream) {
5555
+ _context17.next = 10;
5556
+ break;
5557
+ }
5558
+ if (!(shareAudioEnabled !== undefined || shareVideoEnabled !== undefined)) {
5559
+ _context17.next = 8;
5534
5560
  break;
5535
5561
  }
5536
5562
  throw new Error('toggling shareAudioEnabled or shareVideoEnabled in a multistream meeting is not supported, to control receiving screen share call meeting.remoteMediaManager.setLayout() with appropriate layout');
5537
- case 7:
5563
+ case 8:
5564
+ _context17.next = 12;
5565
+ break;
5566
+ case 10:
5567
+ if (!(shareAudioEnabled !== undefined)) {
5568
+ _context17.next = 12;
5569
+ break;
5570
+ }
5571
+ throw new Error('toggling shareAudioEnabled in a transcoded meeting is not supported as of now');
5572
+ case 12:
5538
5573
  if (audioEnabled !== undefined) {
5539
5574
  this.mediaProperties.mediaDirection.sendAudio = audioEnabled;
5540
5575
  this.mediaProperties.mediaDirection.receiveAudio = audioEnabled;
@@ -5555,14 +5590,14 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
5555
5590
  this.mediaProperties.mediaDirection.receiveShare = !!(shareAudioEnabled || shareVideoEnabled);
5556
5591
  }
5557
5592
  if (this.isMultistream) {
5558
- _context17.next = 13;
5593
+ _context17.next = 18;
5559
5594
  break;
5560
5595
  }
5561
- _context17.next = 13;
5596
+ _context17.next = 18;
5562
5597
  return this.updateTranscodedMediaConnection();
5563
- case 13:
5598
+ case 18:
5564
5599
  return _context17.abrupt("return", undefined);
5565
- case 14:
5600
+ case 19:
5566
5601
  case "end":
5567
5602
  return _context17.stop();
5568
5603
  }
@@ -6797,6 +6832,28 @@ var Meeting = /*#__PURE__*/function (_StatelessWebexPlugin) {
6797
6832
  }
6798
6833
  return unpublishStreams;
6799
6834
  }()
6835
+ /**
6836
+ * Gets the time left in seconds till the permission token expires
6837
+ * (from the time the function has been fired)
6838
+ *
6839
+ * @returns {number} time left in seconds
6840
+ */
6841
+ }, {
6842
+ key: "getPermissionTokenTimeLeftInSec",
6843
+ value: function getPermissionTokenTimeLeftInSec() {
6844
+ if (!this.permissionTokenPayload) {
6845
+ return undefined;
6846
+ }
6847
+ var permissionTokenExpValue = Number(this.permissionTokenPayload.exp);
6848
+
6849
+ // using new Date instead of Date.now() to allow for accurate unit testing
6850
+ // https://github.com/sinonjs/fake-timers/issues/321
6851
+ var now = new Date().getTime();
6852
+
6853
+ // substract current time from the permissionTokenExp
6854
+ // (permissionTokenExp is a epoch timestamp, not a time to live duration)
6855
+ return (permissionTokenExpValue - now) / 1000;
6856
+ }
6800
6857
  }]);
6801
6858
  return Meeting;
6802
6859
  }(_webexCore.StatelessWebexPlugin);