@microsoft/teams-js 2.35.0-beta.2 → 2.36.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.
Files changed (25) hide show
  1. package/README.md +4 -4
  2. package/dist/esm/packages/teams-js/dts/internal/childCommunication.d.ts +1 -1
  3. package/dist/esm/packages/teams-js/dts/internal/communication.d.ts +1 -1
  4. package/dist/esm/packages/teams-js/dts/internal/globalVars.d.ts +1 -0
  5. package/dist/esm/packages/teams-js/dts/internal/messageObjects.d.ts +1 -0
  6. package/dist/esm/packages/teams-js/dts/internal/nestedAppAuthUtils.d.ts +3 -1
  7. package/dist/esm/packages/teams-js/dts/internal/telemetry.d.ts +2 -0
  8. package/dist/esm/packages/teams-js/dts/private/index.d.ts +1 -0
  9. package/dist/esm/packages/teams-js/dts/private/nestedAppAuth/nestedAppAuthBridge.d.ts +32 -0
  10. package/dist/esm/packages/teams-js/dts/public/nestedAppAuth.d.ts +56 -5
  11. package/dist/esm/packages/teams-js/dts/public/runtime.d.ts +2 -0
  12. package/dist/esm/packages/teams-js/src/index.js +1 -1
  13. package/dist/esm/packages/teams-js/src/internal/childCommunication.js +1 -1
  14. package/dist/esm/packages/teams-js/src/internal/communication.js +1 -1
  15. package/dist/esm/packages/teams-js/src/internal/globalVars.js +1 -1
  16. package/dist/esm/packages/teams-js/src/internal/nestedAppAuthUtils.js +1 -1
  17. package/dist/esm/packages/teams-js/src/private/nestedAppAuth/nestedAppAuthBridge.js +1 -0
  18. package/dist/esm/packages/teams-js/src/public/nestedAppAuth.js +1 -1
  19. package/dist/esm/packages/teams-js/src/public/runtime.js +1 -1
  20. package/dist/esm/packages/teams-js/src/public/version.js +1 -1
  21. package/dist/umd/MicrosoftTeams.js +457 -23
  22. package/dist/umd/MicrosoftTeams.js.map +1 -1
  23. package/dist/umd/MicrosoftTeams.min.js +1 -1
  24. package/dist/umd/MicrosoftTeams.min.js.map +1 -1
  25. package/package.json +53 -1
@@ -1060,6 +1060,7 @@ __webpack_require__.d(__webpack_exports__, {
1060
1060
  navigateCrossDomain: () => (/* reexport */ navigation_navigateCrossDomain),
1061
1061
  navigateToTab: () => (/* reexport */ navigation_navigateToTab),
1062
1062
  nestedAppAuth: () => (/* reexport */ nestedAppAuth_namespaceObject),
1063
+ nestedAppAuthBridge: () => (/* reexport */ nestedAppAuthBridge_namespaceObject),
1063
1064
  notifications: () => (/* reexport */ notifications_namespaceObject),
1064
1065
  openFilePreview: () => (/* reexport */ openFilePreview),
1065
1066
  otherAppStateChange: () => (/* reexport */ otherAppStateChange_namespaceObject),
@@ -1485,6 +1486,14 @@ __webpack_require__.d(messageChannels_namespaceObject, {
1485
1486
  telemetry: () => (messageChannels_telemetry_namespaceObject)
1486
1487
  });
1487
1488
 
1489
+ // NAMESPACE OBJECT: ./src/private/nestedAppAuth/nestedAppAuthBridge.ts
1490
+ var nestedAppAuthBridge_namespaceObject = {};
1491
+ __webpack_require__.r(nestedAppAuthBridge_namespaceObject);
1492
+ __webpack_require__.d(nestedAppAuthBridge_namespaceObject, {
1493
+ initialize: () => (nestedAppAuthBridge_initialize),
1494
+ version: () => (nestedAppAuthBridge_version)
1495
+ });
1496
+
1488
1497
  // NAMESPACE OBJECT: ./src/private/notifications.ts
1489
1498
  var notifications_namespaceObject = {};
1490
1499
  __webpack_require__.r(notifications_namespaceObject);
@@ -1691,6 +1700,11 @@ __webpack_require__.d(clipboard_namespaceObject, {
1691
1700
  var nestedAppAuth_namespaceObject = {};
1692
1701
  __webpack_require__.r(nestedAppAuth_namespaceObject);
1693
1702
  __webpack_require__.d(nestedAppAuth_namespaceObject, {
1703
+ addNAATrustedOrigins: () => (addNAATrustedOrigins),
1704
+ canParentManageNAATrustedOrigins: () => (canParentManageNAATrustedOrigins),
1705
+ deleteNAATrustedOrigins: () => (deleteNAATrustedOrigins),
1706
+ getParentOrigin: () => (getParentOrigin),
1707
+ isDeeplyNestedAuthSupported: () => (isDeeplyNestedAuthSupported),
1694
1708
  isNAAChannelRecommended: () => (isNAAChannelRecommended)
1695
1709
  });
1696
1710
 
@@ -2358,20 +2372,6 @@ const errorRuntimeNotSupported = 'The runtime version is not supported';
2358
2372
  /** @hidden */
2359
2373
  const errorCallNotStarted = 'The call was not properly started';
2360
2374
 
2361
- ;// ./src/internal/globalVars.ts
2362
- class GlobalVars {
2363
- }
2364
- GlobalVars.initializeCalled = false;
2365
- GlobalVars.initializeCompleted = false;
2366
- GlobalVars.additionalValidOrigins = [];
2367
- GlobalVars.initializePromise = undefined;
2368
- GlobalVars.isFramelessWindow = false;
2369
- GlobalVars.frameContext = undefined;
2370
- GlobalVars.hostClientType = undefined;
2371
- GlobalVars.printCapabilityEnabled = false;
2372
-
2373
- // EXTERNAL MODULE: ../../node_modules/.pnpm/debug@4.3.5/node_modules/debug/src/browser.js
2374
- var browser = __webpack_require__(815);
2375
2375
  // EXTERNAL MODULE: ../../node_modules/.pnpm/base64-js@1.5.1/node_modules/base64-js/index.js
2376
2376
  var base64_js = __webpack_require__(933);
2377
2377
  ;// ../../node_modules/.pnpm/skeleton-buffer@file+skeleton-buffer/node_modules/skeleton-buffer/index.js
@@ -4062,6 +4062,22 @@ function validateUuidInstance(id) {
4062
4062
  }
4063
4063
  }
4064
4064
 
4065
+ ;// ./src/internal/globalVars.ts
4066
+
4067
+ class GlobalVars {
4068
+ }
4069
+ GlobalVars.initializeCalled = false;
4070
+ GlobalVars.initializeCompleted = false;
4071
+ GlobalVars.additionalValidOrigins = [];
4072
+ GlobalVars.initializePromise = undefined;
4073
+ GlobalVars.isFramelessWindow = false;
4074
+ GlobalVars.frameContext = undefined;
4075
+ GlobalVars.hostClientType = undefined;
4076
+ GlobalVars.printCapabilityEnabled = false;
4077
+ GlobalVars.teamsJsInstanceId = new UUID().toString();
4078
+
4079
+ // EXTERNAL MODULE: ../../node_modules/.pnpm/debug@4.3.5/node_modules/debug/src/browser.js
4080
+ var browser = __webpack_require__(815);
4065
4081
  ;// ./src/internal/telemetry.ts
4066
4082
  // We are directly referencing the browser implementation of `debug` to resolve an issue with polyfilling. For a full write-up on the bug please see ADO Bug #9619161
4067
4083
 
@@ -4182,6 +4198,7 @@ let runtime = _uninitializedRuntime;
4182
4198
  const versionAndPlatformAgnosticTeamsRuntimeConfig = {
4183
4199
  apiVersion: 4,
4184
4200
  isNAAChannelRecommended: false,
4201
+ isDeeplyNestedAuthSupported: false,
4185
4202
  hostVersionsInfo: teamsMinAdaptiveCardVersion,
4186
4203
  isLegacyTeams: true,
4187
4204
  supports: {
@@ -4518,7 +4535,7 @@ function isSerializable(arg) {
4518
4535
  * @hidden
4519
4536
  * Package version.
4520
4537
  */
4521
- const version = "2.35.0-beta.2";
4538
+ const version = "2.36.0";
4522
4539
 
4523
4540
  ;// ./src/public/featureFlags.ts
4524
4541
  // All build feature flags are defined inside this object. Any build feature flag must have its own unique getter and setter function. This pattern allows for client apps to treeshake unused code and avoid including code guarded by this feature flags in the final bundle. If this property isn't desired, use the below runtime feature flags object.
@@ -7752,7 +7769,8 @@ function handleIncomingMessage(evt, sendMessageToParentHelper, setCallbackForReq
7752
7769
  * Limited to Microsoft-internal use
7753
7770
  */
7754
7771
  function sendChildMessageToParent(message, sendMessageToParentHelper, setCallbackForRequest) {
7755
- const request = sendMessageToParentHelper(getApiVersionTag("v2" /* ApiVersionNumber.V_2 */, "tasks.startTask" /* ApiName.Tasks_StartTask */), message.func, message.args, true);
7772
+ const request = sendMessageToParentHelper(getApiVersionTag("v2" /* ApiVersionNumber.V_2 */, "tasks.startTask" /* ApiName.Tasks_StartTask */), message.func, message.args, true, // Tags message as proxied from child
7773
+ message.teamsJsInstanceId);
7756
7774
  // Copy variable to new pointer
7757
7775
  const requestChildWindowOrigin = ChildCommunication.origin;
7758
7776
  setCallbackForRequest(request.uuid, (...args) => {
@@ -7920,6 +7938,7 @@ HostToAppMessageDelayTelemetry.callbackInformation = new Map();
7920
7938
 
7921
7939
  const nestedAppAuthLogger = getLogger('nestedAppAuthUtils');
7922
7940
  const tryPolyfillWithNestedAppAuthBridgeLogger = nestedAppAuthLogger.extend('tryPolyfillWithNestedAppAuthBridge');
7941
+ const nestedAppAuthTelemetryVersionNumber = "v2" /* ApiVersionNumber.V_2 */;
7923
7942
  /**
7924
7943
  * @hidden
7925
7944
  * Attempt to polyfill the nestedAppAuthBridge object on the given window
@@ -7938,6 +7957,11 @@ function tryPolyfillWithNestedAppAuthBridge(clientSupportedSDKVersion, window, h
7938
7957
  logger('Cannot polyfill nestedAppAuthBridge as current window does not exist');
7939
7958
  return;
7940
7959
  }
7960
+ // Skip injection if this is a nested iframe (i.e., not the top-most app)
7961
+ if (window.parent !== window.top) {
7962
+ logger('Default NAA bridge injection not supported in nested iframe. Use standalone NAA bridge instead.');
7963
+ return;
7964
+ }
7941
7965
  const parsedClientSupportedSDKVersion = (() => {
7942
7966
  try {
7943
7967
  return JSON.parse(clientSupportedSDKVersion);
@@ -8008,8 +8032,9 @@ function createNestedAppAuthBridge(window, bridgeHandlers) {
8008
8032
  logger('Unrecognized data format received by app, message being ignored. Message: %o', message);
8009
8033
  return;
8010
8034
  }
8035
+ const apiVersionTag = getApiVersionTag(nestedAppAuthTelemetryVersionNumber, "nestedAppAuth.execute" /* ApiName.NestedAppAuth_Execute */);
8011
8036
  // Post the message to the top window
8012
- sendPostMessage(message);
8037
+ sendPostMessage(message, apiVersionTag);
8013
8038
  },
8014
8039
  removeEventListener: (eventName, callback) => {
8015
8040
  window.removeEventListener(eventName, nestedAppAuthBridgeHandler(callback));
@@ -8350,10 +8375,10 @@ const sendNestedAuthRequestToTopWindowLogger = communication_communicationLogger
8350
8375
  * @internal
8351
8376
  * Limited to Microsoft-internal use
8352
8377
  */
8353
- function sendNestedAuthRequestToTopWindow(message) {
8378
+ function sendNestedAuthRequestToTopWindow(message, apiVersionTag) {
8354
8379
  const logger = sendNestedAuthRequestToTopWindowLogger;
8355
8380
  const targetWindow = Communication.topWindow;
8356
- const request = createNestedAppAuthRequest(message);
8381
+ const request = createNestedAppAuthRequest(message, apiVersionTag);
8357
8382
  logger('Message %s information: %o', getMessageIdsAsLogString(request), {
8358
8383
  actionName: request.func,
8359
8384
  });
@@ -8394,10 +8419,10 @@ const sendMessageToParentHelperLogger = communication_communicationLogger.extend
8394
8419
  * @internal
8395
8420
  * Limited to Microsoft-internal use
8396
8421
  */
8397
- function sendMessageToParentHelper(apiVersionTag, actionName, args, isProxiedFromChild) {
8422
+ function sendMessageToParentHelper(apiVersionTag, actionName, args, isProxiedFromChild, teamsJsInstanceId) {
8398
8423
  const logger = sendMessageToParentHelperLogger;
8399
8424
  const targetWindow = Communication.parentWindow;
8400
- const request = createMessageRequest(apiVersionTag, actionName, args, isProxiedFromChild);
8425
+ const request = createMessageRequest(apiVersionTag, actionName, args, isProxiedFromChild, teamsJsInstanceId);
8401
8426
  HostToAppMessageDelayTelemetry.storeCallbackInformation(request.uuid, {
8402
8427
  name: actionName,
8403
8428
  calledAt: request.timestamp,
@@ -8772,10 +8797,16 @@ function waitForMessageQueue(targetWindow, callback) {
8772
8797
  * @internal
8773
8798
  * Limited to Microsoft-internal use
8774
8799
  */
8775
- function createMessageRequest(apiVersionTag, func, args, isProxiedFromChild) {
8800
+ function createMessageRequest(apiVersionTag, func, args, isProxiedFromChild, teamsJsInstanceId) {
8776
8801
  const messageId = CommunicationPrivate.nextMessageId++;
8777
8802
  const messageUuid = new UUID();
8778
8803
  CommunicationPrivate.legacyMessageIdsToUuidMap[messageId] = messageUuid;
8804
+ /**
8805
+ * Only when `isProxiedFromChild` is explicitly set to be true, the message request is created and relayed for child app
8806
+ * Parent app needs to create and relay message request with whatever child app sent to it,
8807
+ * and parent app's TeamsJS instance ID can NOT be used in this case.
8808
+ */
8809
+ const tjsInstanceIdToAttach = isProxiedFromChild === true ? teamsJsInstanceId : GlobalVars.teamsJsInstanceId;
8779
8810
  return {
8780
8811
  id: messageId,
8781
8812
  uuid: messageUuid,
@@ -8785,6 +8816,7 @@ function createMessageRequest(apiVersionTag, func, args, isProxiedFromChild) {
8785
8816
  args: args || [],
8786
8817
  apiVersionTag: apiVersionTag,
8787
8818
  isProxiedFromChild: isProxiedFromChild !== null && isProxiedFromChild !== void 0 ? isProxiedFromChild : false,
8819
+ teamsJsInstanceId: tjsInstanceIdToAttach,
8788
8820
  };
8789
8821
  }
8790
8822
  /**
@@ -8798,7 +8830,7 @@ function createMessageRequest(apiVersionTag, func, args, isProxiedFromChild) {
8798
8830
  *
8799
8831
  * @returns {NestedAppAuthRequest} Returns a NestedAppAuthRequest object with a unique id, the function name set to 'nestedAppAuthRequest', the current timestamp, an empty args array, and the provided message as data.
8800
8832
  */
8801
- function createNestedAppAuthRequest(message) {
8833
+ function createNestedAppAuthRequest(message, apiVersionTag) {
8802
8834
  const messageId = CommunicationPrivate.nextMessageId++;
8803
8835
  const messageUuid = new UUID();
8804
8836
  CommunicationPrivate.legacyMessageIdsToUuidMap[messageId] = messageUuid;
@@ -8808,6 +8840,7 @@ function createNestedAppAuthRequest(message) {
8808
8840
  func: 'nestedAppAuth.execute',
8809
8841
  timestamp: Date.now(),
8810
8842
  monotonicTimestamp: getCurrentTimestamp(),
8843
+ apiVersionTag: apiVersionTag,
8811
8844
  // Since this is a nested app auth request, we don't need to send any args.
8812
8845
  // We avoid overloading the args array with the message to avoid potential issues processing of these messages on the hubSDK.
8813
8846
  args: [],
@@ -10941,6 +10974,240 @@ function messageChannels_isSupported() {
10941
10974
  }
10942
10975
 
10943
10976
 
10977
+ ;// ./src/private/nestedAppAuth/nestedAppAuthBridge.ts
10978
+
10979
+ /**
10980
+ * @beta
10981
+ * @hidden
10982
+ * Local version of the Nested App Auth Bridge module.
10983
+ *
10984
+ * This version is specific to this standalone module and is not tied to the overall TeamsJS SDK version.
10985
+ * It allows developers to track changes within this module and handle version-based compatibility if needed.
10986
+ *
10987
+ * While not strictly required today, having a version provides flexibility for future updates,
10988
+ * especially if breaking changes are introduced later.
10989
+ *
10990
+ * Example:
10991
+ * if (nestedAppAuthBridge.version.startsWith('1.')) {
10992
+ * // Safe to use with current logic
10993
+ * }
10994
+ *
10995
+ * @internal
10996
+ * Limited to Microsoft-internal use
10997
+ */
10998
+ const nestedAppAuthBridge_version = '1.0.0';
10999
+ /**
11000
+ * Bridge handlers used for processing messages.
11001
+ */
11002
+ const bridgeHandlers = {
11003
+ onMessage: nestedAppAuthBridge_processAuthBridgeMessage,
11004
+ };
11005
+ let topOriginForNAA = null;
11006
+ let isNAALoggerEnabled = false;
11007
+ /**
11008
+ * @beta
11009
+ * @hidden
11010
+ * Initializes the Nested App Auth Bridge.
11011
+ * @param window The window object where the bridge will be attached.
11012
+ * @param topOrigin The origin of the top-level frame.
11013
+ * @param enableLogging - Optional flag to enable internal debug and error logging. Defaults to false.
11014
+ *
11015
+ * @internal
11016
+ * Limited to Microsoft-internal use
11017
+ */
11018
+ function nestedAppAuthBridge_initialize(window, topOrigin, enableLogging = false) {
11019
+ isNAALoggerEnabled = enableLogging;
11020
+ if (!window) {
11021
+ throw new Error('Cannot polyfill nestedAppAuthBridge as the current window does not exist');
11022
+ }
11023
+ if (!topOrigin) {
11024
+ throw new Error('Top origin is required to initialize the Nested App Auth Bridge');
11025
+ }
11026
+ try {
11027
+ const parsedOrigin = new URL(topOrigin);
11028
+ if (parsedOrigin.protocol !== 'https:') {
11029
+ throw new Error(`Invalid top origin: ${topOrigin}. Only HTTPS origins are allowed.`);
11030
+ }
11031
+ topOriginForNAA = parsedOrigin.origin;
11032
+ }
11033
+ catch (error) {
11034
+ throw new Error(`Failed to initialize bridge: invalid top origin: ${topOrigin}`);
11035
+ }
11036
+ const extendedWindow = window;
11037
+ // If the bridge is already present, return.
11038
+ if (extendedWindow.nestedAppAuthBridge) {
11039
+ log('Nested App Auth Bridge is already present');
11040
+ return;
11041
+ }
11042
+ // Create and assign the bridge to the window.
11043
+ const nestedAppAuthBridge = nestedAppAuthBridge_createNestedAppAuthBridge(extendedWindow);
11044
+ if (nestedAppAuthBridge) {
11045
+ extendedWindow.nestedAppAuthBridge = nestedAppAuthBridge;
11046
+ }
11047
+ }
11048
+ /**
11049
+ * Creates the Nested App Auth Bridge.
11050
+ * @param window The window object where the bridge is being injected.
11051
+ * @returns A NestedAppAuthBridge instance.
11052
+ */
11053
+ function nestedAppAuthBridge_createNestedAppAuthBridge(window) {
11054
+ const messageHandlers = new WeakMap();
11055
+ const { onMessage } = bridgeHandlers;
11056
+ const nestedAppAuthBridgeHandler = (callback) => (evt) => onMessage(evt, callback);
11057
+ return {
11058
+ /**
11059
+ * Adds an event listener for message events.
11060
+ */
11061
+ addEventListener: (eventName, callback) => {
11062
+ if (eventName === 'message') {
11063
+ const handler = nestedAppAuthBridgeHandler(callback);
11064
+ messageHandlers.set(callback, handler);
11065
+ window.addEventListener(eventName, handler);
11066
+ }
11067
+ else {
11068
+ log(`Event ${eventName} is not supported by nestedAppAuthBridge`);
11069
+ }
11070
+ },
11071
+ /**
11072
+ * Sends a message using postMessage.
11073
+ */
11074
+ postMessage: (message) => {
11075
+ if (window.top) {
11076
+ try {
11077
+ const parsedMessage = JSON.parse(message);
11078
+ if (typeof parsedMessage === 'object' &&
11079
+ parsedMessage.messageType === "NestedAppAuthRequest" /* NestedAppAuthMessageEventNames.Request */) {
11080
+ const request = nestedAppAuthBridge_createNestedAppAuthRequest(message);
11081
+ if (window !== window.top && topOriginForNAA) {
11082
+ window.top.postMessage(request, topOriginForNAA);
11083
+ }
11084
+ else {
11085
+ logError('Not in an embedded iframe; skipping postMessage.');
11086
+ return;
11087
+ }
11088
+ }
11089
+ }
11090
+ catch (error) {
11091
+ logError('Failed to parse message:', error, 'Original message:', message);
11092
+ return;
11093
+ }
11094
+ }
11095
+ else {
11096
+ throw new Error('window.top is not available for posting messages');
11097
+ }
11098
+ },
11099
+ /**
11100
+ * Removes a previously attached event listener.
11101
+ */
11102
+ removeEventListener: (eventName, callback) => {
11103
+ const handler = messageHandlers.get(callback);
11104
+ if (handler) {
11105
+ window.removeEventListener(eventName, handler);
11106
+ messageHandlers.delete(callback);
11107
+ }
11108
+ },
11109
+ };
11110
+ }
11111
+ /**
11112
+ * Processes messages received through the auth bridge.
11113
+ * @param evt The message event containing the response.
11114
+ * @param onMessageReceived Callback function to handle the received message.
11115
+ */
11116
+ function nestedAppAuthBridge_processAuthBridgeMessage(evt, onMessageReceived) {
11117
+ if (!evt || !evt.data || typeof evt.data !== 'object' || evt.data === null) {
11118
+ log('Invalid message format, ignoring. Message: %o', evt);
11119
+ return;
11120
+ }
11121
+ // Validate message source before processing
11122
+ if (!nestedAppAuthBridge_shouldProcessIncomingMessage(evt.source, evt.origin)) {
11123
+ log('Message source/origin not allowed, ignoring.');
11124
+ return;
11125
+ }
11126
+ const { args } = evt.data;
11127
+ const [, message] = args !== null && args !== void 0 ? args : [];
11128
+ const parsedData = (() => {
11129
+ try {
11130
+ return JSON.parse(message);
11131
+ }
11132
+ catch (error) {
11133
+ logError('Failed to parse response message:', error);
11134
+ return null;
11135
+ }
11136
+ })();
11137
+ if (!parsedData || parsedData.messageType !== "NestedAppAuthResponse" /* NestedAppAuthMessageEventNames.Response */) {
11138
+ log('Invalid response format, ignoring. Message: %o', evt);
11139
+ return;
11140
+ }
11141
+ onMessageReceived(message);
11142
+ }
11143
+ function nestedAppAuthBridge_shouldProcessIncomingMessage(messageSource, messageOrigin) {
11144
+ // Reject messages if they are not from the top window
11145
+ if (messageSource && messageSource !== window.top) {
11146
+ log('Should not process message because it is not coming from the top window');
11147
+ return false;
11148
+ }
11149
+ // Check if messageOrigin matches topOriginForNAA
11150
+ if (messageOrigin === topOriginForNAA) {
11151
+ try {
11152
+ return new URL(messageOrigin).protocol === 'https:';
11153
+ }
11154
+ catch (error) {
11155
+ logError('Invalid message origin URL:', error);
11156
+ return false;
11157
+ }
11158
+ }
11159
+ return false;
11160
+ }
11161
+ /**
11162
+ * Creates a NAA request with a unique ID and timestamp.
11163
+ * @param data The data to be included in the request.
11164
+ * @returns A stringified JSON request object.
11165
+ */
11166
+ function nestedAppAuthBridge_createNestedAppAuthRequest(data) {
11167
+ const timestamp = Date.now();
11168
+ return {
11169
+ id: generateUniqueId(),
11170
+ uuid: esm_browser_v4(),
11171
+ func: 'nestedAppAuth.execute',
11172
+ timestamp: timestamp,
11173
+ apiVersionTag: 'v2_nestedAppAuth.execute',
11174
+ monotonicTimestamp: timestamp,
11175
+ args: [],
11176
+ data,
11177
+ };
11178
+ }
11179
+ /**
11180
+ * Generates a unique ID for NAA auth requests.
11181
+ * @returns A randomly generated unique string.
11182
+ */
11183
+ function generateUniqueId() {
11184
+ return typeof crypto !== 'undefined' && crypto.randomUUID
11185
+ ? crypto.randomUUID()
11186
+ : Math.random().toString(36).substring(2, 11);
11187
+ }
11188
+ /**
11189
+ * Logs informational messages to the console if logging is enabled.
11190
+ * Used internally for non-critical debug output.
11191
+ *
11192
+ * @param args - The data to be logged.
11193
+ */
11194
+ function log(...args) {
11195
+ if (isNAALoggerEnabled) {
11196
+ console.log(...args);
11197
+ }
11198
+ }
11199
+ /**
11200
+ * Logs error messages to the console if logging is enabled.
11201
+ * Used internally for debugging and error tracing.
11202
+ *
11203
+ * @param args - The error data to be logged.
11204
+ */
11205
+ function logError(...args) {
11206
+ if (isNAALoggerEnabled) {
11207
+ console.error(...args);
11208
+ }
11209
+ }
11210
+
10944
11211
  ;// ./src/private/notifications.ts
10945
11212
  /**
10946
11213
  * @hidden
@@ -13234,6 +13501,8 @@ function serializeValidSize(size) {
13234
13501
 
13235
13502
 
13236
13503
 
13504
+
13505
+
13237
13506
 
13238
13507
 
13239
13508
 
@@ -14596,6 +14865,15 @@ function clipboard_isSupported() {
14596
14865
  }
14597
14866
 
14598
14867
  ;// ./src/public/nestedAppAuth.ts
14868
+ var nestedAppAuth_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
14869
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14870
+ return new (P || (P = Promise))(function (resolve, reject) {
14871
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
14872
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
14873
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
14874
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
14875
+ });
14876
+ };
14599
14877
  /**
14600
14878
  * @beta
14601
14879
  * Nested app auth capabilities
@@ -14605,6 +14883,24 @@ function clipboard_isSupported() {
14605
14883
 
14606
14884
 
14607
14885
 
14886
+
14887
+
14888
+ /**
14889
+ * v2 APIs telemetry file: All of APIs in this capability file should send out API version v2 ONLY
14890
+ */
14891
+ const nestedAppAuth_hostEntityTelemetryVersionNumber = "v2" /* ApiVersionNumber.V_2 */;
14892
+ /**
14893
+ * Response handler for managing NAA Trusted Origins.
14894
+ */
14895
+ const trustedOriginResponseHandler = {
14896
+ validate: (response) => Array.isArray(response) || typeof response === 'object',
14897
+ deserialize: (response) => response,
14898
+ };
14899
+ var TrustedOriginAction;
14900
+ (function (TrustedOriginAction) {
14901
+ TrustedOriginAction["ADD"] = "ADD";
14902
+ TrustedOriginAction["DELETE"] = "DELETE";
14903
+ })(TrustedOriginAction || (TrustedOriginAction = {}));
14608
14904
  /**
14609
14905
  * Checks if MSAL-NAA channel recommended by the host
14610
14906
  * @returns true if host is recommending NAA channel and false otherwise
@@ -14618,6 +14914,47 @@ function isNAAChannelRecommended() {
14618
14914
  return ((_a = (ensureInitialized(runtime) &&
14619
14915
  (runtime.isNAAChannelRecommended || isNAAChannelRecommendedForLegacyTeamsMobile()))) !== null && _a !== void 0 ? _a : false);
14620
14916
  }
14917
+ /**
14918
+ * Gets the origin of the parent window if available.
14919
+ * This will be the top-level origin in the case of a parent app.
14920
+ * It is used to pass to the embedded child app to initialize the Nested App Auth bridge.
14921
+
14922
+ * @returns The origin string if available, otherwise null
14923
+ *
14924
+ * @throws Error if {@linkcode app.initialize} has not successfully completed
14925
+ *
14926
+ * @beta
14927
+ */
14928
+ function getParentOrigin() {
14929
+ ensureInitialized(runtime);
14930
+ return Communication.parentOrigin;
14931
+ }
14932
+ /**
14933
+ * Checks if the parent has the capability to manage its list of trusted child origins
14934
+ * for Nested App Auth (NAA).
14935
+ *
14936
+ * @returns true if parent can manage NAA TrustedOrigins, false otherwise
14937
+ *
14938
+ * @throws Error if {@linkcode app.initialize} has not successfully completed
14939
+ *
14940
+ * @beta
14941
+ */
14942
+ function canParentManageNAATrustedOrigins() {
14943
+ var _a;
14944
+ return (_a = (ensureInitialized(runtime) && runtime.canParentManageNAATrustedOrigins)) !== null && _a !== void 0 ? _a : false;
14945
+ }
14946
+ /**
14947
+ * Checks if NAA deeply nested scenario supported by the host
14948
+ * @returns true if host supports
14949
+ *
14950
+ * @throws Error if {@linkcode app.initialize} has not successfully completed
14951
+ *
14952
+ * @beta
14953
+ */
14954
+ function isDeeplyNestedAuthSupported() {
14955
+ var _a;
14956
+ return (_a = (ensureInitialized(runtime) && runtime.isDeeplyNestedAuthSupported)) !== null && _a !== void 0 ? _a : false;
14957
+ }
14621
14958
  function isNAAChannelRecommendedForLegacyTeamsMobile() {
14622
14959
  return ensureInitialized(runtime) &&
14623
14960
  isHostAndroidOrIOSOrIPadOSOrVisionOS() &&
@@ -14632,6 +14969,103 @@ function isHostAndroidOrIOSOrIPadOSOrVisionOS() {
14632
14969
  GlobalVars.hostClientType === HostClientType.ipados ||
14633
14970
  GlobalVars.hostClientType === HostClientType.visionOS);
14634
14971
  }
14972
+ /**
14973
+ * Registers the origins of child apps as trusted for Nested App Auth (NAA).
14974
+ *
14975
+ * This allows a top-level parent app to specify which child app origins are considered trusted
14976
+ *
14977
+ * @param appOrigins - An array of child app origins to trust (must be a non-empty array).
14978
+ * @returns A Promise resolving with the result of the action.
14979
+ * @throws Error if called from a non-top-level parent or if parameters are invalid.
14980
+ *
14981
+ * @beta
14982
+ */
14983
+ function addNAATrustedOrigins(appOrigins) {
14984
+ return nestedAppAuth_awaiter(this, void 0, void 0, function* () {
14985
+ if (!canParentManageNAATrustedOrigins()) {
14986
+ throw errorNotSupportedOnPlatform;
14987
+ }
14988
+ const normalizedOrigins = appOrigins.map(normalizeOrigin);
14989
+ return manageNAATrustedOrigins(TrustedOriginAction.ADD, normalizedOrigins);
14990
+ });
14991
+ }
14992
+ /**
14993
+ * Removes previously trusted child app origins from Nested App Auth (NAA).
14994
+ *
14995
+ * The specified origins will no longer be considered trusted.
14996
+ *
14997
+ * @param appOrigins - An array of child app origins to remove from the trusted list (must be a non-empty array).
14998
+ * @returns A Promise resolving with the result of the action.
14999
+ * @throws Error if called from a non-top-level parent or if parameters are invalid.
15000
+ *
15001
+ * @beta
15002
+ */
15003
+ function deleteNAATrustedOrigins(appOrigins) {
15004
+ return nestedAppAuth_awaiter(this, void 0, void 0, function* () {
15005
+ if (!canParentManageNAATrustedOrigins()) {
15006
+ throw errorNotSupportedOnPlatform;
15007
+ }
15008
+ const normalizedOrigins = appOrigins.map(normalizeOrigin);
15009
+ return manageNAATrustedOrigins(TrustedOriginAction.DELETE, normalizedOrigins);
15010
+ });
15011
+ }
15012
+ /**
15013
+ * Performs the specified action (add or delete) on the list of trusted child app origins for Nested App Auth (NAA).
15014
+ *
15015
+ * This function is intended to be called by a top-level parent app to manage which child app origins are considered trusted.
15016
+ *
15017
+ * @param action - The action to perform: 'ADD' or 'DELETE'.
15018
+ * @param appOrigins - An array of origins to add or remove (must be a non-empty array).
15019
+ * @returns A Promise resolving with the result of the action.
15020
+ * @throws Error if called from a non-top-level parent or if parameters are invalid.
15021
+ */
15022
+ function manageNAATrustedOrigins(action, appOrigins) {
15023
+ return nestedAppAuth_awaiter(this, void 0, void 0, function* () {
15024
+ if (window.parent !== window.top) {
15025
+ throw new Error('This API is only available in the top-level parent.');
15026
+ }
15027
+ if (!Array.isArray(appOrigins) || appOrigins.length === 0) {
15028
+ throw new Error(`The '${appOrigins}' parameter is required and must be a non-empty array.`);
15029
+ }
15030
+ const args = [new SerializableManageNAATrustedOriginArgs(action, appOrigins)];
15031
+ return callFunctionInHostAndHandleResponse('nestedAppAuth.manageNAATrustedOrigins', args, trustedOriginResponseHandler, getApiVersionTag(nestedAppAuth_hostEntityTelemetryVersionNumber, "nestedAppAuth.manageNAATrustedOrigins" /* ApiName.NestedAppAuth_ManageNAATrustedOrigins */));
15032
+ });
15033
+ }
15034
+ /**
15035
+ * Normalizes a given origin string by converting it to lowercase and extracting only the origin part.
15036
+ *
15037
+ * @param origin - A string representing a full URL.
15038
+ * @returns The normalized origin (scheme + host + port) in lowercase.
15039
+ * @throws Error if the input is not a valid URL.
15040
+ */
15041
+ function normalizeOrigin(origin) {
15042
+ try {
15043
+ const url = new URL(origin);
15044
+ return url.origin.toLowerCase(); // Normalize and return only the origin part
15045
+ }
15046
+ catch (error) {
15047
+ throw new Error(`Invalid origin provided: ${origin}`);
15048
+ }
15049
+ }
15050
+ /**
15051
+ * Serializable arguments for manageNAATrustedOrigins.
15052
+ */
15053
+ class SerializableManageNAATrustedOriginArgs {
15054
+ constructor(action, appOrigins) {
15055
+ this.action = action;
15056
+ this.appOrigins = appOrigins;
15057
+ }
15058
+ /**
15059
+ * Serializes the object to a JSON-compliant format.
15060
+ * @returns JSON representation of the arguments.
15061
+ */
15062
+ serialize() {
15063
+ return {
15064
+ action: this.action,
15065
+ appOrigins: this.appOrigins, // No need for conditional check, always included
15066
+ };
15067
+ }
15068
+ }
14635
15069
 
14636
15070
  ;// ./src/public/geoLocation/map.ts
14637
15071
  /**