@microsoft/teams-js 2.39.0 → 2.39.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -24,7 +24,7 @@ To install the stable [version](https://learn.microsoft.com/javascript/api/overv
24
24
 
25
25
  ### Production
26
26
 
27
- You can reference these files directly [from here](https://res.cdn.office.net/teams-js/2.39.0/js/MicrosoftTeams.min.js) or point your package manager at them.
27
+ You can reference these files directly [from here](https://res.cdn.office.net/teams-js/2.39.1/js/MicrosoftTeams.min.js) or point your package manager at them.
28
28
 
29
29
  ## Usage
30
30
 
@@ -45,13 +45,13 @@ Reference the library inside of your `.html` page using:
45
45
  ```html
46
46
  <!-- Microsoft Teams JavaScript API (via CDN) -->
47
47
  <script
48
- src="https://res.cdn.office.net/teams-js/2.39.0/js/MicrosoftTeams.min.js"
49
- integrity="sha384-XYPfud/y4+g4RJ1EBfLD8IVybNuKXSda4PyKOc8h56srGBwitmBqbBWHb0mNWtfd"
48
+ src="https://res.cdn.office.net/teams-js/2.39.1/js/MicrosoftTeams.min.js"
49
+ integrity="sha384-DCaADE5ucxq02uymDGfLHqBklxuM03ZONTCmqdwEFNouwR1kHsPHVT1UYOyb3X72"
50
50
  crossorigin="anonymous"
51
51
  ></script>
52
52
 
53
53
  <!-- Microsoft Teams JavaScript API (via npm) -->
54
- <script src="node_modules/@microsoft/teams-js@2.39.0/dist/MicrosoftTeams.min.js"></script>
54
+ <script src="node_modules/@microsoft/teams-js@2.39.1/dist/MicrosoftTeams.min.js"></script>
55
55
 
56
56
  <!-- Microsoft Teams JavaScript API (via local) -->
57
57
  <script src="MicrosoftTeams.min.js"></script>
@@ -4,3 +4,10 @@ export declare function prefetchOriginsFromCDN(): Promise<void>;
4
4
  * Limited to Microsoft-internal use
5
5
  */
6
6
  export declare function validateOrigin(messageOrigin: URL, disableCache?: boolean): Promise<boolean>;
7
+ /**
8
+ * @internal
9
+ * Limited to Microsoft-internal use
10
+ *
11
+ * This function is only used for testing to reset the valid origins cache and ignore prefetched values.
12
+ */
13
+ export declare function resetValidOriginsCache(): void;
@@ -54,8 +54,17 @@ export interface ServerEmailContent extends BaseEmailContent {
54
54
  * Limited to Microsoft-internal use
55
55
  */
56
56
  export interface DraftEmailContent extends BaseEmailContent {
57
+ responseToEmailId?: string;
57
58
  savedTime?: Date;
58
59
  }
60
+ /**
61
+ * @hidden
62
+ *
63
+ * Interface for draft email content (no id, times optional)
64
+ *
65
+ * @internal
66
+ * Limited to Microsoft-internal use
67
+ */
59
68
  export type EmailContent = ServerEmailContent | DraftEmailContent;
60
69
  /**
61
70
  * @hidden
@@ -207,6 +216,15 @@ export interface MixedContent {
207
216
  * Limited to Microsoft-internal use
208
217
  */
209
218
  export type ContentItem = EmailContent | TextSelection | MediaSelection | CalendarInviteContent | WebPageContent | MixedContent;
219
+ /**
220
+ * @hidden
221
+ *
222
+ * The Content interface represents the content data structure used in the side panel.
223
+ * It si the payload received by the copilot app from the hub.
224
+ *
225
+ * @internal
226
+ * Limited to Microsoft-internal use
227
+ */
210
228
  export interface Content {
211
229
  userAction?: string;
212
230
  contentType: ContentItemType.CALENDAR_INVITE | ContentItemType.EMAIL | ContentItemType.MEDIA | ContentItemType.TEXT | ContentItemType.WEB_PAGE | ContentItemType.MIXED;
@@ -217,6 +235,14 @@ export interface Content {
217
235
  error_code?: string;
218
236
  status?: string;
219
237
  }
238
+ /**
239
+ * @hidden
240
+ *
241
+ * The ContentRequest interface represents the request params sent to the hub to fetch content.
242
+ *
243
+ * @internal
244
+ * Limited to Microsoft-internal use
245
+ */
220
246
  export interface ContentRequest {
221
247
  localEndpointInfo: string;
222
248
  }
@@ -17,7 +17,7 @@
17
17
  * @internal
18
18
  * Limited to Microsoft-internal use
19
19
  */
20
- export declare const version = "1.0.0";
20
+ export declare const version = "1.0.1";
21
21
  /**
22
22
  * @beta
23
23
  * @hidden
@@ -1 +1 @@
1
- var o=["teams.microsoft.com","teams.microsoft.us","gov.teams.microsoft.us","dod.teams.microsoft.us","int.teams.microsoft.com","outlook.office.com","outlook-sdf.office.com","outlook.office365.com","outlook-sdf.office365.com","outlook.live.com","outlook-sdf.live.com","teams.live.com","local.teams.live.com","local.teams.live.com:8080","local.teams.office.com","local.teams.office.com:8080","devspaces.skype.com","*.www.office.com","www.office.com","word.office.com","excel.office.com","powerpoint.office.com","www.officeppe.com","*.www.microsoft365.com","www.microsoft365.com","bing.com","edgeservices.bing.com","work.bing.com","www.bing.com","www.staging-bing-int.com","*.cloud.microsoft","*.m365.cloud.microsoft","chatuxmanager.svc.cloud.microsoft","copilot.microsoft.com","windows.msn.com","fa000000125.resources.office.net","fa000000129.resources.office.net","fa000000124.resources.office.net","fa000000128.resources.office.net","fa000000136.resources.office.net"],c={validOrigins:o};export{c as default,o as validOrigins};
1
+ var o=["teams.microsoft.com","teams.microsoft.us","gov.teams.microsoft.us","dod.teams.microsoft.us","int.teams.microsoft.com","outlook.office.com","outlook-sdf.office.com","outlook.office365.com","outlook-sdf.office365.com","outlook.live.com","outlook-sdf.live.com","teams.live.com","local.teams.live.com","local.teams.live.com:8080","local.teams.office.com","local.teams.office.com:8080","devspaces.skype.com","*.www.office.com","www.office.com","word.office.com","excel.office.com","powerpoint.office.com","www.officeppe.com","*.www.microsoft365.com","www.microsoft365.com","bing.com","edgeservices.bing.com","work.bing.com","www.bing.com","www.staging-bing-int.com","*.cloud.microsoft","*.m365.cloud.microsoft","*.outlook.cloud.microsoft","chatuxmanager.svc.cloud.microsoft","copilot.microsoft.com","windows.msn.com","fa000000125.resources.office.net","fa000000129.resources.office.net","fa000000124.resources.office.net","fa000000128.resources.office.net","fa000000136.resources.office.net"],c={validOrigins:o};export{c as default,o as validOrigins};
@@ -1 +1 @@
1
- import{__awaiter as i}from"../../../../node_modules/.pnpm/@rollup_plugin-typescript@11.1.6_rollup@4.24.4_tslib@2.6.3_typescript@4.9.5/node_modules/tslib/tslib.es6.js";import{ORIGIN_LIST_FETCH_TIMEOUT_IN_MS as t,validOriginsCdnEndpoint as r,validOriginsFallback as n}from"./constants.js";import{GlobalVars as e}from"./globalVars.js";import{getLogger as o}from"./telemetry.js";import{inServerSideRenderingEnvironment as l,isValidHttpsURL as s}from"./utils.js";let a=[];const u=o("validateOrigin");function c(){return i(this,void 0,void 0,(function*(){yield d()}))}function d(e=!1){return i(this,void 0,void 0,(function*(){if(0!==a.length&&!e)return a;if(l())return a=n,n;{u("Initiating fetch call to acquire valid origins list from CDN");const i=new AbortController,e=setTimeout((()=>i.abort()),t);return fetch(r,{signal:i.signal}).then((i=>{if(clearTimeout(e),!i.ok)throw new Error("Invalid Response from Fetch Call");return u("Fetch call completed and retrieved valid origins list from CDN"),i.json().then((i=>{if(function(i){let t=JSON.parse(i);try{t=JSON.parse(i)}catch(i){return!1}if(!t.validOrigins)return!1;for(const i of t.validOrigins)try{new URL("https://"+i)}catch(t){return u("isValidOriginsFromCDN call failed to validate origin: %s",i),!1}return!0}(JSON.stringify(i)))return a=i.validOrigins,a;throw new Error("Valid origins list retrieved from CDN is invalid")}))})).catch((i=>("AbortError"===i.name?u(`validOrigins fetch call to CDN failed due to Timeout of ${t} ms. Defaulting to fallback list`):u("validOrigins fetch call to CDN failed with error: %s. Defaulting to fallback list",i),a=n,a)))}}))}function f(i,t){if("*."===i.substring(0,2)){const r=i.substring(1);if(t.length>r.length&&t.split(".").length===r.split(".").length&&t.substring(t.length-r.length)===r)return!0}else if(i===t)return!0;return!1}function g(i,t){return d(t).then((t=>{if(!s(i))return u("Origin %s is invalid because it is not using https protocol. Protocol being used: %s",i,i.protocol),!1;const r=i.host;if(t.some((i=>f(i,r))))return!0;for(const i of e.additionalValidOrigins){if(f("https://"===i.substring(0,8)?i.substring(8):i,r))return!0}return u("Origin %s is invalid because it is not an origin approved by this library or included in the call to app.initialize.\nOrigins approved by this library: %o\nOrigins included in app.initialize: %o",i,t,e.additionalValidOrigins),!1}))}c();export{c as prefetchOriginsFromCDN,g as validateOrigin};
1
+ import{__awaiter as i}from"../../../../node_modules/.pnpm/@rollup_plugin-typescript@11.1.6_rollup@4.24.4_tslib@2.6.3_typescript@4.9.5/node_modules/tslib/tslib.es6.js";import{ORIGIN_LIST_FETCH_TIMEOUT_IN_MS as t,validOriginsCdnEndpoint as r,validOriginsFallback as n}from"./constants.js";import{GlobalVars as e}from"./globalVars.js";import{getLogger as o}from"./telemetry.js";import{inServerSideRenderingEnvironment as l,isValidHttpsURL as s}from"./utils.js";let a=[];const u=o("validateOrigin");let c;function f(){return i(this,void 0,void 0,(function*(){c||(yield g())}))}function d(){return 0===a.length}function g(e=!1){return i(this,void 0,void 0,(function*(){if(!d()&&!e)return a;if(c)return c;if(l())return a=n,n;{u("Initiating fetch call to acquire valid origins list from CDN");const i=new AbortController,e=setTimeout((()=>i.abort()),t);return c=fetch(r,{signal:i.signal}).then((i=>{if(clearTimeout(e),!i.ok)throw new Error("Invalid Response from Fetch Call");return u("Fetch call completed and retrieved valid origins list from CDN"),i.json().then((i=>{if(function(i){let t=JSON.parse(i);try{t=JSON.parse(i)}catch(i){return!1}if(!t.validOrigins)return!1;for(const i of t.validOrigins)try{new URL("https://"+i)}catch(t){return u("isValidOriginsFromCDN call failed to validate origin: %s",i),!1}return!0}(JSON.stringify(i)))return a=i.validOrigins,a;throw new Error("Valid origins list retrieved from CDN is invalid")}))})).catch((i=>("AbortError"===i.name?u(`validOrigins fetch call to CDN failed due to Timeout of ${t} ms. Defaulting to fallback list`):u("validOrigins fetch call to CDN failed with error: %s. Defaulting to fallback list",i),a=n,a))),c}}))}function p(i,t){if("*."===i.substring(0,2)){const r=i.substring(1);if(t.length>r.length&&t.split(".").length===r.split(".").length&&t.substring(t.length-r.length)===r)return!0}else if(i===t)return!0;return!1}function h(i,t){const r=d()?n:a;return m(i,r)?Promise.resolve(!0):(u("Origin %s is not in the local valid origins list, fetching from CDN",i),g(t).then((t=>m(i,t))))}function m(i,t){if(!s(i))return u("Origin %s is invalid because it is not using https protocol. Protocol being used: %s",i,i.protocol),!1;const r=i.host;if(t.some((i=>p(i,r))))return!0;for(const i of e.additionalValidOrigins){if(p("https://"===i.substring(0,8)?i.substring(8):i,r))return!0}return u("Origin %s is invalid because it is not an origin approved by this library or included in the call to app.initialize.\nOrigins approved by this library: %o\nOrigins included in app.initialize: %o",i,t,e.additionalValidOrigins),!1}f();export{f as prefetchOriginsFromCDN,h as validateOrigin};
@@ -1 +1 @@
1
- import e from"../../../../../node_modules/.pnpm/uuid@9.0.1/node_modules/uuid/dist/esm-browser/v4.js";const t="1.0.0",o={onMessage:function(e,t){if(!e||!e.data||"object"!=typeof e.data||null===e.data)return void a("Invalid message format, ignoring. Message: %o",e);if(!function(e,t){if(e&&e!==window.top)return a("Should not process message because it is not coming from the top window"),!1;if(t===n)try{return"https:"===new URL(t).protocol}catch(e){return d("Invalid message origin URL:",e),!1}return!1}(e.source,e.origin))return void a("Message source/origin not allowed, ignoring.");const{args:o}=e.data,[,r]=null!=o?o:[],i=(()=>{try{return JSON.parse(r)}catch(e){return d("Failed to parse response message:",e),null}})();if(!i||"NestedAppAuthResponse"!==i.messageType)return void a("Invalid response format, ignoring. Message: %o",e);t(r)}};let n=null,r=!1;function i(t,i,p=!1){if(r=p,!t)throw new Error("Cannot polyfill nestedAppAuthBridge as the current window does not exist");if(!i)throw new Error("Top origin is required to initialize the Nested App Auth Bridge");try{const e=new URL(i);if("https:"!==e.protocol)throw new Error(`Invalid top origin: ${i}. Only HTTPS origins are allowed.`);n=e.origin}catch(e){throw new Error(`Failed to initialize bridge: invalid top origin: ${i}`)}const u=t;if(u.nestedAppAuthBridge)return void a("Nested App Auth Bridge is already present");const g=function(t){const r=new WeakMap,{onMessage:i}=o,p=e=>t=>i(t,e);return{addEventListener:(e,o)=>{if("message"===e){const n=p(o);r.set(o,n),t.addEventListener(e,n)}else a(`Event ${e} is not supported by nestedAppAuthBridge`)},postMessage:o=>{if(!t.top)throw new Error("window.top is not available for posting messages");try{const r=JSON.parse(o);if("object"==typeof r&&"NestedAppAuthRequest"===r.messageType){const r=function(t){const o=Date.now();return{id:s(),uuid:e(),func:"nestedAppAuth.execute",timestamp:o,apiVersionTag:"v2_nestedAppAuth.execute",monotonicTimestamp:o,args:[],data:t}}(o);if(t===t.top||!n)return void d("Not in an embedded iframe; skipping postMessage.");t.top.postMessage(r,n)}}catch(e){return void d("Failed to parse message:",e,"Original message:",o)}},removeEventListener:(e,o)=>{const n=r.get(o);n&&(t.removeEventListener(e,n),r.delete(o))}}}(u);g&&(u.nestedAppAuthBridge=g)}function s(){return"undefined"!=typeof crypto&&crypto.randomUUID?crypto.randomUUID():Math.random().toString(36).substring(2,11)}function a(...e){r&&console.log(...e)}function d(...e){r&&console.error(...e)}export{i as initialize,t as version};
1
+ import e from"../../../../../node_modules/.pnpm/uuid@9.0.1/node_modules/uuid/dist/esm-browser/v4.js";const t="1.0.1",n={onMessage:function(e,t){if(!e||!e.data||"object"!=typeof e.data||null===e.data)return void a("Invalid message format, ignoring. Message: %o",e);if(!function(e,t){if(t===o)try{return"https:"===new URL(t).protocol}catch(e){return d("Invalid message origin URL:",e),!1}return!1}(e.source,e.origin))return void a("Message source/origin not allowed, ignoring.");const{args:n}=e.data,[,r]=null!=n?n:[],i=(()=>{try{return JSON.parse(r)}catch(e){return d("Failed to parse response message:",e),null}})();if(!i||"NestedAppAuthResponse"!==i.messageType)return void a("Invalid response format, ignoring. Message: %o",e);t(r)}};let o=null,r=!1;function i(t,i,p=!1){if(r=p,!t)throw new Error("Cannot polyfill nestedAppAuthBridge as the current window does not exist");if(!i)throw new Error("Top origin is required to initialize the Nested App Auth Bridge");try{const e=new URL(i);if("https:"!==e.protocol)throw new Error(`Invalid top origin: ${i}. Only HTTPS origins are allowed.`);o=e.origin}catch(e){throw new Error(`Failed to initialize bridge: invalid top origin: ${i}`)}const u=t;if(u.nestedAppAuthBridge)return void a("Nested App Auth Bridge is already present");const g=function(t){const r=new WeakMap,{onMessage:i}=n,p=e=>t=>i(t,e);return{addEventListener:(e,n)=>{if("message"===e){const o=p(n);r.set(n,o),t.addEventListener(e,o)}else a(`Event ${e} is not supported by nestedAppAuthBridge`)},postMessage:n=>{if(!t.top)throw new Error("window.top is not available for posting messages");try{const r=JSON.parse(n);if("object"==typeof r&&"NestedAppAuthRequest"===r.messageType){const r=function(t){const n=Date.now();return{id:s(),uuid:e(),func:"nestedAppAuth.execute",timestamp:n,apiVersionTag:"v2_nestedAppAuth.execute",monotonicTimestamp:n,args:[],data:t}}(n);if(t===t.top||!o)return void d("Not in an embedded iframe; skipping postMessage.");t.top.postMessage(r,o)}}catch(e){return void d("Failed to parse message:",e,"Original message:",n)}},removeEventListener:(e,n)=>{const o=r.get(n);o&&(t.removeEventListener(e,o),r.delete(n))}}}(u);g&&(u.nestedAppAuthBridge=g)}function s(){return"undefined"!=typeof crypto&&crypto.randomUUID?crypto.randomUUID():Math.random().toString(36).substring(2,11)}function a(...e){r&&console.log(...e)}function d(...e){r&&console.error(...e)}export{i as initialize,t as version};
@@ -1 +1 @@
1
- const o="2.39.0";export{o as version};
1
+ const o="2.39.1";export{o as version};
@@ -2231,7 +2231,7 @@ var ClipboardSupportedMimeType;
2231
2231
  })(ClipboardSupportedMimeType || (ClipboardSupportedMimeType = {}));
2232
2232
 
2233
2233
  ;// ./src/artifactsForCDN/validDomains.json
2234
- const validDomains_namespaceObject = /*#__PURE__*/JSON.parse('{"validOrigins":["teams.microsoft.com","teams.microsoft.us","gov.teams.microsoft.us","dod.teams.microsoft.us","int.teams.microsoft.com","outlook.office.com","outlook-sdf.office.com","outlook.office365.com","outlook-sdf.office365.com","outlook.live.com","outlook-sdf.live.com","teams.live.com","local.teams.live.com","local.teams.live.com:8080","local.teams.office.com","local.teams.office.com:8080","devspaces.skype.com","*.www.office.com","www.office.com","word.office.com","excel.office.com","powerpoint.office.com","www.officeppe.com","*.www.microsoft365.com","www.microsoft365.com","bing.com","edgeservices.bing.com","work.bing.com","www.bing.com","www.staging-bing-int.com","*.cloud.microsoft","*.m365.cloud.microsoft","chatuxmanager.svc.cloud.microsoft","copilot.microsoft.com","windows.msn.com","fa000000125.resources.office.net","fa000000129.resources.office.net","fa000000124.resources.office.net","fa000000128.resources.office.net","fa000000136.resources.office.net"]}');
2234
+ const validDomains_namespaceObject = /*#__PURE__*/JSON.parse('{"validOrigins":["teams.microsoft.com","teams.microsoft.us","gov.teams.microsoft.us","dod.teams.microsoft.us","int.teams.microsoft.com","outlook.office.com","outlook-sdf.office.com","outlook.office365.com","outlook-sdf.office365.com","outlook.live.com","outlook-sdf.live.com","teams.live.com","local.teams.live.com","local.teams.live.com:8080","local.teams.office.com","local.teams.office.com:8080","devspaces.skype.com","*.www.office.com","www.office.com","word.office.com","excel.office.com","powerpoint.office.com","www.officeppe.com","*.www.microsoft365.com","www.microsoft365.com","bing.com","edgeservices.bing.com","work.bing.com","www.bing.com","www.staging-bing-int.com","*.cloud.microsoft","*.m365.cloud.microsoft","*.outlook.cloud.microsoft","chatuxmanager.svc.cloud.microsoft","copilot.microsoft.com","windows.msn.com","fa000000125.resources.office.net","fa000000129.resources.office.net","fa000000124.resources.office.net","fa000000128.resources.office.net","fa000000136.resources.office.net"]}');
2235
2235
  var artifactsForCDN_validDomains_namespaceObject = /*#__PURE__*/__webpack_require__.t(validDomains_namespaceObject, 2);
2236
2236
  ;// ./src/internal/constants.ts
2237
2237
 
@@ -4585,7 +4585,7 @@ function isSerializable(arg) {
4585
4585
  * @hidden
4586
4586
  * Package version.
4587
4587
  */
4588
- const version = "2.39.0";
4588
+ const version = "2.39.1";
4589
4589
 
4590
4590
  ;// ./src/public/featureFlags.ts
4591
4591
  // 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.
@@ -6641,9 +6641,12 @@ var validOrigins_awaiter = (undefined && undefined.__awaiter) || function (thisA
6641
6641
 
6642
6642
  let validOriginsCache = [];
6643
6643
  const validateOriginLogger = getLogger('validateOrigin');
6644
+ let validOriginsPromise;
6644
6645
  function prefetchOriginsFromCDN() {
6645
6646
  return validOrigins_awaiter(this, void 0, void 0, function* () {
6646
- yield getValidOriginsListFromCDN();
6647
+ if (!validOriginsPromise) {
6648
+ yield getValidOriginsListFromCDN();
6649
+ }
6647
6650
  });
6648
6651
  }
6649
6652
  function isValidOriginsCacheEmpty() {
@@ -6654,11 +6657,15 @@ function getValidOriginsListFromCDN(shouldDisableCache = false) {
6654
6657
  if (!isValidOriginsCacheEmpty() && !shouldDisableCache) {
6655
6658
  return validOriginsCache;
6656
6659
  }
6660
+ if (validOriginsPromise) {
6661
+ // Fetch has already been initiated, return the existing promise
6662
+ return validOriginsPromise;
6663
+ }
6657
6664
  if (!inServerSideRenderingEnvironment()) {
6658
6665
  validateOriginLogger('Initiating fetch call to acquire valid origins list from CDN');
6659
6666
  const controller = new AbortController();
6660
6667
  const timeoutId = setTimeout(() => controller.abort(), ORIGIN_LIST_FETCH_TIMEOUT_IN_MS);
6661
- return fetch(validOriginsCdnEndpoint, { signal: controller.signal })
6668
+ validOriginsPromise = fetch(validOriginsCdnEndpoint, { signal: controller.signal })
6662
6669
  .then((response) => {
6663
6670
  clearTimeout(timeoutId);
6664
6671
  if (!response.ok) {
@@ -6685,6 +6692,7 @@ function getValidOriginsListFromCDN(shouldDisableCache = false) {
6685
6692
  validOriginsCache = validOriginsFallback;
6686
6693
  return validOriginsCache;
6687
6694
  });
6695
+ return validOriginsPromise;
6688
6696
  }
6689
6697
  else {
6690
6698
  validOriginsCache = validOriginsFallback;
@@ -6745,25 +6753,46 @@ function validateHostAgainstPattern(pattern, host) {
6745
6753
  * Limited to Microsoft-internal use
6746
6754
  */
6747
6755
  function validateOrigin(messageOrigin, disableCache) {
6748
- return getValidOriginsListFromCDN(disableCache).then((validOriginsList) => {
6749
- // Check whether the url is in the pre-known allowlist or supplied by user
6750
- if (!isValidHttpsURL(messageOrigin)) {
6751
- validateOriginLogger('Origin %s is invalid because it is not using https protocol. Protocol being used: %s', messageOrigin, messageOrigin.protocol);
6752
- return false;
6753
- }
6754
- const messageOriginHost = messageOrigin.host;
6755
- if (validOriginsList.some((pattern) => validateHostAgainstPattern(pattern, messageOriginHost))) {
6756
+ // Try origin against the cache or hardcoded fallback list first before fetching from CDN
6757
+ const localList = !disableCache && !isValidOriginsCacheEmpty() ? validOriginsCache : validOriginsFallback;
6758
+ if (validateOriginWithValidOriginsList(messageOrigin, localList)) {
6759
+ return Promise.resolve(true);
6760
+ }
6761
+ else {
6762
+ validateOriginLogger('Origin %s is not in the local valid origins list, fetching from CDN', messageOrigin);
6763
+ return getValidOriginsListFromCDN(disableCache).then((validOriginsList) => {
6764
+ return validateOriginWithValidOriginsList(messageOrigin, validOriginsList);
6765
+ });
6766
+ }
6767
+ }
6768
+ function validateOriginWithValidOriginsList(messageOrigin, validOriginsList) {
6769
+ // Check whether the url is in the pre-known allowlist or supplied by user
6770
+ if (!isValidHttpsURL(messageOrigin)) {
6771
+ validateOriginLogger('Origin %s is invalid because it is not using https protocol. Protocol being used: %s', messageOrigin, messageOrigin.protocol);
6772
+ return false;
6773
+ }
6774
+ const messageOriginHost = messageOrigin.host;
6775
+ if (validOriginsList.some((pattern) => validateHostAgainstPattern(pattern, messageOriginHost))) {
6776
+ return true;
6777
+ }
6778
+ for (const domainOrPattern of GlobalVars.additionalValidOrigins) {
6779
+ const pattern = domainOrPattern.substring(0, 8) === 'https://' ? domainOrPattern.substring(8) : domainOrPattern;
6780
+ if (validateHostAgainstPattern(pattern, messageOriginHost)) {
6756
6781
  return true;
6757
6782
  }
6758
- for (const domainOrPattern of GlobalVars.additionalValidOrigins) {
6759
- const pattern = domainOrPattern.substring(0, 8) === 'https://' ? domainOrPattern.substring(8) : domainOrPattern;
6760
- if (validateHostAgainstPattern(pattern, messageOriginHost)) {
6761
- return true;
6762
- }
6763
- }
6764
- validateOriginLogger('Origin %s is invalid because it is not an origin approved by this library or included in the call to app.initialize.\nOrigins approved by this library: %o\nOrigins included in app.initialize: %o', messageOrigin, validOriginsList, GlobalVars.additionalValidOrigins);
6765
- return false;
6766
- });
6783
+ }
6784
+ validateOriginLogger('Origin %s is invalid because it is not an origin approved by this library or included in the call to app.initialize.\nOrigins approved by this library: %o\nOrigins included in app.initialize: %o', messageOrigin, validOriginsList, GlobalVars.additionalValidOrigins);
6785
+ return false;
6786
+ }
6787
+ /**
6788
+ * @internal
6789
+ * Limited to Microsoft-internal use
6790
+ *
6791
+ * This function is only used for testing to reset the valid origins cache and ignore prefetched values.
6792
+ */
6793
+ function resetValidOriginsCache() {
6794
+ validOriginsCache = [];
6795
+ validOriginsPromise = undefined;
6767
6796
  }
6768
6797
  prefetchOriginsFromCDN();
6769
6798
 
@@ -11287,7 +11316,7 @@ function messageChannels_isSupported() {
11287
11316
  * @internal
11288
11317
  * Limited to Microsoft-internal use
11289
11318
  */
11290
- const nestedAppAuthBridge_version = '1.0.0';
11319
+ const nestedAppAuthBridge_version = '1.0.1';
11291
11320
  /**
11292
11321
  * Bridge handlers used for processing messages.
11293
11322
  */
@@ -11433,11 +11462,6 @@ function nestedAppAuthBridge_processAuthBridgeMessage(evt, onMessageReceived) {
11433
11462
  onMessageReceived(message);
11434
11463
  }
11435
11464
  function nestedAppAuthBridge_shouldProcessIncomingMessage(messageSource, messageOrigin) {
11436
- // Reject messages if they are not from the top window
11437
- if (messageSource && messageSource !== window.top) {
11438
- log('Should not process message because it is not coming from the top window');
11439
- return false;
11440
- }
11441
11465
  // Check if messageOrigin matches topOriginForNAA
11442
11466
  if (messageOrigin === topOriginForNAA) {
11443
11467
  try {