@webex/plugin-meetings 1.151.2 → 1.151.3

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.
@@ -131,15 +131,56 @@ MeetingInfoUtil.getSipUriFromHydraPersonId = function (destination, webex) {
131
131
 
132
132
  MeetingInfoUtil.getDestinationType = /*#__PURE__*/function () {
133
133
  var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(from) {
134
- var destination, type, webex, options, hydraId, conversationUrl;
134
+ var type, webex, destination, _options, res, _res$items$, orgId, userId, options, hydraId, conversationUrl;
135
+
135
136
  return _regenerator.default.wrap(function _callee$(_context) {
136
137
  while (1) {
137
138
  switch (_context.prev = _context.next) {
138
139
  case 0:
139
- destination = from.destination, type = from.type, webex = from.webex;
140
+ type = from.type, webex = from.webex;
141
+ destination = from.destination;
142
+
143
+ if (!(type === _constants._PERSONAL_ROOM_)) {
144
+ _context.next = 15;
145
+ break;
146
+ }
147
+
148
+ if (destination) {
149
+ _context.next = 7;
150
+ break;
151
+ }
152
+
153
+ // if we are not getting anything in desination we fetch org and user ids from webex instance
154
+ destination = {
155
+ userId: webex.internal.device.userId,
156
+ orgId: webex.internal.device.orgId
157
+ };
158
+ _context.next = 15;
159
+ break;
140
160
 
161
+ case 7:
162
+ _options = _constants.VALID_EMAIL_ADDRESS.test(destination) ? {
163
+ email: destination
164
+ } : {
165
+ id: destination
166
+ }; // we are assuming userId as default
167
+
168
+ _context.next = 10;
169
+ return webex.people.list(_options);
170
+
171
+ case 10:
172
+ res = _context.sent;
173
+ _res$items$ = res.items[0], orgId = _res$items$.orgId, userId = _res$items$.id;
174
+ userId = (0, _common.deconstructHydraId)(userId).id;
175
+ orgId = (0, _common.deconstructHydraId)(orgId).id;
176
+ destination = {
177
+ userId: userId,
178
+ orgId: orgId
179
+ };
180
+
181
+ case 15:
141
182
  if (!type) {
142
- _context.next = 3;
183
+ _context.next = 17;
143
184
  break;
144
185
  }
145
186
 
@@ -148,12 +189,12 @@ MeetingInfoUtil.getDestinationType = /*#__PURE__*/function () {
148
189
  type: type
149
190
  });
150
191
 
151
- case 3:
192
+ case 17:
152
193
  options = {};
153
194
  hydraId = MeetingInfoUtil.getHydraId(destination);
154
195
 
155
196
  if (!MeetingInfoUtil.isMeetingLink(destination)) {
156
- _context.next = 11;
197
+ _context.next = 25;
157
198
  break;
158
199
  }
159
200
 
@@ -161,45 +202,45 @@ MeetingInfoUtil.getDestinationType = /*#__PURE__*/function () {
161
202
 
162
203
  options.type = _constants._MEETING_LINK_;
163
204
  options.destination = destination;
164
- _context.next = 48;
205
+ _context.next = 62;
165
206
  break;
166
207
 
167
- case 11:
208
+ case 25:
168
209
  if (!MeetingInfoUtil.isSipUri(destination)) {
169
- _context.next = 16;
210
+ _context.next = 30;
170
211
  break;
171
212
  }
172
213
 
173
214
  options.type = _constants._SIP_URI_;
174
215
  options.destination = destination;
175
- _context.next = 48;
216
+ _context.next = 62;
176
217
  break;
177
218
 
178
- case 16:
219
+ case 30:
179
220
  if (!MeetingInfoUtil.isPhoneNumber(destination)) {
180
- _context.next = 21;
221
+ _context.next = 35;
181
222
  break;
182
223
  }
183
224
 
184
225
  options.type = _constants._SIP_URI_;
185
226
  options.destination = destination;
186
- _context.next = 48;
227
+ _context.next = 62;
187
228
  break;
188
229
 
189
- case 21:
230
+ case 35:
190
231
  if (!MeetingInfoUtil.isConversationUrl(destination, webex)) {
191
- _context.next = 26;
232
+ _context.next = 40;
192
233
  break;
193
234
  }
194
235
 
195
236
  options.type = _constants._CONVERSATION_URL_;
196
237
  options.destination = destination;
197
- _context.next = 48;
238
+ _context.next = 62;
198
239
  break;
199
240
 
200
- case 26:
241
+ case 40:
201
242
  if (!hydraId.people) {
202
- _context.next = 31;
243
+ _context.next = 45;
203
244
  break;
204
245
  }
205
246
 
@@ -216,52 +257,52 @@ MeetingInfoUtil.getDestinationType = /*#__PURE__*/function () {
216
257
  return _promise.default.resolve(options);
217
258
  }));
218
259
 
219
- case 31:
260
+ case 45:
220
261
  if (!hydraId.room) {
221
- _context.next = 46;
262
+ _context.next = 60;
222
263
  break;
223
264
  }
224
265
 
225
266
  options.type = _constants._CONVERSATION_URL_;
226
- _context.prev = 33;
227
- _context.next = 36;
267
+ _context.prev = 47;
268
+ _context.next = 50;
228
269
  return webex.internal.services.waitForCatalog('postauth');
229
270
 
230
- case 36:
271
+ case 50:
231
272
  conversationUrl = webex.internal.conversation.getUrlFromClusterId({
232
273
  cluster: hydraId.cluster,
233
274
  id: hydraId.destination
234
275
  });
235
276
  options.destination = conversationUrl;
236
- _context.next = 44;
277
+ _context.next = 58;
237
278
  break;
238
279
 
239
- case 40:
240
- _context.prev = 40;
241
- _context.t0 = _context["catch"](33);
280
+ case 54:
281
+ _context.prev = 54;
282
+ _context.t0 = _context["catch"](47);
242
283
 
243
284
  _loggerProxy.default.logger.error("Meeting-info:util#getDestinationType --> ".concat(_context.t0));
244
285
 
245
286
  throw _context.t0;
246
287
 
247
- case 44:
248
- _context.next = 48;
288
+ case 58:
289
+ _context.next = 62;
249
290
  break;
250
291
 
251
- case 46:
292
+ case 60:
252
293
  _loggerProxy.default.logger.warn('Meeting-info:util#getDestinationType --> (\'MeetingInfo is fetched with meeting link, sip uri, phone number, hydra room id, hydra people id, or a conversation url.');
253
294
 
254
295
  throw new _parameter.default('MeetingInfo is fetched with meeting link, sip uri, phone number, hydra room id, hydra people id, or a conversation url.');
255
296
 
256
- case 48:
297
+ case 62:
257
298
  return _context.abrupt("return", _promise.default.resolve(options));
258
299
 
259
- case 49:
300
+ case 63:
260
301
  case "end":
261
302
  return _context.stop();
262
303
  }
263
304
  }
264
- }, _callee, null, [[33, 40]]);
305
+ }, _callee, null, [[47, 54]]);
265
306
  }));
266
307
 
267
308
  return function (_x) {
@@ -292,9 +333,8 @@ MeetingInfoUtil.getRequestBody = function (options) {
292
333
  break;
293
334
 
294
335
  case _constants._PERSONAL_ROOM_:
295
- body.userId = destination;
296
- body.orgId = ''; // TODO: when to use the org iD (fetch others PMR)
297
-
336
+ body.userId = destination.userId;
337
+ body.orgId = destination.orgId;
298
338
  break;
299
339
 
300
340
  case _constants._MEETING_ID_:
@@ -1 +1 @@
1
- {"version":3,"sources":["utilv2.js"],"names":["MeetingInfoUtil","getParsedUrl","link","parsedUrl","url","parse","protocol","HTTPS_PROTOCOL","error","LoggerProxy","logger","warn","isMeetingLink","value","hostNameBool","hostname","includes","WEBEX_DOT_COM","pathNameBool","pathname","MEET","MEET_M","JOIN","isConversationUrl","webex","clusterId","internal","services","getClusterId","endsWith","CONVERSATION_SERVICE","isSipUri","sipString","sipUri","DIALER_REGEX","SIP_ADDRESS","exec","isPhoneNumber","phoneNumber","isValidNumber","PHONE_NUMBER","test","getHydraId","destination","type","id","cluster","UUID_REG","_ROOM_","room","_PEOPLE_","people","getSipUriFromHydraPersonId","get","then","res","emails","length","ParameterError","catch","err","getDestinationType","from","options","hydraId","_MEETING_LINK_","_SIP_URI_","_CONVERSATION_URL_","wasHydraPerson","resolve","waitForCatalog","conversationUrl","conversation","getUrlFromClusterId","getRequestBody","body","supportHostKey","sipUrl","_PERSONAL_ROOM_","userId","orgId","_MEETING_ID_","meetingKey","_LOCUS_ID_","info","webExMeetingId","meetingUrl","_MEETING_UUID_","meetingUUID"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;AAEA;;AAIA;;AAmBA;;AACA;;AAEA,IAAMA,eAAe,GAAG,EAAxB;;AAEAA,eAAe,CAACC,YAAhB,GAA+B,UAACC,IAAD,EAAU;AACvC,MAAI;AACF,QAAIC,SAAS,GAAGC,aAAIC,KAAJ,CAAUH,IAAV,CAAhB;;AAEA,QAAI,CAACC,SAAL,EAAgB;AACd,aAAO,KAAP;AACD,KALC,CAMF;;;AACA,QAAI,CAACA,SAAS,CAACG,QAAf,EAAyB;AACvBH,MAAAA,SAAS,GAAGC,aAAIC,KAAJ,WAAaE,yBAAb,SAA8BL,IAA9B,EAAZ;AACD;;AAED,WAAOC,SAAP;A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;AACA;;AACF,SAAK4C,yBAAL;AAAqB;AACnBZ,QAAAA,IAAI,CAACa,WAAL,GAAmB7C,WAAnB;AACA;AACD;;AACD;AA9BF;;AAiCA,SAAOgC,IAAP;AACD,CAxCD;;eA0Ce3E,e","sourcesContent":["import url from 'url';\n\nimport {\n deconstructHydraId\n} from '@webex/common';\n\nimport {\n _SIP_URI_,\n _PERSONAL_ROOM_,\n _MEETING_ID_,\n _CONVERSATION_URL_,\n _LOCUS_ID_,\n _MEETING_LINK_,\n _PEOPLE_,\n _ROOM_,\n _MEETING_UUID_,\n DIALER_REGEX,\n WEBEX_DOT_COM,\n CONVERSATION_SERVICE,\n JOIN,\n MEET,\n MEET_M,\n HTTPS_PROTOCOL,\n UUID_REG\n} from '../constants';\nimport ParameterError from '../common/errors/parameter';\nimport LoggerProxy from '../common/logs/logger-proxy';\n\nconst MeetingInfoUtil = {};\n\nMeetingInfoUtil.getParsedUrl = (link) => {\n try {\n let parsedUrl = url.parse(link);\n\n if (!parsedUrl) {\n return false;\n }\n // hack for links such as <company>.webex.com/meet/<user> without a protocol\n if (!parsedUrl.protocol) {\n parsedUrl = url.parse(`${HTTPS_PROTOCOL}${link}`);\n }\n\n return parsedUrl;\n }\n catch (error) {\n LoggerProxy.logger.warn(`Meeting-info:util#getParsedUrl --> unable to parse the URL, error: ${error}`);\n\n return null;\n }\n};\n\n/**\n * Helper function to check if a string matches a known meeting link pattern\n * @param {String} value string to parse and see if it matches a meeting link\n * @returns {Boolean}\n */\nMeetingInfoUtil.isMeetingLink = (value) => {\n const parsedUrl = MeetingInfoUtil.getParsedUrl(value);\n const hostNameBool = parsedUrl.hostname && parsedUrl.hostname.includes(WEBEX_DOT_COM);\n const pathNameBool = parsedUrl.pathname && (parsedUrl.pathname.includes(`/${MEET}`) || parsedUrl.pathname.includes(`/${MEET_M}`) || parsedUrl.pathname.includes(`/${JOIN}`));\n\n return hostNameBool && pathNameBool;\n};\n\nMeetingInfoUtil.isConversationUrl = (value, webex) => {\n const clusterId = webex.internal.services.getClusterId(value);\n\n if (clusterId) {\n return clusterId.endsWith(CONVERSATION_SERVICE);\n }\n\n return false;\n};\n\n\nMeetingInfoUtil.isSipUri = (sipString) => {\n // TODO: lets remove regex from this equation and user URI matchers and such\n // have not found a great sip uri parser library as of now\n const sipUri = DIALER_REGEX.SIP_ADDRESS.exec(sipString);\n\n return sipUri;\n};\n\nMeetingInfoUtil.isPhoneNumber = (phoneNumber) => {\n const isValidNumber = DIALER_REGEX.PHONE_NUMBER.test(phoneNumber);\n\n return isValidNumber;\n};\n\nMeetingInfoUtil.getHydraId = (destination) => {\n const {type, id, cluster} = deconstructHydraId(destination);\n\n if (id && UUID_REG.test(id)) {\n if (type === _ROOM_) {\n return {room: true, destination: id, cluster};\n }\n if (type === _PEOPLE_) {\n return {people: true, destination: id, cluster};\n }\n\n return {};\n }\n\n return {};\n};\n\nMeetingInfoUtil.getSipUriFromHydraPersonId = (destination, webex) => webex.people.get(destination).then((res) => {\n if (res.emails && res.emails.length) {\n return res.emails[0];\n }\n throw new ParameterError('Hydra Id Lookup was an invalid hydra person id.');\n}).catch((err) => {\n LoggerProxy.logger.error(`Meeting-info:util#MeetingInfoUtil.getSipUriFromHydraPersonId --> getSipUriFromHydraPersonId ${err} `);\n throw err;\n});\n\n\nMeetingInfoUtil.getDestinationType = async (from) => {\n const {destination, type, webex} = from;\n\n if (type) {\n return {\n destination,\n type\n };\n }\n const options = {};\n const hydraId = MeetingInfoUtil.getHydraId(destination);\n\n if (MeetingInfoUtil.isMeetingLink(destination)) {\n LoggerProxy.logger.warn('Meeting-info:util#generateOptions --> WARN, use of Meeting Link is deprecated, please use a SIP URI instead');\n\n options.type = _MEETING_LINK_;\n options.destination = destination;\n }\n else if (MeetingInfoUtil.isSipUri(destination)) {\n options.type = _SIP_URI_;\n options.destination = destination;\n }\n else if (MeetingInfoUtil.isPhoneNumber(destination)) {\n options.type = _SIP_URI_;\n options.destination = destination;\n }\n else if (MeetingInfoUtil.isConversationUrl(destination, webex)) {\n options.type = _CONVERSATION_URL_;\n options.destination = destination;\n }\n else if (hydraId.people) {\n options.type = _SIP_URI_;\n\n return MeetingInfoUtil.getSipUriFromHydraPersonId(hydraId.destination, webex).then((res) => {\n options.destination = res;\n\n // Since hydra person ids require a unique case in which they are\n // entirely converted to a SIP URI, we need to set a flag for detecting\n // this type of destination.\n options.wasHydraPerson = true;\n\n return Promise.resolve(options);\n });\n }\n else if (hydraId.room) {\n options.type = _CONVERSATION_URL_;\n try {\n await webex.internal.services.waitForCatalog('postauth');\n\n const conversationUrl = webex.internal.conversation.getUrlFromClusterId({\n cluster: hydraId.cluster,\n id: hydraId.destination\n });\n\n options.destination = conversationUrl;\n }\n catch (e) {\n LoggerProxy.logger.error(`Meeting-info:util#getDestinationType --> ${e}`);\n throw (e);\n }\n }\n else {\n LoggerProxy.logger.warn('Meeting-info:util#getDestinationType --> (\\'MeetingInfo is fetched with meeting link, sip uri, phone number, hydra room id, hydra people id, or a conversation url.');\n throw new ParameterError('MeetingInfo is fetched with meeting link, sip uri, phone number, hydra room id, hydra people id, or a conversation url.');\n }\n\n return Promise.resolve(options);\n};\n\n/**\n * Helper function to build up a correct locus url depending on the value passed\n * @param {Object} options type and value to fetch meeting info\n * @param {String} options.type One of [SIP_URI, PERSONAL_ROOM, MEETING_ID, CONVERSATION_URL, LOCUS_ID, MEETING_LINK]\n * @param {Object} options.destination ?? value.value\n * @returns {Object} returns an object with {resource, method}\n */\nMeetingInfoUtil.getRequestBody = (options) => {\n const {type, destination} = options;\n const body = {\n supportHostKey: true\n };\n\n switch (type) {\n case _SIP_URI_:\n body.sipUrl = destination;\n break;\n case _PERSONAL_ROOM_:\n body.userId = destination;\n body.orgId = ''; // TODO: when to use the org iD (fetch others PMR)\n break;\n case _MEETING_ID_:\n body.meetingKey = destination;\n break;\n case _CONVERSATION_URL_:\n body.conversationUrl = destination;\n break;\n case _LOCUS_ID_:\n // use meetingID for the completer meeting info for the already started meeting\n if (destination.info?.webExMeetingId) {\n body.meetingKey = destination.info.webExMeetingId;\n }\n else if (destination.info?.sipUri) {\n body.sipUrl = destination.info.sipUri;\n }\n break;\n case _MEETING_LINK_:\n body.meetingUrl = destination;\n break;\n case _MEETING_UUID_: {\n body.meetingUUID = destination;\n break;\n }\n default:\n }\n\n return body;\n};\n\nexport default MeetingInfoUtil;\n"]}
1
+ {"version":3,"sources":["utilv2.js"],"names":["MeetingInfoUtil","getParsedUrl","link","parsedUrl","url","parse","protocol","HTTPS_PROTOCOL","error","LoggerProxy","logger","warn","isMeetingLink","value","hostNameBool","hostname","includes","WEBEX_DOT_COM","pathNameBool","pathname","MEET","MEET_M","JOIN","isConversationUrl","webex","clusterId","internal","services","getClusterId","endsWith","CONVERSATION_SERVICE","isSipUri","sipString","sipUri","DIALER_REGEX","SIP_ADDRESS","exec","isPhoneNumber","phoneNumber","isValidNumber","PHONE_NUMBER","test","getHydraId","destination","type","id","cluster","UUID_REG","_ROOM_","room","_PEOPLE_","people","getSipUriFromHydraPersonId","get","then","res","emails","length","ParameterError","catch","err","getDestinationType","from","_PERSONAL_ROOM_","userId","device","orgId","options","VALID_EMAIL_ADDRESS","email","list","items","hydraId","_MEETING_LINK_","_SIP_URI_","_CONVERSATION_URL_","wasHydraPerson","resolve","waitForCatalog","conversationUrl","conversation","getUrlFromClusterId","getRequestBody","body","supportHostKey","sipUrl","_MEETING_ID_","meetingKey","_LOCUS_ID_","info","webExMeetingId","meetingUrl","_MEETING_UUID_","meetingUUID"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;AAEA;;AAIA;;AAoBA;;AACA;;AAEA,IAAMA,eAAe,GAAG,EAAxB;;AAEAA,eAAe,CAACC,YAAhB,GAA+B,UAACC,IAAD,EAAU;AACvC,MAAI;AACF,QAAIC,SAAS,GAAGC,aAAIC,KAAJ,CAAUH,IAAV,CAAhB;;AAEA,QAAI,CAACC,SAAL,EAAgB;AACd,aAAO,KAAP;AACD,KALC,CAMF;;;AACA,QAAI,CAACA,SAAS,C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F;;AAiCA,SAAOwC,IAAP;AACD,CAxCD;;eA0CenF,e","sourcesContent":["import url from 'url';\n\nimport {\n deconstructHydraId\n} from '@webex/common';\n\nimport {\n _SIP_URI_,\n _PERSONAL_ROOM_,\n _MEETING_ID_,\n _CONVERSATION_URL_,\n _LOCUS_ID_,\n _MEETING_LINK_,\n _PEOPLE_,\n _ROOM_,\n _MEETING_UUID_,\n DIALER_REGEX,\n WEBEX_DOT_COM,\n CONVERSATION_SERVICE,\n JOIN,\n MEET,\n MEET_M,\n HTTPS_PROTOCOL,\n UUID_REG,\n VALID_EMAIL_ADDRESS\n} from '../constants';\nimport ParameterError from '../common/errors/parameter';\nimport LoggerProxy from '../common/logs/logger-proxy';\n\nconst MeetingInfoUtil = {};\n\nMeetingInfoUtil.getParsedUrl = (link) => {\n try {\n let parsedUrl = url.parse(link);\n\n if (!parsedUrl) {\n return false;\n }\n // hack for links such as <company>.webex.com/meet/<user> without a protocol\n if (!parsedUrl.protocol) {\n parsedUrl = url.parse(`${HTTPS_PROTOCOL}${link}`);\n }\n\n return parsedUrl;\n }\n catch (error) {\n LoggerProxy.logger.warn(`Meeting-info:util#getParsedUrl --> unable to parse the URL, error: ${error}`);\n\n return null;\n }\n};\n\n/**\n * Helper function to check if a string matches a known meeting link pattern\n * @param {String} value string to parse and see if it matches a meeting link\n * @returns {Boolean}\n */\nMeetingInfoUtil.isMeetingLink = (value) => {\n const parsedUrl = MeetingInfoUtil.getParsedUrl(value);\n const hostNameBool = parsedUrl.hostname && parsedUrl.hostname.includes(WEBEX_DOT_COM);\n const pathNameBool = parsedUrl.pathname && (parsedUrl.pathname.includes(`/${MEET}`) || parsedUrl.pathname.includes(`/${MEET_M}`) || parsedUrl.pathname.includes(`/${JOIN}`));\n\n return hostNameBool && pathNameBool;\n};\n\nMeetingInfoUtil.isConversationUrl = (value, webex) => {\n const clusterId = webex.internal.services.getClusterId(value);\n\n if (clusterId) {\n return clusterId.endsWith(CONVERSATION_SERVICE);\n }\n\n return false;\n};\n\n\nMeetingInfoUtil.isSipUri = (sipString) => {\n // TODO: lets remove regex from this equation and user URI matchers and such\n // have not found a great sip uri parser library as of now\n const sipUri = DIALER_REGEX.SIP_ADDRESS.exec(sipString);\n\n return sipUri;\n};\n\nMeetingInfoUtil.isPhoneNumber = (phoneNumber) => {\n const isValidNumber = DIALER_REGEX.PHONE_NUMBER.test(phoneNumber);\n\n return isValidNumber;\n};\n\nMeetingInfoUtil.getHydraId = (destination) => {\n const {type, id, cluster} = deconstructHydraId(destination);\n\n if (id && UUID_REG.test(id)) {\n if (type === _ROOM_) {\n return {room: true, destination: id, cluster};\n }\n if (type === _PEOPLE_) {\n return {people: true, destination: id, cluster};\n }\n\n return {};\n }\n\n return {};\n};\n\nMeetingInfoUtil.getSipUriFromHydraPersonId = (destination, webex) => webex.people.get(destination).then((res) => {\n if (res.emails && res.emails.length) {\n return res.emails[0];\n }\n throw new ParameterError('Hydra Id Lookup was an invalid hydra person id.');\n}).catch((err) => {\n LoggerProxy.logger.error(`Meeting-info:util#MeetingInfoUtil.getSipUriFromHydraPersonId --> getSipUriFromHydraPersonId ${err} `);\n throw err;\n});\n\n\nMeetingInfoUtil.getDestinationType = async (from) => {\n const {type, webex} = from;\n let {destination} = from;\n\n if (type === _PERSONAL_ROOM_) { // this case checks if your type is personal room\n if (!destination) { // if we are not getting anything in desination we fetch org and user ids from webex instance\n destination = {\n userId: webex.internal.device.userId,\n orgId: webex.internal.device.orgId\n };\n }\n else {\n const options = VALID_EMAIL_ADDRESS.test(destination) ? {email: destination} : {id: destination};// we are assuming userId as default\n const res = await webex.people.list(options);\n\n let {orgId, id: userId} = res.items[0];\n\n userId = deconstructHydraId(userId).id;\n orgId = deconstructHydraId(orgId).id;\n destination = {userId, orgId};\n }\n }\n if (type) {\n return {\n destination,\n type\n };\n }\n const options = {};\n const hydraId = MeetingInfoUtil.getHydraId(destination);\n\n if (MeetingInfoUtil.isMeetingLink(destination)) {\n LoggerProxy.logger.warn('Meeting-info:util#generateOptions --> WARN, use of Meeting Link is deprecated, please use a SIP URI instead');\n\n options.type = _MEETING_LINK_;\n options.destination = destination;\n }\n else if (MeetingInfoUtil.isSipUri(destination)) {\n options.type = _SIP_URI_;\n options.destination = destination;\n }\n else if (MeetingInfoUtil.isPhoneNumber(destination)) {\n options.type = _SIP_URI_;\n options.destination = destination;\n }\n else if (MeetingInfoUtil.isConversationUrl(destination, webex)) {\n options.type = _CONVERSATION_URL_;\n options.destination = destination;\n }\n else if (hydraId.people) {\n options.type = _SIP_URI_;\n\n return MeetingInfoUtil.getSipUriFromHydraPersonId(hydraId.destination, webex).then((res) => {\n options.destination = res;\n\n // Since hydra person ids require a unique case in which they are\n // entirely converted to a SIP URI, we need to set a flag for detecting\n // this type of destination.\n options.wasHydraPerson = true;\n\n return Promise.resolve(options);\n });\n }\n else if (hydraId.room) {\n options.type = _CONVERSATION_URL_;\n try {\n await webex.internal.services.waitForCatalog('postauth');\n\n const conversationUrl = webex.internal.conversation.getUrlFromClusterId({\n cluster: hydraId.cluster,\n id: hydraId.destination\n });\n\n options.destination = conversationUrl;\n }\n catch (e) {\n LoggerProxy.logger.error(`Meeting-info:util#getDestinationType --> ${e}`);\n throw (e);\n }\n }\n else {\n LoggerProxy.logger.warn('Meeting-info:util#getDestinationType --> (\\'MeetingInfo is fetched with meeting link, sip uri, phone number, hydra room id, hydra people id, or a conversation url.');\n throw new ParameterError('MeetingInfo is fetched with meeting link, sip uri, phone number, hydra room id, hydra people id, or a conversation url.');\n }\n\n return Promise.resolve(options);\n};\n\n/**\n * Helper function to build up a correct locus url depending on the value passed\n * @param {Object} options type and value to fetch meeting info\n * @param {String} options.type One of [SIP_URI, PERSONAL_ROOM, MEETING_ID, CONVERSATION_URL, LOCUS_ID, MEETING_LINK]\n * @param {Object} options.destination ?? value.value\n * @returns {Object} returns an object with {resource, method}\n */\nMeetingInfoUtil.getRequestBody = (options) => {\n const {type, destination} = options;\n const body = {\n supportHostKey: true\n };\n\n switch (type) {\n case _SIP_URI_:\n body.sipUrl = destination;\n break;\n case _PERSONAL_ROOM_:\n body.userId = destination.userId;\n body.orgId = destination.orgId;\n break;\n case _MEETING_ID_:\n body.meetingKey = destination;\n break;\n case _CONVERSATION_URL_:\n body.conversationUrl = destination;\n break;\n case _LOCUS_ID_:\n // use meetingID for the completer meeting info for the already started meeting\n if (destination.info?.webExMeetingId) {\n body.meetingKey = destination.info.webExMeetingId;\n }\n else if (destination.info?.sipUri) {\n body.sipUrl = destination.info.sipUri;\n }\n break;\n case _MEETING_LINK_:\n body.meetingUrl = destination;\n break;\n case _MEETING_UUID_: {\n body.meetingUUID = destination;\n break;\n }\n default:\n }\n\n return body;\n};\n\nexport default MeetingInfoUtil;\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webex/plugin-meetings",
3
- "version": "1.151.2",
3
+ "version": "1.151.3",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "contributors": [
@@ -24,18 +24,18 @@
24
24
  },
25
25
  "dependencies": {
26
26
  "@babel/runtime-corejs2": "^7.14.8",
27
- "@webex/webex-core": "1.151.2",
28
- "@webex/internal-plugin-mercury": "1.151.2",
27
+ "@webex/webex-core": "1.151.3",
28
+ "@webex/internal-plugin-mercury": "1.151.3",
29
29
  "webrtc-adapter": "^7.7.0",
30
30
  "lodash": "^4.17.21",
31
31
  "uuid": "^3.3.2",
32
32
  "global": "^4.4.0",
33
33
  "ip-anonymize": "^0.1.0",
34
- "@webex/common": "1.151.2",
34
+ "@webex/common": "1.151.3",
35
35
  "bowser": "^2.11.0",
36
36
  "sdp-transform": "^2.12.0",
37
37
  "readable-stream": "^3.6.0",
38
- "@webex/common-timers": "1.151.2",
38
+ "@webex/common-timers": "1.151.3",
39
39
  "btoa": "^1.2.1",
40
40
  "javascript-state-machine": "^3.1.0",
41
41
  "envify": "^4.1.0"
@@ -21,7 +21,8 @@ import {
21
21
  MEET,
22
22
  MEET_M,
23
23
  HTTPS_PROTOCOL,
24
- UUID_REG
24
+ UUID_REG,
25
+ VALID_EMAIL_ADDRESS
25
26
  } from '../constants';
26
27
  import ParameterError from '../common/errors/parameter';
27
28
  import LoggerProxy from '../common/logs/logger-proxy';
@@ -116,8 +117,27 @@ MeetingInfoUtil.getSipUriFromHydraPersonId = (destination, webex) => webex.peopl
116
117
 
117
118
 
118
119
  MeetingInfoUtil.getDestinationType = async (from) => {
119
- const {destination, type, webex} = from;
120
+ const {type, webex} = from;
121
+ let {destination} = from;
122
+
123
+ if (type === _PERSONAL_ROOM_) { // this case checks if your type is personal room
124
+ if (!destination) { // if we are not getting anything in desination we fetch org and user ids from webex instance
125
+ destination = {
126
+ userId: webex.internal.device.userId,
127
+ orgId: webex.internal.device.orgId
128
+ };
129
+ }
130
+ else {
131
+ const options = VALID_EMAIL_ADDRESS.test(destination) ? {email: destination} : {id: destination};// we are assuming userId as default
132
+ const res = await webex.people.list(options);
133
+
134
+ let {orgId, id: userId} = res.items[0];
120
135
 
136
+ userId = deconstructHydraId(userId).id;
137
+ orgId = deconstructHydraId(orgId).id;
138
+ destination = {userId, orgId};
139
+ }
140
+ }
121
141
  if (type) {
122
142
  return {
123
143
  destination,
@@ -202,8 +222,8 @@ MeetingInfoUtil.getRequestBody = (options) => {
202
222
  body.sipUrl = destination;
203
223
  break;
204
224
  case _PERSONAL_ROOM_:
205
- body.userId = destination;
206
- body.orgId = ''; // TODO: when to use the org iD (fetch others PMR)
225
+ body.userId = destination.userId;
226
+ body.orgId = destination.orgId;
207
227
  break;
208
228
  case _MEETING_ID_:
209
229
  body.meetingKey = destination;
@@ -2,7 +2,7 @@
2
2
  * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
3
3
  */
4
4
 
5
- import {assert} from '@webex/test-helper-chai';
5
+ import {assert, expect} from '@webex/test-helper-chai';
6
6
  import sinon from 'sinon';
7
7
  import {
8
8
  _MEETING_ID_,
@@ -68,18 +68,78 @@ describe('plugin-meetings', () => {
68
68
  assert.equal(res.type, _CONVERSATION_URL_);
69
69
  assert.equal(res.destination, 'https://conv-a.wbx2.com/conversation/api/v1/conversations/bfb49280');
70
70
  });
71
+
72
+ describe('PMR', () => {
73
+ const mockedListReturn = {userId: '01824b9b-adef-4b10-b5c1-8a2fe2fb7c0e', orgId: '1eb65fdf-9643-417f-9974-ad72cae0e10f'};
74
+ const mockedList = {
75
+ items: [{
76
+ id: 'Y2lzY29zcGFyazovL3VzL1BFT1BMRS8wMTgyNGI5Yi1hZGVmLTRiMTAtYjVjMS04YTJmZTJmYjdjMGU',
77
+ orgId: 'Y2lzY29zcGFyazovL3VzL09SR0FOSVpBVElPTi8xZWI2NWZkZi05NjQzLTQxN2YtOTk3NC1hZDcyY2FlMGUxMGY'
78
+ }]
79
+
80
+ };
81
+
82
+ it('should return a userID and orgID without passing a destination', async () => {
83
+ const res = await MeetingInfoUtil.getDestinationType({
84
+ type: _PERSONAL_ROOM_,
85
+ webex: {
86
+ internal: {
87
+ device: {
88
+ userId: '01824b9b-adef-4b10-b5c1-8a2fe2fb7c0e',
89
+ orgId: '1eb65fdf-9643-417f-9974-ad72cae0e10f'
90
+ }
91
+ }
92
+ }
93
+ });
94
+
95
+ expect(res.destination.userId).to.equal('01824b9b-adef-4b10-b5c1-8a2fe2fb7c0e');
96
+ expect(res.destination.orgId).to.equal('1eb65fdf-9643-417f-9974-ad72cae0e10f');
97
+ });
98
+
99
+ it('should return a userID and orgID when passing an email', async () => {
100
+ const res = await MeetingInfoUtil.getDestinationType({
101
+ type: _PERSONAL_ROOM_,
102
+ destination: 'amritesi@cisco.com',
103
+ webex: {
104
+ people: {list: sinon.stub().returns(mockedList)}
105
+
106
+ }
107
+ });
108
+ const {orgId, userId} = res.destination;
109
+
110
+ expect(userId).to.equal(mockedListReturn.userId);
111
+ expect(orgId).to.equal(mockedListReturn.orgId);
112
+ });
113
+
114
+ it('should return a userID and orgID when passing an id', async () => {
115
+ const res = await MeetingInfoUtil.getDestinationType({
116
+ type: _PERSONAL_ROOM_,
117
+ destination: '01824b9b-adef-4b10-b5c1-8a2fe2fb7c0e',
118
+ webex: {
119
+ people: {list: sinon.stub().returns(mockedList)}
120
+ }
121
+
122
+ });
123
+ const {orgId, userId} = res.destination;
124
+
125
+ expect(userId).to.equal(mockedListReturn.userId);
126
+ expect(orgId).to.equal(mockedListReturn.orgId);
127
+ });
128
+ });
71
129
  });
72
130
 
73
131
  describe('#getRequestBody', () => {
74
132
  it('for _PERSONAL_ROOM_', () => {
75
133
  const res = MeetingInfoUtil.getRequestBody({
76
134
  type: _PERSONAL_ROOM_,
77
- destination: 'userId_1234'
135
+ destination: {
136
+ userId: '01824b9b-adef-4b10-b5c1-8a2fe2fb7c0e',
137
+ orgId: '1eb65fdf-9643-417f-9974-ad72cae0e10f'
138
+ }
78
139
  });
79
140
 
80
- assert.equal(res.orgId, '');
81
- assert.equal(res.userId, 'userId_1234');
82
- assert.isTrue(res.supportHostKey);
141
+ assert.equal(res.orgId, '1eb65fdf-9643-417f-9974-ad72cae0e10f');
142
+ assert.equal(res.userId, '01824b9b-adef-4b10-b5c1-8a2fe2fb7c0e');
83
143
  });
84
144
 
85
145
  it('for _MEETING_ID_', () => {