@microsoft/teams-js 1.6.0-beta.6 → 1.6.0

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.
@@ -106,6 +106,8 @@ var GlobalVars = /** @class */ (function () {
106
106
  }
107
107
  GlobalVars.initializeCalled = false;
108
108
  GlobalVars.initializeCompleted = false;
109
+ GlobalVars.additionalValidOrigins = [];
110
+ GlobalVars.additionalValidOriginsRegexp = null;
109
111
  GlobalVars.initializeCallbacks = [];
110
112
  GlobalVars.isFramelessWindow = false;
111
113
  GlobalVars.parentMessageQueue = [];
@@ -129,6 +131,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
129
131
  var publicAPIs_1 = __webpack_require__(4);
130
132
  var constants_1 = __webpack_require__(2);
131
133
  var globalVars_1 = __webpack_require__(0);
134
+ var utils_1 = __webpack_require__(3);
132
135
  // ::::::::::::::::::::MicrosoftTeams SDK Internal :::::::::::::::::
133
136
  globalVars_1.GlobalVars.handlers['themeChange'] = handleThemeChange;
134
137
  globalVars_1.GlobalVars.handlers['fullScreenChange'] = handleFullScreenChange;
@@ -163,7 +166,7 @@ function handleThemeChange(theme) {
163
166
  globalVars_1.GlobalVars.themeChangeHandler(theme);
164
167
  }
165
168
  if (globalVars_1.GlobalVars.childWindow) {
166
- sendMessageRequest(globalVars_1.GlobalVars.childWindow, 'themeChange', [theme]);
169
+ sendMessageEventToChild('themeChange', [theme]);
167
170
  }
168
171
  }
169
172
  function handleFullScreenChange(isFullScreen) {
@@ -181,12 +184,12 @@ function handleLoad(context) {
181
184
  globalVars_1.GlobalVars.loadHandler(context);
182
185
  }
183
186
  if (globalVars_1.GlobalVars.childWindow) {
184
- sendMessageRequest(globalVars_1.GlobalVars.childWindow, 'load', [context]);
187
+ sendMessageEventToChild('load', [context]);
185
188
  }
186
189
  }
187
190
  function handleBeforeUnload() {
188
191
  var readyToUnload = function () {
189
- sendMessageRequest(globalVars_1.GlobalVars.parentWindow, 'readyToUnload', []);
192
+ sendMessageRequestToParent('readyToUnload', []);
190
193
  };
191
194
  if (!globalVars_1.GlobalVars.beforeUnloadHandler || !globalVars_1.GlobalVars.beforeUnloadHandler(readyToUnload)) {
192
195
  readyToUnload();
@@ -225,10 +228,10 @@ function processMessage(evt) {
225
228
  return;
226
229
  }
227
230
  // Process only if the message is coming from a different window and a valid origin
228
- var messageSource = evt.source || evt.originalEvent.source;
229
- var messageOrigin = evt.origin || evt.originalEvent.origin;
230
- if (messageSource === globalVars_1.GlobalVars.currentWindow ||
231
- (messageOrigin !== globalVars_1.GlobalVars.currentWindow.location.origin && !constants_1.validOriginRegExp.test(messageOrigin.toLowerCase()))) {
231
+ // valid origins are either a pre-known
232
+ var messageSource = evt.source || (evt.originalEvent && evt.originalEvent.source);
233
+ var messageOrigin = evt.origin || (evt.originalEvent && evt.originalEvent.origin);
234
+ if (!shouldProcessMessage(messageSource, messageOrigin)) {
232
235
  return;
233
236
  }
234
237
  // Update our parent and child relationships based on this message
@@ -242,6 +245,28 @@ function processMessage(evt) {
242
245
  }
243
246
  }
244
247
  exports.processMessage = processMessage;
248
+ /**
249
+ * Validates the message source and origin, if it should be processed
250
+ */
251
+ function shouldProcessMessage(messageSource, messageOrigin) {
252
+ // Process if message source is a different window and if origin is either in
253
+ // Teams' pre-known whitelist or supplied as valid origin by user during initialization
254
+ if (globalVars_1.GlobalVars.currentWindow && messageSource === globalVars_1.GlobalVars.currentWindow) {
255
+ return false;
256
+ }
257
+ else if (globalVars_1.GlobalVars.currentWindow &&
258
+ globalVars_1.GlobalVars.currentWindow.location &&
259
+ messageOrigin &&
260
+ messageOrigin === globalVars_1.GlobalVars.currentWindow.location.origin) {
261
+ return true;
262
+ }
263
+ else if (constants_1.validOriginRegExp.test(messageOrigin.toLowerCase()) ||
264
+ (globalVars_1.GlobalVars.additionalValidOriginsRegexp &&
265
+ globalVars_1.GlobalVars.additionalValidOriginsRegexp.test(messageOrigin.toLowerCase()))) {
266
+ return true;
267
+ }
268
+ return false;
269
+ }
245
270
  function updateRelationships(messageSource, messageOrigin) {
246
271
  // Determine whether the source of the message is our parent or child and update our
247
272
  // window and origin pointer accordingly
@@ -267,7 +292,7 @@ function updateRelationships(messageSource, messageOrigin) {
267
292
  flushMessageQueue(globalVars_1.GlobalVars.childWindow);
268
293
  }
269
294
  function handleParentMessage(evt) {
270
- if ('id' in evt.data) {
295
+ if ('id' in evt.data && typeof evt.data.id === 'number') {
271
296
  // Call any associated GlobalVars.callbacks
272
297
  var message = evt.data;
273
298
  var callback = globalVars_1.GlobalVars.callbacks[message.id];
@@ -277,7 +302,7 @@ function handleParentMessage(evt) {
277
302
  delete globalVars_1.GlobalVars.callbacks[message.id];
278
303
  }
279
304
  }
280
- else if ('func' in evt.data) {
305
+ else if ('func' in evt.data && typeof evt.data.func === 'string') {
281
306
  // Delegate the request to the proper handler
282
307
  var message = evt.data;
283
308
  var handler = globalVars_1.GlobalVars.handlers[message.func];
@@ -290,18 +315,18 @@ function handleParentMessage(evt) {
290
315
  exports.handleParentMessage = handleParentMessage;
291
316
  function handleChildMessage(evt) {
292
317
  if ('id' in evt.data && 'func' in evt.data) {
293
- // Try to delegate the request to the proper handler
318
+ // Try to delegate the request to the proper handler, if defined
294
319
  var message_1 = evt.data;
295
- var handler = globalVars_1.GlobalVars.handlers[message_1.func];
320
+ var handler = message_1.func ? globalVars_1.GlobalVars.handlers[message_1.func] : null;
296
321
  if (handler) {
297
322
  var result = handler.apply(this, message_1.args);
298
- if (result) {
299
- sendMessageResponse(globalVars_1.GlobalVars.childWindow, message_1.id, Array.isArray(result) ? result : [result]);
323
+ if (typeof result !== 'undefined') {
324
+ sendMessageResponseToChild(message_1.id, Array.isArray(result) ? result : [result]);
300
325
  }
301
326
  }
302
327
  else {
303
- // Proxy to parent
304
- var messageId = sendMessageRequest(globalVars_1.GlobalVars.parentWindow, message_1.func, message_1.args);
328
+ // No handler, proxy to parent
329
+ var messageId = sendMessageRequestToParent(message_1.func, message_1.args);
305
330
  // tslint:disable-next-line:no-any
306
331
  globalVars_1.GlobalVars.callbacks[messageId] = function () {
307
332
  var args = [];
@@ -309,12 +334,37 @@ function handleChildMessage(evt) {
309
334
  args[_i] = arguments[_i];
310
335
  }
311
336
  if (globalVars_1.GlobalVars.childWindow) {
312
- sendMessageResponse(globalVars_1.GlobalVars.childWindow, message_1.id, args);
337
+ sendMessageResponseToChild(message_1.id, args);
313
338
  }
314
339
  };
315
340
  }
316
341
  }
317
342
  }
343
+ /**
344
+ * Processes the valid origins specifuied by the user, de-duplicates and converts them into a regexp
345
+ * which is used later for message source/origin validation
346
+ */
347
+ function processAdditionalValidOrigins(validMessageOrigins) {
348
+ var combinedOriginUrls = globalVars_1.GlobalVars.additionalValidOrigins.concat(validMessageOrigins.filter(function (_origin) {
349
+ return typeof _origin === 'string' && constants_1.userOriginUrlValidationRegExp.test(_origin);
350
+ }));
351
+ var dedupUrls = {};
352
+ combinedOriginUrls = combinedOriginUrls.filter(function (_originUrl) {
353
+ if (dedupUrls[_originUrl]) {
354
+ return false;
355
+ }
356
+ dedupUrls[_originUrl] = true;
357
+ return true;
358
+ });
359
+ globalVars_1.GlobalVars.additionalValidOrigins = combinedOriginUrls;
360
+ if (globalVars_1.GlobalVars.additionalValidOrigins.length > 0) {
361
+ globalVars_1.GlobalVars.additionalValidOriginsRegexp = utils_1.generateRegExpFromUrls(globalVars_1.GlobalVars.additionalValidOrigins);
362
+ }
363
+ else {
364
+ globalVars_1.GlobalVars.additionalValidOriginsRegexp = null;
365
+ }
366
+ }
367
+ exports.processAdditionalValidOrigins = processAdditionalValidOrigins;
318
368
  function getTargetMessageQueue(targetWindow) {
319
369
  return targetWindow === globalVars_1.GlobalVars.parentWindow
320
370
  ? globalVars_1.GlobalVars.parentMessageQueue
@@ -345,9 +395,13 @@ function waitForMessageQueue(targetWindow, callback) {
345
395
  }, 100);
346
396
  }
347
397
  exports.waitForMessageQueue = waitForMessageQueue;
348
- function sendMessageRequest(targetWindow, actionName,
398
+ /**
399
+ * Send a message to parent. Uses nativeInterface on mobile to communicate with parent context
400
+ */
401
+ function sendMessageRequestToParent(actionName,
349
402
  // tslint:disable-next-line: no-any
350
403
  args) {
404
+ var targetWindow = globalVars_1.GlobalVars.parentWindow;
351
405
  var request = createMessageRequest(actionName, args);
352
406
  if (globalVars_1.GlobalVars.isFramelessWindow) {
353
407
  if (globalVars_1.GlobalVars.currentWindow && globalVars_1.GlobalVars.currentWindow.nativeInterface) {
@@ -367,16 +421,40 @@ args) {
367
421
  }
368
422
  return request.id;
369
423
  }
370
- exports.sendMessageRequest = sendMessageRequest;
371
- function sendMessageResponse(targetWindow, id,
424
+ exports.sendMessageRequestToParent = sendMessageRequestToParent;
425
+ /**
426
+ * Send a response to child for a message request that was from child
427
+ */
428
+ function sendMessageResponseToChild(id,
372
429
  // tslint:disable-next-line:no-any
373
430
  args) {
431
+ var targetWindow = globalVars_1.GlobalVars.childWindow;
374
432
  var response = createMessageResponse(id, args);
375
433
  var targetOrigin = getTargetOrigin(targetWindow);
376
434
  if (targetWindow && targetOrigin) {
377
435
  targetWindow.postMessage(response, targetOrigin);
378
436
  }
379
437
  }
438
+ /**
439
+ * Send a custom message object that can be sent to child window,
440
+ * instead of a response message to a child
441
+ */
442
+ function sendMessageEventToChild(actionName,
443
+ // tslint:disable-next-line: no-any
444
+ args) {
445
+ var targetWindow = globalVars_1.GlobalVars.childWindow;
446
+ var customEvent = createMessageEvent(actionName, args);
447
+ var targetOrigin = getTargetOrigin(targetWindow);
448
+ // If the target window isn't closed and we already know its origin, send the message right away; otherwise,
449
+ // queue the message and send it after the origin is established
450
+ if (targetWindow && targetOrigin) {
451
+ targetWindow.postMessage(customEvent, targetOrigin);
452
+ }
453
+ else {
454
+ getTargetMessageQueue(targetWindow).push(customEvent);
455
+ }
456
+ }
457
+ exports.sendMessageEventToChild = sendMessageEventToChild;
380
458
  // tslint:disable-next-line:no-any
381
459
  function createMessageRequest(func, args) {
382
460
  return {
@@ -392,6 +470,16 @@ function createMessageResponse(id, args) {
392
470
  args: args || [],
393
471
  };
394
472
  }
473
+ /**
474
+ * Creates a message object without any id, used for custom actions being sent to child frame/window
475
+ */
476
+ // tslint:disable-next-line:no-any
477
+ function createMessageEvent(func, args) {
478
+ return {
479
+ func: func,
480
+ args: args || [],
481
+ };
482
+ }
395
483
 
396
484
 
397
485
  /***/ }),
@@ -402,7 +490,7 @@ function createMessageResponse(id, args) {
402
490
 
403
491
  Object.defineProperty(exports, "__esModule", { value: true });
404
492
  var utils_1 = __webpack_require__(3);
405
- exports.version = '1.4.1';
493
+ exports.version = '1.6.0';
406
494
  exports.validOrigins = [
407
495
  'https://teams.microsoft.com',
408
496
  'https://teams.microsoft.us',
@@ -411,14 +499,15 @@ exports.validOrigins = [
411
499
  'https://int.teams.microsoft.com',
412
500
  'https://devspaces.skype.com',
413
501
  'https://ssauth.skype.com',
414
- 'http://dev.local',
415
- 'http://dev.local:8080',
502
+ 'https://local.teams.office.com',
503
+ 'https://local.teams.office.com:8080',
416
504
  'https://msft.spoppe.com',
417
505
  'https://*.sharepoint.com',
418
506
  'https://*.sharepoint-df.com',
419
507
  'https://*.sharepointonline.com',
420
508
  'https://outlook.office.com',
421
509
  'https://outlook-sdf.office.com',
510
+ 'https://*.teams.microsoft.com',
422
511
  ];
423
512
  // Ensure these declarations stay in sync with the framework.
424
513
  exports.frameContexts = {
@@ -429,6 +518,10 @@ exports.frameContexts = {
429
518
  task: 'task',
430
519
  };
431
520
  exports.validOriginRegExp = utils_1.generateRegExpFromUrls(exports.validOrigins);
521
+ /**
522
+ * USer specified message origins should satisfy this test
523
+ */
524
+ exports.userOriginUrlValidationRegExp = /^https\:\/\//;
432
525
 
433
526
 
434
527
  /***/ }),
@@ -484,8 +577,11 @@ var logs_1 = __webpack_require__(6);
484
577
  /**
485
578
  * Initializes the library. This must be called before any other SDK calls
486
579
  * but after the frame is loaded successfully.
580
+ * @param callback Optionally specify a callback to invoke when Teams SDK has successfully initialized
581
+ * @param validMessageOrigins Optionally specify a list of cross frame message origins. There must have
582
+ * https: protocol otherwise they will be ignored. Example: https://www.example.com
487
583
  */
488
- function initialize(callback) {
584
+ function initialize(callback, validMessageOrigins) {
489
585
  // Independent components might not know whether the SDK is initialized so might call it to be safe.
490
586
  // Just no-op if that happens to make it easier to use.
491
587
  if (!globalVars_1.GlobalVars.initializeCalled) {
@@ -511,7 +607,7 @@ function initialize(callback) {
511
607
  // Send the initialized message to any origin, because at this point we most likely don't know the origin
512
608
  // of the parent window, and this message contains no data that could pose a security risk.
513
609
  globalVars_1.GlobalVars.parentOrigin = '*';
514
- var messageId = internalAPIs_1.sendMessageRequest(globalVars_1.GlobalVars.parentWindow, 'initialize', [constants_1.version]);
610
+ var messageId = internalAPIs_1.sendMessageRequestToParent('initialize', [constants_1.version]);
515
611
  globalVars_1.GlobalVars.callbacks[messageId] = function (context, clientType) {
516
612
  globalVars_1.GlobalVars.frameContext = context;
517
613
  globalVars_1.GlobalVars.hostClientType = clientType;
@@ -546,6 +642,7 @@ function initialize(callback) {
546
642
  globalVars_1.GlobalVars.initializeCalled = false;
547
643
  globalVars_1.GlobalVars.initializeCompleted = false;
548
644
  globalVars_1.GlobalVars.initializeCallbacks = [];
645
+ globalVars_1.GlobalVars.additionalValidOrigins = [];
549
646
  globalVars_1.GlobalVars.parentWindow = null;
550
647
  globalVars_1.GlobalVars.parentOrigin = null;
551
648
  globalVars_1.GlobalVars.parentMessageQueue = [];
@@ -559,6 +656,10 @@ function initialize(callback) {
559
656
  globalVars_1.GlobalVars.isFramelessWindow = false;
560
657
  };
561
658
  }
659
+ // Handle additional valid message origins if specified
660
+ if (Array.isArray(validMessageOrigins)) {
661
+ internalAPIs_1.processAdditionalValidOrigins(validMessageOrigins);
662
+ }
562
663
  // Handle the callback if specified:
563
664
  // 1. If initialization has already completed then just call it right away
564
665
  // 2. If initialization hasn't completed then add it to the array of callbacks
@@ -618,7 +719,7 @@ exports.print = print;
618
719
  */
619
720
  function getContext(callback) {
620
721
  internalAPIs_1.ensureInitialized();
621
- var messageId = internalAPIs_1.sendMessageRequest(globalVars_1.GlobalVars.parentWindow, 'getContext');
722
+ var messageId = internalAPIs_1.sendMessageRequestToParent('getContext');
622
723
  globalVars_1.GlobalVars.callbacks[messageId] = callback;
623
724
  }
624
725
  exports.getContext = getContext;
@@ -630,7 +731,7 @@ exports.getContext = getContext;
630
731
  function registerOnThemeChangeHandler(handler) {
631
732
  internalAPIs_1.ensureInitialized();
632
733
  globalVars_1.GlobalVars.themeChangeHandler = handler;
633
- handler && internalAPIs_1.sendMessageRequest(globalVars_1.GlobalVars.parentWindow, 'registerHandler', ['themeChange']);
734
+ handler && internalAPIs_1.sendMessageRequestToParent('registerHandler', ['themeChange']);
634
735
  }
635
736
  exports.registerOnThemeChangeHandler = registerOnThemeChangeHandler;
636
737
  /**
@@ -641,7 +742,7 @@ exports.registerOnThemeChangeHandler = registerOnThemeChangeHandler;
641
742
  function registerFullScreenHandler(handler) {
642
743
  internalAPIs_1.ensureInitialized();
643
744
  globalVars_1.GlobalVars.fullScreenChangeHandler = handler;
644
- handler && internalAPIs_1.sendMessageRequest(globalVars_1.GlobalVars.parentWindow, 'registerHandler', ['fullScreen']);
745
+ handler && internalAPIs_1.sendMessageRequestToParent('registerHandler', ['fullScreen']);
645
746
  }
646
747
  exports.registerFullScreenHandler = registerFullScreenHandler;
647
748
  /**
@@ -654,7 +755,7 @@ exports.registerFullScreenHandler = registerFullScreenHandler;
654
755
  function registerBackButtonHandler(handler) {
655
756
  internalAPIs_1.ensureInitialized();
656
757
  globalVars_1.GlobalVars.backButtonPressHandler = handler;
657
- handler && internalAPIs_1.sendMessageRequest(globalVars_1.GlobalVars.parentWindow, 'registerHandler', ['backButton']);
758
+ handler && internalAPIs_1.sendMessageRequestToParent('registerHandler', ['backButton']);
658
759
  }
659
760
  exports.registerBackButtonHandler = registerBackButtonHandler;
660
761
  /**
@@ -663,7 +764,7 @@ exports.registerBackButtonHandler = registerBackButtonHandler;
663
764
  */
664
765
  function navigateBack(onComplete) {
665
766
  internalAPIs_1.ensureInitialized();
666
- var messageId = internalAPIs_1.sendMessageRequest(globalVars_1.GlobalVars.parentWindow, 'navigateBack', []);
767
+ var messageId = internalAPIs_1.sendMessageRequestToParent('navigateBack', []);
667
768
  var errorMessage = 'Back navigation is not supported in the current client or context.';
668
769
  globalVars_1.GlobalVars.callbacks[messageId] = onComplete ? onComplete : utils_1.getGenericOnCompleteHandler(errorMessage);
669
770
  }
@@ -676,7 +777,7 @@ exports.navigateBack = navigateBack;
676
777
  function registerOnLoadHandler(handler) {
677
778
  internalAPIs_1.ensureInitialized();
678
779
  globalVars_1.GlobalVars.loadHandler = handler;
679
- handler && internalAPIs_1.sendMessageRequest(globalVars_1.GlobalVars.parentWindow, 'registerHandler', ['load']);
780
+ handler && internalAPIs_1.sendMessageRequestToParent('registerHandler', ['load']);
680
781
  }
681
782
  exports.registerOnLoadHandler = registerOnLoadHandler;
682
783
  /**
@@ -688,7 +789,7 @@ exports.registerOnLoadHandler = registerOnLoadHandler;
688
789
  function registerBeforeUnloadHandler(handler) {
689
790
  internalAPIs_1.ensureInitialized();
690
791
  globalVars_1.GlobalVars.beforeUnloadHandler = handler;
691
- handler && internalAPIs_1.sendMessageRequest(globalVars_1.GlobalVars.parentWindow, 'registerHandler', ['beforeUnload']);
792
+ handler && internalAPIs_1.sendMessageRequestToParent('registerHandler', ['beforeUnload']);
692
793
  }
693
794
  exports.registerBeforeUnloadHandler = registerBeforeUnloadHandler;
694
795
  /**
@@ -698,7 +799,7 @@ exports.registerBeforeUnloadHandler = registerBeforeUnloadHandler;
698
799
  function registerChangeSettingsHandler(handler) {
699
800
  internalAPIs_1.ensureInitialized(constants_1.frameContexts.content);
700
801
  globalVars_1.GlobalVars.changeSettingsHandler = handler;
701
- handler && internalAPIs_1.sendMessageRequest(globalVars_1.GlobalVars.parentWindow, 'registerHandler', ['changeSettings']);
802
+ handler && internalAPIs_1.sendMessageRequestToParent('registerHandler', ['changeSettings']);
702
803
  }
703
804
  exports.registerChangeSettingsHandler = registerChangeSettingsHandler;
704
805
  /**
@@ -711,7 +812,7 @@ exports.registerChangeSettingsHandler = registerChangeSettingsHandler;
711
812
  */
712
813
  function navigateCrossDomain(url, onComplete) {
713
814
  internalAPIs_1.ensureInitialized(constants_1.frameContexts.content, constants_1.frameContexts.settings, constants_1.frameContexts.remove, constants_1.frameContexts.task);
714
- var messageId = internalAPIs_1.sendMessageRequest(globalVars_1.GlobalVars.parentWindow, 'navigateCrossDomain', [url]);
815
+ var messageId = internalAPIs_1.sendMessageRequestToParent('navigateCrossDomain', [url]);
715
816
  var errorMessage = 'Cross-origin navigation is only supported for URLs matching the pattern registered in the manifest.';
716
817
  globalVars_1.GlobalVars.callbacks[messageId] = onComplete ? onComplete : utils_1.getGenericOnCompleteHandler(errorMessage);
717
818
  }
@@ -724,7 +825,7 @@ exports.navigateCrossDomain = navigateCrossDomain;
724
825
  */
725
826
  function getTabInstances(callback, tabInstanceParameters) {
726
827
  internalAPIs_1.ensureInitialized();
727
- var messageId = internalAPIs_1.sendMessageRequest(globalVars_1.GlobalVars.parentWindow, 'getTabInstances', [tabInstanceParameters]);
828
+ var messageId = internalAPIs_1.sendMessageRequestToParent('getTabInstances', [tabInstanceParameters]);
728
829
  globalVars_1.GlobalVars.callbacks[messageId] = callback;
729
830
  }
730
831
  exports.getTabInstances = getTabInstances;
@@ -735,7 +836,7 @@ exports.getTabInstances = getTabInstances;
735
836
  */
736
837
  function getMruTabInstances(callback, tabInstanceParameters) {
737
838
  internalAPIs_1.ensureInitialized();
738
- var messageId = internalAPIs_1.sendMessageRequest(globalVars_1.GlobalVars.parentWindow, 'getMruTabInstances', [tabInstanceParameters]);
839
+ var messageId = internalAPIs_1.sendMessageRequestToParent('getMruTabInstances', [tabInstanceParameters]);
739
840
  globalVars_1.GlobalVars.callbacks[messageId] = callback;
740
841
  }
741
842
  exports.getMruTabInstances = getMruTabInstances;
@@ -745,7 +846,7 @@ exports.getMruTabInstances = getMruTabInstances;
745
846
  */
746
847
  function shareDeepLink(deepLinkParameters) {
747
848
  internalAPIs_1.ensureInitialized(constants_1.frameContexts.content);
748
- internalAPIs_1.sendMessageRequest(globalVars_1.GlobalVars.parentWindow, 'shareDeepLink', [
849
+ internalAPIs_1.sendMessageRequestToParent('shareDeepLink', [
749
850
  deepLinkParameters.subEntityId,
750
851
  deepLinkParameters.subEntityLabel,
751
852
  deepLinkParameters.subEntityWebUrl,
@@ -758,7 +859,7 @@ exports.shareDeepLink = shareDeepLink;
758
859
  */
759
860
  function executeDeepLink(deepLink, onComplete) {
760
861
  internalAPIs_1.ensureInitialized(constants_1.frameContexts.content, constants_1.frameContexts.task);
761
- var messageId = internalAPIs_1.sendMessageRequest(globalVars_1.GlobalVars.parentWindow, 'executeDeepLink', [deepLink]);
862
+ var messageId = internalAPIs_1.sendMessageRequestToParent('executeDeepLink', [deepLink]);
762
863
  globalVars_1.GlobalVars.callbacks[messageId] = onComplete ? onComplete : utils_1.getGenericOnCompleteHandler();
763
864
  }
764
865
  exports.executeDeepLink = executeDeepLink;
@@ -768,11 +869,21 @@ exports.executeDeepLink = executeDeepLink;
768
869
  */
769
870
  function navigateToTab(tabInstance, onComplete) {
770
871
  internalAPIs_1.ensureInitialized();
771
- var messageId = internalAPIs_1.sendMessageRequest(globalVars_1.GlobalVars.parentWindow, 'navigateToTab', [tabInstance]);
872
+ var messageId = internalAPIs_1.sendMessageRequestToParent('navigateToTab', [tabInstance]);
772
873
  var errorMessage = 'Invalid internalTabInstanceId and/or channelId were/was provided';
773
874
  globalVars_1.GlobalVars.callbacks[messageId] = onComplete ? onComplete : utils_1.getGenericOnCompleteHandler(errorMessage);
774
875
  }
775
876
  exports.navigateToTab = navigateToTab;
877
+ function setFrameContext(frameContext) {
878
+ internalAPIs_1.ensureInitialized(constants_1.frameContexts.content);
879
+ internalAPIs_1.sendMessageRequestToParent('setFrameContext', [frameContext]);
880
+ }
881
+ exports.setFrameContext = setFrameContext;
882
+ function initializeWithFrameContext(frameContext, callback, validMessageOrigins) {
883
+ initialize(callback, validMessageOrigins);
884
+ setFrameContext(frameContext);
885
+ }
886
+ exports.initializeWithFrameContext = initializeWithFrameContext;
776
887
 
777
888
 
778
889
  /***/ }),
@@ -803,7 +914,7 @@ var settings;
803
914
  */
804
915
  function setValidityState(validityState) {
805
916
  internalAPIs_1.ensureInitialized(constants_1.frameContexts.settings, constants_1.frameContexts.remove);
806
- internalAPIs_1.sendMessageRequest(globalVars_1.GlobalVars.parentWindow, 'settings.setValidityState', [validityState]);
917
+ internalAPIs_1.sendMessageRequestToParent('settings.setValidityState', [validityState]);
807
918
  }
808
919
  settings.setValidityState = setValidityState;
809
920
  /**
@@ -812,7 +923,7 @@ var settings;
812
923
  */
813
924
  function getSettings(callback) {
814
925
  internalAPIs_1.ensureInitialized(constants_1.frameContexts.content, constants_1.frameContexts.settings, constants_1.frameContexts.remove);
815
- var messageId = internalAPIs_1.sendMessageRequest(globalVars_1.GlobalVars.parentWindow, 'settings.getSettings');
926
+ var messageId = internalAPIs_1.sendMessageRequestToParent('settings.getSettings');
816
927
  globalVars_1.GlobalVars.callbacks[messageId] = callback;
817
928
  }
818
929
  settings.getSettings = getSettings;
@@ -823,7 +934,7 @@ var settings;
823
934
  */
824
935
  function setSettings(instanceSettings, onComplete) {
825
936
  internalAPIs_1.ensureInitialized(constants_1.frameContexts.content, constants_1.frameContexts.settings);
826
- var messageId = internalAPIs_1.sendMessageRequest(globalVars_1.GlobalVars.parentWindow, 'settings.setSettings', [instanceSettings]);
937
+ var messageId = internalAPIs_1.sendMessageRequestToParent('settings.setSettings', [instanceSettings]);
827
938
  globalVars_1.GlobalVars.callbacks[messageId] = onComplete ? onComplete : utils_1.getGenericOnCompleteHandler();
828
939
  }
829
940
  settings.setSettings = setSettings;
@@ -837,7 +948,7 @@ var settings;
837
948
  function registerOnSaveHandler(handler) {
838
949
  internalAPIs_1.ensureInitialized(constants_1.frameContexts.settings);
839
950
  saveHandler = handler;
840
- handler && internalAPIs_1.sendMessageRequest(globalVars_1.GlobalVars.parentWindow, 'registerHandler', ['save']);
951
+ handler && internalAPIs_1.sendMessageRequestToParent('registerHandler', ['save']);
841
952
  }
842
953
  settings.registerOnSaveHandler = registerOnSaveHandler;
843
954
  /**
@@ -850,7 +961,7 @@ var settings;
850
961
  function registerOnRemoveHandler(handler) {
851
962
  internalAPIs_1.ensureInitialized(constants_1.frameContexts.remove);
852
963
  removeHandler = handler;
853
- handler && internalAPIs_1.sendMessageRequest(globalVars_1.GlobalVars.parentWindow, 'registerHandler', ['remove']);
964
+ handler && internalAPIs_1.sendMessageRequestToParent('registerHandler', ['remove']);
854
965
  }
855
966
  settings.registerOnRemoveHandler = registerOnRemoveHandler;
856
967
  function handleSave(result) {
@@ -874,12 +985,12 @@ var settings;
874
985
  }
875
986
  SaveEventImpl.prototype.notifySuccess = function () {
876
987
  this.ensureNotNotified();
877
- internalAPIs_1.sendMessageRequest(globalVars_1.GlobalVars.parentWindow, 'settings.save.success');
988
+ internalAPIs_1.sendMessageRequestToParent('settings.save.success');
878
989
  this.notified = true;
879
990
  };
880
991
  SaveEventImpl.prototype.notifyFailure = function (reason) {
881
992
  this.ensureNotNotified();
882
- internalAPIs_1.sendMessageRequest(globalVars_1.GlobalVars.parentWindow, 'settings.save.failure', [reason]);
993
+ internalAPIs_1.sendMessageRequestToParent('settings.save.failure', [reason]);
883
994
  this.notified = true;
884
995
  };
885
996
  SaveEventImpl.prototype.ensureNotNotified = function () {
@@ -909,12 +1020,12 @@ var settings;
909
1020
  }
910
1021
  RemoveEventImpl.prototype.notifySuccess = function () {
911
1022
  this.ensureNotNotified();
912
- internalAPIs_1.sendMessageRequest(globalVars_1.GlobalVars.parentWindow, 'settings.remove.success');
1023
+ internalAPIs_1.sendMessageRequestToParent('settings.remove.success');
913
1024
  this.notified = true;
914
1025
  };
915
1026
  RemoveEventImpl.prototype.notifyFailure = function (reason) {
916
1027
  this.ensureNotNotified();
917
- internalAPIs_1.sendMessageRequest(globalVars_1.GlobalVars.parentWindow, 'settings.remove.failure', [reason]);
1028
+ internalAPIs_1.sendMessageRequestToParent('settings.remove.failure', [reason]);
918
1029
  this.notified = true;
919
1030
  };
920
1031
  RemoveEventImpl.prototype.ensureNotNotified = function () {
@@ -949,7 +1060,7 @@ var logs;
949
1060
  function handleGetLogRequest() {
950
1061
  if (globalVars_1.GlobalVars.getLogHandler) {
951
1062
  var log = globalVars_1.GlobalVars.getLogHandler();
952
- internalAPIs_1.sendMessageRequest(globalVars_1.GlobalVars.parentWindow, 'log.receive', [log]);
1063
+ internalAPIs_1.sendMessageRequestToParent('log.receive', [log]);
953
1064
  }
954
1065
  }
955
1066
  /**
@@ -962,7 +1073,7 @@ var logs;
962
1073
  function registerGetLogHandler(handler) {
963
1074
  internalAPIs_1.ensureInitialized();
964
1075
  globalVars_1.GlobalVars.getLogHandler = handler;
965
- handler && internalAPIs_1.sendMessageRequest(globalVars_1.GlobalVars.parentWindow, 'registerHandler', ['log.request']);
1076
+ handler && internalAPIs_1.sendMessageRequestToParent('registerHandler', ['log.request']);
966
1077
  }
967
1078
  logs.registerGetLogHandler = registerGetLogHandler;
968
1079
  })(logs = exports.logs || (exports.logs = {}));
@@ -984,7 +1095,7 @@ var ChildAppWindow = /** @class */ (function () {
984
1095
  }
985
1096
  ChildAppWindow.prototype.postMessage = function (message, onComplete) {
986
1097
  internalAPIs_1.ensureInitialized();
987
- var messageId = internalAPIs_1.sendMessageRequest(globalVars_1.GlobalVars.parentWindow, 'messageForChild', [message]);
1098
+ var messageId = internalAPIs_1.sendMessageRequestToParent('messageForChild', [message]);
988
1099
  globalVars_1.GlobalVars.callbacks[messageId] = onComplete ? onComplete : utils_1.getGenericOnCompleteHandler();
989
1100
  };
990
1101
  ChildAppWindow.prototype.addEventListener = function (type, listener) {
@@ -1008,7 +1119,7 @@ var ParentAppWindow = /** @class */ (function () {
1008
1119
  });
1009
1120
  ParentAppWindow.prototype.postMessage = function (message, onComplete) {
1010
1121
  internalAPIs_1.ensureInitialized(constants_1.frameContexts.task);
1011
- var messageId = internalAPIs_1.sendMessageRequest(globalVars_1.GlobalVars.parentWindow, 'messageForParent', [message]);
1122
+ var messageId = internalAPIs_1.sendMessageRequestToParent('messageForParent', [message]);
1012
1123
  globalVars_1.GlobalVars.callbacks[messageId] = onComplete ? onComplete : utils_1.getGenericOnCompleteHandler();
1013
1124
  };
1014
1125
  ParentAppWindow.prototype.addEventListener = function (type, listener) {
@@ -1057,6 +1168,8 @@ exports.getUserJoinedTeams = privateAPIs_1.getUserJoinedTeams;
1057
1168
  exports.openFilePreview = privateAPIs_1.openFilePreview;
1058
1169
  exports.sendCustomMessage = privateAPIs_1.sendCustomMessage;
1059
1170
  exports.showNotification = privateAPIs_1.showNotification;
1171
+ exports.sendCustomEvent = privateAPIs_1.sendCustomEvent;
1172
+ exports.registerCustomHandler = privateAPIs_1.registerCustomHandler;
1060
1173
  exports.uploadCustomApp = privateAPIs_1.uploadCustomApp;
1061
1174
  var conversations_1 = __webpack_require__(13);
1062
1175
  exports.conversations = conversations_1.conversations;
@@ -1088,7 +1201,7 @@ var bot;
1088
1201
  */
1089
1202
  function sendQuery(botRequest, onSuccess, onError) {
1090
1203
  internalAPIs_1.ensureInitialized();
1091
- var messageId = internalAPIs_1.sendMessageRequest(globalVars_1.GlobalVars.parentWindow, 'bot.executeQuery', [botRequest]);
1204
+ var messageId = internalAPIs_1.sendMessageRequestToParent('bot.executeQuery', [botRequest]);
1092
1205
  globalVars_1.GlobalVars.callbacks[messageId] = function (success, response) {
1093
1206
  if (success) {
1094
1207
  onSuccess(response);
@@ -1109,7 +1222,7 @@ var bot;
1109
1222
  */
1110
1223
  function getSupportedCommands(onSuccess, onError) {
1111
1224
  internalAPIs_1.ensureInitialized();
1112
- var messageId = internalAPIs_1.sendMessageRequest(globalVars_1.GlobalVars.parentWindow, 'bot.getSupportedCommands');
1225
+ var messageId = internalAPIs_1.sendMessageRequestToParent('bot.getSupportedCommands');
1113
1226
  globalVars_1.GlobalVars.callbacks[messageId] = function (success, response) {
1114
1227
  if (success) {
1115
1228
  onSuccess(response);
@@ -1131,7 +1244,7 @@ var bot;
1131
1244
  */
1132
1245
  function authenticate(authRequest, onSuccess, onError) {
1133
1246
  internalAPIs_1.ensureInitialized();
1134
- var messageId = internalAPIs_1.sendMessageRequest(globalVars_1.GlobalVars.parentWindow, 'bot.authenticate', [authRequest]);
1247
+ var messageId = internalAPIs_1.sendMessageRequestToParent('bot.authenticate', [authRequest]);
1135
1248
  globalVars_1.GlobalVars.callbacks[messageId] = function (success, response) {
1136
1249
  if (success) {
1137
1250
  onSuccess(response);
@@ -1204,13 +1317,13 @@ var menus;
1204
1317
  function setUpViews(viewConfig, handler) {
1205
1318
  internalAPIs_1.ensureInitialized();
1206
1319
  viewConfigItemPressHandler = handler;
1207
- internalAPIs_1.sendMessageRequest(globalVars_1.GlobalVars.parentWindow, 'setUpViews', [viewConfig]);
1320
+ internalAPIs_1.sendMessageRequestToParent('setUpViews', [viewConfig]);
1208
1321
  }
1209
1322
  menus.setUpViews = setUpViews;
1210
1323
  function handleViewConfigItemPress(id) {
1211
1324
  if (!viewConfigItemPressHandler || !viewConfigItemPressHandler(id)) {
1212
1325
  internalAPIs_1.ensureInitialized();
1213
- internalAPIs_1.sendMessageRequest(globalVars_1.GlobalVars.parentWindow, 'viewConfigItemPress', [id]);
1326
+ internalAPIs_1.sendMessageRequestToParent('viewConfigItemPress', [id]);
1214
1327
  }
1215
1328
  }
1216
1329
  /**
@@ -1221,13 +1334,13 @@ var menus;
1221
1334
  function setNavBarMenu(items, handler) {
1222
1335
  internalAPIs_1.ensureInitialized();
1223
1336
  navBarMenuItemPressHandler = handler;
1224
- internalAPIs_1.sendMessageRequest(globalVars_1.GlobalVars.parentWindow, 'setNavBarMenu', [items]);
1337
+ internalAPIs_1.sendMessageRequestToParent('setNavBarMenu', [items]);
1225
1338
  }
1226
1339
  menus.setNavBarMenu = setNavBarMenu;
1227
1340
  function handleNavBarMenuItemPress(id) {
1228
1341
  if (!navBarMenuItemPressHandler || !navBarMenuItemPressHandler(id)) {
1229
1342
  internalAPIs_1.ensureInitialized();
1230
- internalAPIs_1.sendMessageRequest(globalVars_1.GlobalVars.parentWindow, 'handleNavBarMenuItemPress', [id]);
1343
+ internalAPIs_1.sendMessageRequestToParent('handleNavBarMenuItemPress', [id]);
1231
1344
  }
1232
1345
  }
1233
1346
  /**
@@ -1238,13 +1351,13 @@ var menus;
1238
1351
  function showActionMenu(params, handler) {
1239
1352
  internalAPIs_1.ensureInitialized();
1240
1353
  actionMenuItemPressHandler = handler;
1241
- internalAPIs_1.sendMessageRequest(globalVars_1.GlobalVars.parentWindow, 'showActionMenu', [params]);
1354
+ internalAPIs_1.sendMessageRequestToParent('showActionMenu', [params]);
1242
1355
  }
1243
1356
  menus.showActionMenu = showActionMenu;
1244
1357
  function handleActionMenuItemPress(id) {
1245
1358
  if (!actionMenuItemPressHandler || !actionMenuItemPressHandler(id)) {
1246
1359
  internalAPIs_1.ensureInitialized();
1247
- internalAPIs_1.sendMessageRequest(globalVars_1.GlobalVars.parentWindow, 'handleActionMenuItemPress', [id]);
1360
+ internalAPIs_1.sendMessageRequestToParent('handleActionMenuItemPress', [id]);
1248
1361
  }
1249
1362
  }
1250
1363
  })(menus = exports.menus || (exports.menus = {}));
@@ -1271,7 +1384,7 @@ var utils_1 = __webpack_require__(3);
1271
1384
  */
1272
1385
  function getUserJoinedTeams(callback, teamInstanceParameters) {
1273
1386
  internalAPIs_1.ensureInitialized();
1274
- var messageId = internalAPIs_1.sendMessageRequest(globalVars_1.GlobalVars.parentWindow, 'getUserJoinedTeams', [teamInstanceParameters]);
1387
+ var messageId = internalAPIs_1.sendMessageRequestToParent('getUserJoinedTeams', [teamInstanceParameters]);
1275
1388
  globalVars_1.GlobalVars.callbacks[messageId] = callback;
1276
1389
  }
1277
1390
  exports.getUserJoinedTeams = getUserJoinedTeams;
@@ -1283,7 +1396,7 @@ exports.getUserJoinedTeams = getUserJoinedTeams;
1283
1396
  */
1284
1397
  function enterFullscreen() {
1285
1398
  internalAPIs_1.ensureInitialized(constants_1.frameContexts.content);
1286
- internalAPIs_1.sendMessageRequest(globalVars_1.GlobalVars.parentWindow, 'enterFullscreen', []);
1399
+ internalAPIs_1.sendMessageRequestToParent('enterFullscreen', []);
1287
1400
  }
1288
1401
  exports.enterFullscreen = enterFullscreen;
1289
1402
  /**
@@ -1294,7 +1407,7 @@ exports.enterFullscreen = enterFullscreen;
1294
1407
  */
1295
1408
  function exitFullscreen() {
1296
1409
  internalAPIs_1.ensureInitialized(constants_1.frameContexts.content);
1297
- internalAPIs_1.sendMessageRequest(globalVars_1.GlobalVars.parentWindow, 'exitFullscreen', []);
1410
+ internalAPIs_1.sendMessageRequestToParent('exitFullscreen', []);
1298
1411
  }
1299
1412
  exports.exitFullscreen = exitFullscreen;
1300
1413
  /**
@@ -1319,7 +1432,7 @@ function openFilePreview(filePreviewParameters) {
1319
1432
  filePreviewParameters.editFile,
1320
1433
  filePreviewParameters.subEntityId,
1321
1434
  ];
1322
- internalAPIs_1.sendMessageRequest(globalVars_1.GlobalVars.parentWindow, 'openFilePreview', params);
1435
+ internalAPIs_1.sendMessageRequestToParent('openFilePreview', params);
1323
1436
  }
1324
1437
  exports.openFilePreview = openFilePreview;
1325
1438
  /**
@@ -1333,7 +1446,7 @@ exports.openFilePreview = openFilePreview;
1333
1446
  function showNotification(showNotificationParameters) {
1334
1447
  internalAPIs_1.ensureInitialized(constants_1.frameContexts.content);
1335
1448
  var params = [showNotificationParameters.message, showNotificationParameters.notificationType];
1336
- internalAPIs_1.sendMessageRequest(globalVars_1.GlobalVars.parentWindow, 'showNotification', params);
1449
+ internalAPIs_1.sendMessageRequestToParent('showNotification', params);
1337
1450
  }
1338
1451
  exports.showNotification = showNotification;
1339
1452
  /**
@@ -1345,25 +1458,77 @@ exports.showNotification = showNotification;
1345
1458
  */
1346
1459
  function uploadCustomApp(manifestBlob, onComplete) {
1347
1460
  internalAPIs_1.ensureInitialized();
1348
- var messageId = internalAPIs_1.sendMessageRequest(globalVars_1.GlobalVars.parentWindow, 'uploadCustomApp', [manifestBlob]);
1461
+ var messageId = internalAPIs_1.sendMessageRequestToParent('uploadCustomApp', [manifestBlob]);
1349
1462
  globalVars_1.GlobalVars.callbacks[messageId] = onComplete ? onComplete : utils_1.getGenericOnCompleteHandler();
1350
1463
  }
1351
1464
  exports.uploadCustomApp = uploadCustomApp;
1352
1465
  /**
1353
1466
  * @private
1354
1467
  * Internal use only
1355
- * Sends a custom action message to Teams.
1468
+ * Sends a custom action MessageRequest to Teams or parent window
1356
1469
  * @param actionName Specifies name of the custom action to be sent
1357
1470
  * @param args Specifies additional arguments passed to the action
1471
+ * @param callback Optionally specify a callback to receive response parameters from the parent
1358
1472
  * @returns id of sent message
1359
1473
  */
1360
1474
  function sendCustomMessage(actionName,
1361
1475
  // tslint:disable-next-line:no-any
1362
- args) {
1476
+ args,
1477
+ // tslint:disable-next-line:no-any
1478
+ callback) {
1363
1479
  internalAPIs_1.ensureInitialized();
1364
- return internalAPIs_1.sendMessageRequest(globalVars_1.GlobalVars.parentWindow, actionName, args);
1480
+ var messageId = internalAPIs_1.sendMessageRequestToParent(actionName, args);
1481
+ if (typeof callback === 'function') {
1482
+ globalVars_1.GlobalVars.callbacks[messageId] = function () {
1483
+ var args = [];
1484
+ for (var _i = 0; _i < arguments.length; _i++) {
1485
+ args[_i] = arguments[_i];
1486
+ }
1487
+ callback.apply(null, args);
1488
+ };
1489
+ }
1490
+ return messageId;
1365
1491
  }
1366
1492
  exports.sendCustomMessage = sendCustomMessage;
1493
+ /**
1494
+ * @private
1495
+ * Internal use only
1496
+ * Sends a custom action MessageEvent to a child iframe/window, only if you are not using auth popup.
1497
+ * Otherwise it will go to the auth popup (which becomes the child)
1498
+ * @param actionName Specifies name of the custom action to be sent
1499
+ * @param args Specifies additional arguments passed to the action
1500
+ * @returns id of sent message
1501
+ */
1502
+ function sendCustomEvent(actionName,
1503
+ // tslint:disable-next-line:no-any
1504
+ args) {
1505
+ internalAPIs_1.ensureInitialized();
1506
+ //validate childWindow
1507
+ if (!globalVars_1.GlobalVars.childWindow) {
1508
+ throw new Error('The child window has not yet been initialized or is not present');
1509
+ }
1510
+ internalAPIs_1.sendMessageEventToChild(actionName, args);
1511
+ }
1512
+ exports.sendCustomEvent = sendCustomEvent;
1513
+ /**
1514
+ * @private
1515
+ * Internal use only
1516
+ * Adds a handler for an action sent by a child window or parent window
1517
+ * @param actionName Specifies name of the action message to handle
1518
+ * @param customHandler The callback to invoke when the action message is received. The return value is sent to the child
1519
+ */
1520
+ function registerCustomHandler(actionName, customHandler) {
1521
+ var _this = this;
1522
+ internalAPIs_1.ensureInitialized();
1523
+ globalVars_1.GlobalVars.handlers[actionName] = function () {
1524
+ var args = [];
1525
+ for (var _i = 0; _i < arguments.length; _i++) {
1526
+ args[_i] = arguments[_i];
1527
+ }
1528
+ return customHandler.apply(_this, args);
1529
+ };
1530
+ }
1531
+ exports.registerCustomHandler = registerCustomHandler;
1367
1532
  /**
1368
1533
  * @private
1369
1534
  * Hide from docs
@@ -1375,7 +1540,7 @@ exports.sendCustomMessage = sendCustomMessage;
1375
1540
  */
1376
1541
  function getChatMembers(callback) {
1377
1542
  internalAPIs_1.ensureInitialized();
1378
- var messageId = internalAPIs_1.sendMessageRequest(globalVars_1.GlobalVars.parentWindow, 'getChatMembers');
1543
+ var messageId = internalAPIs_1.sendMessageRequestToParent('getChatMembers');
1379
1544
  globalVars_1.GlobalVars.callbacks[messageId] = callback;
1380
1545
  }
1381
1546
  exports.getChatMembers = getChatMembers;
@@ -1389,7 +1554,7 @@ exports.getChatMembers = getChatMembers;
1389
1554
  */
1390
1555
  function getConfigSetting(callback, key) {
1391
1556
  internalAPIs_1.ensureInitialized();
1392
- var messageId = internalAPIs_1.sendMessageRequest(globalVars_1.GlobalVars.parentWindow, 'getConfigSetting', [key]);
1557
+ var messageId = internalAPIs_1.sendMessageRequestToParent('getConfigSetting', [key]);
1393
1558
  globalVars_1.GlobalVars.callbacks[messageId] = callback;
1394
1559
  }
1395
1560
  exports.getConfigSetting = getConfigSetting;
@@ -1418,7 +1583,7 @@ var conversations;
1418
1583
  */
1419
1584
  function openConversation(openConversationRequest) {
1420
1585
  internalAPIs_1.ensureInitialized(constants_1.frameContexts.content);
1421
- var messageId = internalAPIs_1.sendMessageRequest(globalVars_1.GlobalVars.parentWindow, 'conversations.openConversation', [
1586
+ var messageId = internalAPIs_1.sendMessageRequestToParent('conversations.openConversation', [
1422
1587
  {
1423
1588
  title: openConversationRequest.title,
1424
1589
  subEntityId: openConversationRequest.subEntityId,
@@ -1444,7 +1609,7 @@ var conversations;
1444
1609
  */
1445
1610
  function closeConversation() {
1446
1611
  internalAPIs_1.ensureInitialized(constants_1.frameContexts.content);
1447
- internalAPIs_1.sendMessageRequest(globalVars_1.GlobalVars.parentWindow, 'conversations.closeConversation');
1612
+ internalAPIs_1.sendMessageRequestToParent('conversations.closeConversation');
1448
1613
  globalVars_1.GlobalVars.onCloseConversationHandler = null;
1449
1614
  globalVars_1.GlobalVars.onStartConversationHandler = null;
1450
1615
  }
@@ -1470,6 +1635,7 @@ exports.getContext = publicAPIs_1.getContext;
1470
1635
  exports.getMruTabInstances = publicAPIs_1.getMruTabInstances;
1471
1636
  exports.getTabInstances = publicAPIs_1.getTabInstances;
1472
1637
  exports.initialize = publicAPIs_1.initialize;
1638
+ exports.initializeWithFrameContext = publicAPIs_1.initializeWithFrameContext;
1473
1639
  exports.navigateBack = publicAPIs_1.navigateBack;
1474
1640
  exports.navigateCrossDomain = publicAPIs_1.navigateCrossDomain;
1475
1641
  exports.navigateToTab = publicAPIs_1.navigateToTab;
@@ -1480,6 +1646,7 @@ exports.registerChangeSettingsHandler = publicAPIs_1.registerChangeSettingsHandl
1480
1646
  exports.registerFullScreenHandler = publicAPIs_1.registerFullScreenHandler;
1481
1647
  exports.registerOnLoadHandler = publicAPIs_1.registerOnLoadHandler;
1482
1648
  exports.registerOnThemeChangeHandler = publicAPIs_1.registerOnThemeChangeHandler;
1649
+ exports.setFrameContext = publicAPIs_1.setFrameContext;
1483
1650
  exports.shareDeepLink = publicAPIs_1.shareDeepLink;
1484
1651
  var settings_1 = __webpack_require__(5);
1485
1652
  exports.settings = settings_1.settings;
@@ -1498,7 +1665,6 @@ exports.ParentAppWindow = appWindow_1.ParentAppWindow;
1498
1665
 
1499
1666
  Object.defineProperty(exports, "__esModule", { value: true });
1500
1667
  var internalAPIs_1 = __webpack_require__(1);
1501
- var globalVars_1 = __webpack_require__(0);
1502
1668
  var constants_1 = __webpack_require__(2);
1503
1669
  var appInitialization;
1504
1670
  (function (appInitialization) {
@@ -1507,7 +1673,7 @@ var appInitialization;
1507
1673
  */
1508
1674
  function notifyAppLoaded() {
1509
1675
  internalAPIs_1.ensureInitialized();
1510
- internalAPIs_1.sendMessageRequest(globalVars_1.GlobalVars.parentWindow, 'appInitialization.appLoaded', [constants_1.version]);
1676
+ internalAPIs_1.sendMessageRequestToParent('appInitialization.appLoaded', [constants_1.version]);
1511
1677
  }
1512
1678
  appInitialization.notifyAppLoaded = notifyAppLoaded;
1513
1679
  /**
@@ -1515,7 +1681,7 @@ var appInitialization;
1515
1681
  */
1516
1682
  function notifySuccess() {
1517
1683
  internalAPIs_1.ensureInitialized();
1518
- internalAPIs_1.sendMessageRequest(globalVars_1.GlobalVars.parentWindow, 'appInitialization.success', [constants_1.version]);
1684
+ internalAPIs_1.sendMessageRequestToParent('appInitialization.success', [constants_1.version]);
1519
1685
  }
1520
1686
  appInitialization.notifySuccess = notifySuccess;
1521
1687
  /**
@@ -1523,7 +1689,7 @@ var appInitialization;
1523
1689
  */
1524
1690
  function notifyFailure(appInitializationFailedRequest) {
1525
1691
  internalAPIs_1.ensureInitialized();
1526
- internalAPIs_1.sendMessageRequest(globalVars_1.GlobalVars.parentWindow, 'appInitialization.failure', [
1692
+ internalAPIs_1.sendMessageRequestToParent('appInitialization.failure', [
1527
1693
  appInitializationFailedRequest.reason,
1528
1694
  appInitializationFailedRequest.message,
1529
1695
  ]);
@@ -1574,7 +1740,7 @@ var authentication;
1574
1740
  var link = document.createElement('a');
1575
1741
  link.href = authenticateParams.url;
1576
1742
  // Ask the parent window to open an authentication window with the parameters provided by the caller.
1577
- var messageId = internalAPIs_1.sendMessageRequest(globalVars_1.GlobalVars.parentWindow, 'authentication.authenticate', [
1743
+ var messageId = internalAPIs_1.sendMessageRequestToParent('authentication.authenticate', [
1578
1744
  link.href,
1579
1745
  authenticateParams.width,
1580
1746
  authenticateParams.height,
@@ -1604,9 +1770,7 @@ var authentication;
1604
1770
  */
1605
1771
  function getAuthToken(authTokenRequest) {
1606
1772
  internalAPIs_1.ensureInitialized();
1607
- var messageId = internalAPIs_1.sendMessageRequest(globalVars_1.GlobalVars.parentWindow, 'authentication.getAuthToken', [
1608
- authTokenRequest.resources,
1609
- ]);
1773
+ var messageId = internalAPIs_1.sendMessageRequestToParent('authentication.getAuthToken', [authTokenRequest.resources]);
1610
1774
  globalVars_1.GlobalVars.callbacks[messageId] = function (success, result) {
1611
1775
  if (success) {
1612
1776
  authTokenRequest.successCallback(result);
@@ -1625,7 +1789,7 @@ var authentication;
1625
1789
  */
1626
1790
  function getUser(userRequest) {
1627
1791
  internalAPIs_1.ensureInitialized();
1628
- var messageId = internalAPIs_1.sendMessageRequest(globalVars_1.GlobalVars.parentWindow, 'authentication.getUser');
1792
+ var messageId = internalAPIs_1.sendMessageRequestToParent('authentication.getUser');
1629
1793
  globalVars_1.GlobalVars.callbacks[messageId] = function (success, result) {
1630
1794
  if (success) {
1631
1795
  userRequest.successCallback(result);
@@ -1714,7 +1878,7 @@ var authentication;
1714
1878
  var savedChildOrigin = globalVars_1.GlobalVars.childOrigin;
1715
1879
  try {
1716
1880
  globalVars_1.GlobalVars.childOrigin = '*';
1717
- internalAPIs_1.sendMessageRequest(globalVars_1.GlobalVars.childWindow, 'ping');
1881
+ internalAPIs_1.sendMessageEventToChild('ping');
1718
1882
  }
1719
1883
  finally {
1720
1884
  globalVars_1.GlobalVars.childOrigin = savedChildOrigin;
@@ -1743,7 +1907,7 @@ var authentication;
1743
1907
  function notifySuccess(result, callbackUrl) {
1744
1908
  redirectIfWin32Outlook(callbackUrl, 'result', result);
1745
1909
  internalAPIs_1.ensureInitialized(constants_1.frameContexts.authentication);
1746
- internalAPIs_1.sendMessageRequest(globalVars_1.GlobalVars.parentWindow, 'authentication.authenticate.success', [result]);
1910
+ internalAPIs_1.sendMessageRequestToParent('authentication.authenticate.success', [result]);
1747
1911
  // Wait for the message to be sent before closing the window
1748
1912
  internalAPIs_1.waitForMessageQueue(globalVars_1.GlobalVars.parentWindow, function () { return setTimeout(function () { return globalVars_1.GlobalVars.currentWindow.close(); }, 200); });
1749
1913
  }
@@ -1758,7 +1922,7 @@ var authentication;
1758
1922
  function notifyFailure(reason, callbackUrl) {
1759
1923
  redirectIfWin32Outlook(callbackUrl, 'reason', reason);
1760
1924
  internalAPIs_1.ensureInitialized(constants_1.frameContexts.authentication);
1761
- internalAPIs_1.sendMessageRequest(globalVars_1.GlobalVars.parentWindow, 'authentication.authenticate.failure', [reason]);
1925
+ internalAPIs_1.sendMessageRequestToParent('authentication.authenticate.failure', [reason]);
1762
1926
  // Wait for the message to be sent before closing the window
1763
1927
  internalAPIs_1.waitForMessageQueue(globalVars_1.GlobalVars.parentWindow, function () { return setTimeout(function () { return globalVars_1.GlobalVars.currentWindow.close(); }, 200); });
1764
1928
  }
@@ -1863,7 +2027,7 @@ var tasks;
1863
2027
  */
1864
2028
  function startTask(taskInfo, submitHandler) {
1865
2029
  internalAPIs_1.ensureInitialized(constants_1.frameContexts.content);
1866
- var messageId = internalAPIs_1.sendMessageRequest(globalVars_1.GlobalVars.parentWindow, 'tasks.startTask', [taskInfo]);
2030
+ var messageId = internalAPIs_1.sendMessageRequestToParent('tasks.startTask', [taskInfo]);
1867
2031
  globalVars_1.GlobalVars.callbacks[messageId] = submitHandler;
1868
2032
  return new appWindow_1.ChildAppWindow();
1869
2033
  }
@@ -1876,7 +2040,7 @@ var tasks;
1876
2040
  internalAPIs_1.ensureInitialized(constants_1.frameContexts.content, constants_1.frameContexts.task);
1877
2041
  var width = taskInfo.width, height = taskInfo.height, extra = __rest(taskInfo, ["width", "height"]);
1878
2042
  if (!Object.keys(extra).length) {
1879
- internalAPIs_1.sendMessageRequest(globalVars_1.GlobalVars.parentWindow, 'tasks.updateTask', [taskInfo]);
2043
+ internalAPIs_1.sendMessageRequestToParent('tasks.updateTask', [taskInfo]);
1880
2044
  }
1881
2045
  else {
1882
2046
  throw new Error('updateTask requires a taskInfo argument containing only width and height');
@@ -1891,10 +2055,7 @@ var tasks;
1891
2055
  function submitTask(result, appIds) {
1892
2056
  internalAPIs_1.ensureInitialized(constants_1.frameContexts.content, constants_1.frameContexts.task);
1893
2057
  // Send tasks.completeTask instead of tasks.submitTask message for backward compatibility with Mobile clients
1894
- internalAPIs_1.sendMessageRequest(globalVars_1.GlobalVars.parentWindow, 'tasks.completeTask', [
1895
- result,
1896
- Array.isArray(appIds) ? appIds : [appIds],
1897
- ]);
2058
+ internalAPIs_1.sendMessageRequestToParent('tasks.completeTask', [result, Array.isArray(appIds) ? appIds : [appIds]]);
1898
2059
  }
1899
2060
  tasks.submitTask = submitTask;
1900
2061
  })(tasks = exports.tasks || (exports.tasks = {}));