@microsoft/teams-js 2.48.1 → 2.49.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.
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.48.1/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.49.0/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.48.1/js/MicrosoftTeams.min.js"
49
- integrity="sha384-opiKcSoAwE9QEI+cc408L9oI0NWev5vi/CLyCCX57M7GuRKrXlC4nOxJ9z6cBoXS"
48
+ src="https://res.cdn.office.net/teams-js/2.49.0/js/MicrosoftTeams.min.js"
49
+ integrity="sha384-7wAL7GWYFgbQUP3f6/vtioav57bCRJ7ndOZUan7+vnCnuM5fPwvCzX+W5DzyjBJ5"
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.48.1/dist/MicrosoftTeams.min.js"></script>
54
+ <script src="node_modules/@microsoft/teams-js@2.49.0/dist/MicrosoftTeams.min.js"></script>
55
55
 
56
56
  <!-- Microsoft Teams JavaScript API (via local) -->
57
57
  <script src="MicrosoftTeams.min.js"></script>
@@ -120,14 +120,6 @@ export declare const ORIGIN_LIST_FETCH_TIMEOUT_IN_MS: number;
120
120
  * Limited to Microsoft-internal use
121
121
  */
122
122
  export declare const validOriginsCdnEndpoint: URL;
123
- /**
124
- * @hidden
125
- * USer specified message origins should satisfy this test
126
- *
127
- * @internal
128
- * Limited to Microsoft-internal use
129
- */
130
- export declare const userOriginUrlValidationRegExp: RegExp;
131
123
  /**
132
124
  * @hidden
133
125
  * The protocol used for deep links into Teams
@@ -0,0 +1,50 @@
1
+ import { Debugger } from 'debug/src/browser';
2
+ /**
3
+ * @hidden
4
+ * @internal
5
+ * Limited to Microsoft-internal use.
6
+ *
7
+ * Implementation of URL pattern matching logic for validating origins against a list of allowed patterns.
8
+ */
9
+ export interface URLVerifier {
10
+ /**
11
+ * Checks if the given URL matches the pattern defined in the implementation.
12
+ * @param url - The URL to test against the pattern.
13
+ * @returns - True if the URL matches the pattern, false otherwise.
14
+ */
15
+ test: (url: URL) => boolean;
16
+ }
17
+ /**
18
+ * Checks if the provided host matches the given pattern, which may include a single wildcard segment.
19
+ * @param pattern - reference pattern
20
+ * @param host - candidate string
21
+ * @returns returns true if host matches pre-know valid pattern
22
+ *
23
+ * @example
24
+ * validateHostAgainstPattern('*.teams.microsoft.com', 'subdomain.teams.microsoft.com') returns true
25
+ * validateHostAgainstPattern('test.*.teams.microsoft.com', 'test.subdomain.teams.microsoft.com') returns true
26
+ * validateHostAgainstPattern('teams.microsoft.com', 'team.microsoft.com') returns false
27
+ * validateHostAgainstPattern('*.*.microsoft.com', 'test.team.microsoft.com') returns false
28
+ *
29
+ * @internal
30
+ * Limited to Microsoft-internal use
31
+ */
32
+ export declare function validateHostAgainstPattern(pattern: string, host: string): boolean;
33
+ /**
34
+ * @hidden
35
+ * @internal
36
+ * Limited to Microsoft-internal use.
37
+ *
38
+ * Checks if the provided pattern is valid for checking against URLs.
39
+ * @param pattern - The pattern to validate.
40
+ * @returns - True if the pattern is valid, false otherwise.
41
+ */
42
+ export declare function isValidPatternUrl(pattern: string): boolean;
43
+ /**
44
+ * @hidden
45
+ * @internal
46
+ * Limited to Microsoft-internal use.
47
+ *
48
+ * Creates a URL verifier based on the provided pattern.
49
+ */
50
+ export declare function createURLVerifier(pattern: string, logger: Debugger): URLVerifier | undefined;
@@ -211,6 +211,30 @@ export interface FilePreviewParameters {
211
211
  * Limited to Microsoft-internal use
212
212
  */
213
213
  conversationId?: string;
214
+ /**
215
+ * @hidden
216
+ * Optional; id of message where this file is shared (if applicable)
217
+ *
218
+ * @internal
219
+ * Limited to Microsoft-internal use
220
+ */
221
+ messageId?: string;
222
+ /**
223
+ * @hidden
224
+ * Optional; used internally to differentiate different callers from within an app
225
+ *
226
+ * @internal
227
+ * Limited to Microsoft-internal use
228
+ */
229
+ callerInfo?: string;
230
+ /**
231
+ * @hidden
232
+ * Optional; serialised string of atp data which the apps may pass to expediate safelink validations that run when a file is opened
233
+ *
234
+ * @internal
235
+ * Limited to Microsoft-internal use
236
+ */
237
+ atpData?: string;
214
238
  }
215
239
  /**
216
240
  * @hidden
@@ -517,7 +517,7 @@ export declare function getFrameContext(): FrameContexts | undefined;
517
517
  * @param validMessageOrigins - Optionally specify a list of cross-frame message origins. This parameter is used if you know that your app
518
518
  * will be hosted on a custom domain (i.e., not a standard Microsoft 365 host like Teams, Outlook, etc.) Most apps will never need
519
519
  * to pass a value for this parameter.
520
- * Any domains passed in the array must have the https: protocol on the string otherwise they will be ignored. Example: https://www.example.com
520
+ * Any domains passed in the array must define a scheme to be able to be processed. Examples: https://www.example.com, chrome://
521
521
  * @returns Promise that will be fulfilled when initialization has completed, or rejected if the initialization fails or times out
522
522
  */
523
523
  export declare function initialize(validMessageOrigins?: string[]): Promise<void>;
@@ -20,7 +20,7 @@ export interface StageViewParams {
20
20
  /**
21
21
  * The chat or channel ID.
22
22
  */
23
- threadId: string;
23
+ threadId?: string;
24
24
  /**
25
25
  * The messageId identifies a particular channel meeting within the channel as specified by the threadId above. This should be used only when trying to open the stage view for a channel meeting. It will be a no-op for other scenarios
26
26
  */
@@ -1 +1 @@
1
- import*as t from"../artifactsForCDN/validDomains.json.js";const i="2.0.1",s="2.0.2",e="2.0.3",n="2.0.4",o="2.0.1",a="1.9.0",r="2.0.0",m="1.7.0",l="1.8.0",d="2.0.0",h="1.9.0",p=t.validOrigins,c=1500,f=new URL("https://res.cdn.office.net/teams-js/validDomains/json/validDomains.json"),j=/^https:\/\//,v="https",y="teams.microsoft.com",D="The library has not yet been initialized",T="The runtime has not yet been initialized",b="The runtime version is not supported",u="The call was not properly started";export{c as ORIGIN_LIST_FETCH_TIMEOUT_IN_MS,m as captureImageMobileSupportVersion,i as defaultSDKVersionForCompatCheck,u as errorCallNotStarted,D as errorLibraryNotInitialized,T as errorRuntimeNotInitialized,b as errorRuntimeNotSupported,d as getMediaCallbackSupportVersion,o as getUserJoinedTeamsSupportedAndroidClientVersion,n as imageOutputFormatsAPISupportVersion,a as locationAPIsRequiredVersion,l as mediaAPISupportVersion,e as nonFullScreenVideoModeAPISupportVersion,r as peoplePickerRequiredVersion,h as scanBarCodeAPIMobileSupportVersion,y as teamsDeepLinkHost,v as teamsDeepLinkProtocol,j as userOriginUrlValidationRegExp,f as validOriginsCdnEndpoint,p as validOriginsFallback,s as videoAndImageMediaAPISupportVersion};
1
+ import*as i from"../artifactsForCDN/validDomains.json.js";const t="2.0.1",e="2.0.2",s="2.0.3",n="2.0.4",o="2.0.1",a="1.9.0",r="2.0.0",m="1.7.0",l="1.8.0",d="2.0.0",h="1.9.0",p=i.validOrigins,c=1500,f=new URL("https://res.cdn.office.net/teams-js/validDomains/json/validDomains.json"),j="https",v="teams.microsoft.com",y="The library has not yet been initialized",D="The runtime has not yet been initialized",T="The runtime version is not supported",b="The call was not properly started";export{c as ORIGIN_LIST_FETCH_TIMEOUT_IN_MS,m as captureImageMobileSupportVersion,t as defaultSDKVersionForCompatCheck,b as errorCallNotStarted,y as errorLibraryNotInitialized,D as errorRuntimeNotInitialized,T as errorRuntimeNotSupported,d as getMediaCallbackSupportVersion,o as getUserJoinedTeamsSupportedAndroidClientVersion,n as imageOutputFormatsAPISupportVersion,a as locationAPIsRequiredVersion,l as mediaAPISupportVersion,s as nonFullScreenVideoModeAPISupportVersion,r as peoplePickerRequiredVersion,h as scanBarCodeAPIMobileSupportVersion,v as teamsDeepLinkHost,j as teamsDeepLinkProtocol,f as validOriginsCdnEndpoint,p as validOriginsFallback,e as videoAndImageMediaAPISupportVersion};
@@ -1 +1 @@
1
- import{HostClientType as i}from"../public/constants.js";import{ErrorCode as t}from"../public/interfaces.js";import{isRuntimeInitialized as e}from"../public/runtime.js";import{defaultSDKVersionForCompatCheck as n,errorLibraryNotInitialized as o,userOriginUrlValidationRegExp as r}from"./constants.js";import{GlobalVars as l}from"./globalVars.js";import{getLogger as s}from"./telemetry.js";import{compareSDKVersions as a}from"./utils.js";const f=s("internal"),c=f.extend("ensureInitializeCalled"),d=f.extend("ensureInitialized");function p(){if(!l.initializeCalled)throw c(o),new Error(o)}function m(i,...t){if(!l.initializeCompleted)throw d("%s. initializeCalled: %s",o,l.initializeCalled.toString()),new Error(o);if(t&&t.length>0){let i=!1;for(let e=0;e<t.length;e++)if(t[e]===l.frameContext){i=!0;break}if(!i)throw new Error(`This call is only allowed in following contexts: ${JSON.stringify(t)}. Current context: "${l.frameContext}".`)}return e(i)}function u(i=n){const t=a(l.clientSupportedSDKVersion,i);return!isNaN(t)&&t>=0}function C(){return l.hostClientType==i.android||l.hostClientType==i.ios||l.hostClientType==i.ipados||l.hostClientType==i.visionOS}function h(i=n){if(!C()){throw{errorCode:t.NOT_SUPPORTED_ON_PLATFORM}}if(!u(i)){throw{errorCode:t.OLD_PLATFORM}}}function w(i){let t=l.additionalValidOrigins.concat(i.filter(i=>"string"==typeof i&&r.test(i)));const e={};t=t.filter(i=>!e[i]&&(e[i]=!0,!0)),l.additionalValidOrigins=t}export{p as ensureInitializeCalled,m as ensureInitialized,u as isCurrentSDKVersionAtLeast,C as isHostClientMobile,w as processAdditionalValidOrigins,h as throwExceptionIfMobileApiIsNotSupported};
1
+ import{HostClientType as i}from"../public/constants.js";import{ErrorCode as t}from"../public/interfaces.js";import{isRuntimeInitialized as r}from"../public/runtime.js";import{defaultSDKVersionForCompatCheck as e,errorLibraryNotInitialized as n}from"./constants.js";import{GlobalVars as o}from"./globalVars.js";import{getLogger as l}from"./telemetry.js";import{isValidPatternUrl as s}from"./urlPattern.js";import{compareSDKVersions as a}from"./utils.js";const f=l("internal"),c=f.extend("ensureInitializeCalled"),d=f.extend("ensureInitialized");function m(){if(!o.initializeCalled)throw c(n),new Error(n)}function p(i,...t){if(!o.initializeCompleted)throw d("%s. initializeCalled: %s",n,o.initializeCalled.toString()),new Error(n);if(t&&t.length>0){let i=!1;for(let r=0;r<t.length;r++)if(t[r]===o.frameContext){i=!0;break}if(!i)throw new Error(`This call is only allowed in following contexts: ${JSON.stringify(t)}. Current context: "${o.frameContext}".`)}return r(i)}function u(i=e){const t=a(o.clientSupportedSDKVersion,i);return!isNaN(t)&&t>=0}function C(){return o.hostClientType==i.android||o.hostClientType==i.ios||o.hostClientType==i.ipados||o.hostClientType==i.visionOS}function h(i=e){if(!C()){throw{errorCode:t.NOT_SUPPORTED_ON_PLATFORM}}if(!u(i)){throw{errorCode:t.OLD_PLATFORM}}}function w(i){let t=o.additionalValidOrigins.concat(i.filter(i=>"string"==typeof i&&s(i)));const r={};t=t.filter(i=>!r[i]&&(r[i]=!0,!0)),o.additionalValidOrigins=t}export{m as ensureInitializeCalled,p as ensureInitialized,u as isCurrentSDKVersionAtLeast,C as isHostClientMobile,w as processAdditionalValidOrigins,h as throwExceptionIfMobileApiIsNotSupported};
@@ -0,0 +1 @@
1
+ const t=/^[A-Za-z][A-Za-z\d+.-]*:\/\//;function e(t,e){const r=t.split("."),s=e.split(".");if(s.length!==r.length)return!1;let n=!1;for(let t=0;t<r.length;t++)if(r[t]!==s[t]){if("*"!==r[t])return!1;if(t===r.length-1||n)return!1;n=!0}return!0}class r{constructor(t,e,r){this.protocol=t,this.host=e,this.logger=r}static canUse(e){return t.test(e)}static create(t,e){const s=t.split("://");return new r(s[0],s[1],e.extend("InternalURLPattern"))}test(t){return this.logger("Testing URL %s against pattern protocol: %s, host: %s",t,this.protocol,this.host),t.protocol===`${this.protocol}:`&&(!t.host||e(this.host,t.host))}}function s(t){return r.canUse(t)}function n(t,e){if(r.canUse(t))return r.create(t,e);e("No URL verifier available for pattern: %s",t)}export{n as createURLVerifier,s as isValidPatternUrl,e as validateHostAgainstPattern};
@@ -1 +1 @@
1
- import{__awaiter as i}from"../../../../node_modules/.pnpm/@rollup_plugin-typescript@11.1.6_rollup@4.55.1_tslib@2.8.1_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
+ import{__awaiter as i}from"../../../../node_modules/.pnpm/@rollup_plugin-typescript@11.1.6_rollup@4.55.1_tslib@2.8.1_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 o}from"./globalVars.js";import{getLogger as e}from"./telemetry.js";import{validateHostAgainstPattern as l,createURLVerifier as s}from"./urlPattern.js";import{inServerSideRenderingEnvironment as a,isValidHttpsURL as c}from"./utils.js";let u=[];const d=e("validateOrigin");let f;function g(){return i(this,void 0,void 0,function*(){f||(yield m())})}function p(){return 0===u.length}function m(o=!1){return i(this,void 0,void 0,function*(){if(!p()&&!o)return u;if(f)return f;if(a())return u=n,n;{d("Initiating fetch call to acquire valid origins list from CDN");const i=new AbortController,o=setTimeout(()=>i.abort(),t);return f=fetch(r,{signal:i.signal}).then(i=>{if(clearTimeout(o),!i.ok)throw new Error("Invalid Response from Fetch Call");return d("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 d("isValidOriginsFromCDN call failed to validate origin: %s",i),!1}return!0}(JSON.stringify(i)))return u=i.validOrigins,u;throw new Error("Valid origins list retrieved from CDN is invalid")})}).catch(i=>("AbortError"===i.name?d(`validOrigins fetch call to CDN failed due to Timeout of ${t} ms. Defaulting to fallback list`):d("validOrigins fetch call to CDN failed with error: %s. Defaulting to fallback list",i),u=n,u)),f}})}function h(i,t){let r;try{const t=s(i,d);if(!t)return!1;r=t}catch(i){return!1}return r.test(t)}function v(i,t){const r=p()?n:u;return O(i,r)?Promise.resolve(!0):(d("Origin %s is not in the local valid origins list, fetching from CDN",i),m(t).then(t=>O(i,t)))}function O(i,t){for(const t of o.additionalValidOrigins)if(h(t,i))return!0;const r=i.host;return c(i)?!!t.some(i=>l(i,r))||(d("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,o.additionalValidOrigins),!1):(d("Origin %s is invalid because it is not using https protocol. Protocol being used: %s",i,i.protocol),!1)}g();export{g as prefetchOriginsFromCDN,v as validateOrigin};
@@ -1 +1 @@
1
- import{shouldEventBeRelayedToChild as e,sendMessageEventToChild as t}from"../internal/childCommunication.js";import{sendMessageToParent as n}from"../internal/communication.js";import{registerHandler as i}from"../internal/handlers.js";import{ensureInitialized as r}from"../internal/internalAPIs.js";import{getApiVersionTag as o}from"../internal/telemetry.js";import{getGenericOnCompleteHandler as s}from"../internal/utils.js";import{FrameContexts as l}from"../public/constants.js";import{runtime as a}from"../public/runtime.js";const m="v1";function p(e,t){r(a),n(o(m,"uploadCustomApp"),"uploadCustomApp",[e],t||s())}function c(e,t,i){r(a),n(o(m,"sendCustomMessage"),e,t,i)}function u(n,i){if(r(a),!e())throw new Error("The child window has not yet been initialized or is not present");t(n,i)}function d(e,t){r(a),i(o(m,"registerCustomHandler"),e,(...e)=>t.apply(this,e))}function f(e,t){r(a),i(o(m,"registerUserSettingsChangeHandler"),"userSettingsChange",t,!0,[e])}function w(e){r(a,l.content,l.sidePanel,l.task);const t=[e.entityId,e.title,e.description,e.type,e.objectUrl,e.downloadUrl,e.webPreviewUrl,e.webEditUrl,e.baseUrl,e.editFile,e.subEntityId,e.viewerAction,e.fileOpenPreference,e.conversationId,e.sizeInBytes];n(o(m,"openFilePreview"),"openFilePreview",t)}export{w as openFilePreview,d as registerCustomHandler,f as registerUserSettingsChangeHandler,u as sendCustomEvent,c as sendCustomMessage,p as uploadCustomApp};
1
+ import{shouldEventBeRelayedToChild as e,sendMessageEventToChild as t}from"../internal/childCommunication.js";import{sendMessageToParent as n}from"../internal/communication.js";import{registerHandler as i}from"../internal/handlers.js";import{ensureInitialized as r}from"../internal/internalAPIs.js";import{getApiVersionTag as o}from"../internal/telemetry.js";import{getGenericOnCompleteHandler as s}from"../internal/utils.js";import{FrameContexts as l}from"../public/constants.js";import{runtime as a}from"../public/runtime.js";const m="v1";function p(e,t){r(a),n(o(m,"uploadCustomApp"),"uploadCustomApp",[e],t||s())}function c(e,t,i){r(a),n(o(m,"sendCustomMessage"),e,t,i)}function d(n,i){if(r(a),!e())throw new Error("The child window has not yet been initialized or is not present");t(n,i)}function u(e,t){r(a),i(o(m,"registerCustomHandler"),e,(...e)=>t.apply(this,e))}function f(e,t){r(a),i(o(m,"registerUserSettingsChangeHandler"),"userSettingsChange",t,!0,[e])}function w(e){r(a,l.content,l.sidePanel,l.task);const t=[e.entityId,e.title,e.description,e.type,e.objectUrl,e.downloadUrl,e.webPreviewUrl,e.webEditUrl,e.baseUrl,e.editFile,e.subEntityId,e.viewerAction,e.fileOpenPreference,e.conversationId,e.sizeInBytes,e.messageId,e.callerInfo,e.atpData];n(o(m,"openFilePreview"),"openFilePreview",t)}export{w as openFilePreview,u as registerCustomHandler,f as registerUserSettingsChangeHandler,d as sendCustomEvent,c as sendCustomMessage,p as uploadCustomApp};
@@ -1 +1 @@
1
- const o="2.48.1";export{o as version};
1
+ const o="2.49.0";export{o as version};
@@ -2429,14 +2429,6 @@ const ORIGIN_LIST_FETCH_TIMEOUT_IN_MS = 1500;
2429
2429
  * Limited to Microsoft-internal use
2430
2430
  */
2431
2431
  const validOriginsCdnEndpoint = new URL('https://res.cdn.office.net/teams-js/validDomains/json/validDomains.json');
2432
- /**
2433
- * @hidden
2434
- * USer specified message origins should satisfy this test
2435
- *
2436
- * @internal
2437
- * Limited to Microsoft-internal use
2438
- */
2439
- const userOriginUrlValidationRegExp = /^https:\/\//;
2440
2432
  /**
2441
2433
  * @hidden
2442
2434
  * The protocol used for deep links into Teams
@@ -4677,7 +4669,7 @@ function isSerializable(arg) {
4677
4669
  * @hidden
4678
4670
  * Package version.
4679
4671
  */
4680
- const version = "2.48.1";
4672
+ const version = "2.49.0";
4681
4673
 
4682
4674
  ;// ./src/public/featureFlags.ts
4683
4675
  // 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.
@@ -4810,6 +4802,110 @@ function flushMessageQueue(targetWindow, targetOrigin, targetMessageQueue, targe
4810
4802
  }
4811
4803
  }
4812
4804
 
4805
+ ;// ./src/internal/urlPattern.ts
4806
+ /**
4807
+ * Regex for validating that a user-provided origin includes a protocol.
4808
+ */
4809
+ const userOriginUrlValidationRegExp = /^[A-Za-z][A-Za-z\d+.-]*:\/\//;
4810
+ /**
4811
+ * Checks if the provided host matches the given pattern, which may include a single wildcard segment.
4812
+ * @param pattern - reference pattern
4813
+ * @param host - candidate string
4814
+ * @returns returns true if host matches pre-know valid pattern
4815
+ *
4816
+ * @example
4817
+ * validateHostAgainstPattern('*.teams.microsoft.com', 'subdomain.teams.microsoft.com') returns true
4818
+ * validateHostAgainstPattern('test.*.teams.microsoft.com', 'test.subdomain.teams.microsoft.com') returns true
4819
+ * validateHostAgainstPattern('teams.microsoft.com', 'team.microsoft.com') returns false
4820
+ * validateHostAgainstPattern('*.*.microsoft.com', 'test.team.microsoft.com') returns false
4821
+ *
4822
+ * @internal
4823
+ * Limited to Microsoft-internal use
4824
+ */
4825
+ function validateHostAgainstPattern(pattern, host) {
4826
+ const patternSegments = pattern.split('.');
4827
+ const hostSegments = host.split('.');
4828
+ if (hostSegments.length !== patternSegments.length) {
4829
+ return false;
4830
+ }
4831
+ let hasUsedWildcard = false;
4832
+ for (let i = 0; i < patternSegments.length; i++) {
4833
+ if (patternSegments[i] === hostSegments[i]) {
4834
+ continue;
4835
+ }
4836
+ if (patternSegments[i] !== '*') {
4837
+ return false;
4838
+ }
4839
+ // Wildcard in the last segment (TLD position) is not allowed for security reasons. Additionally, only one wildcard segment is allowed to prevent overly permissive patterns.
4840
+ if (i === patternSegments.length - 1 || hasUsedWildcard) {
4841
+ return false;
4842
+ }
4843
+ hasUsedWildcard = true;
4844
+ continue;
4845
+ }
4846
+ return true;
4847
+ }
4848
+ /**
4849
+ * @hidden
4850
+ * @internal
4851
+ * Limited to Microsoft-internal use.
4852
+ *
4853
+ * Internal class when widely-available URLPattern is not available.
4854
+ */
4855
+ class InternalURLPattern {
4856
+ constructor(protocol, host, logger) {
4857
+ this.protocol = protocol;
4858
+ this.host = host;
4859
+ this.logger = logger;
4860
+ }
4861
+ /**
4862
+ * Checks if InternalURLPattern can be used with the provided pattern.
4863
+ */
4864
+ static canUse(pattern) {
4865
+ return userOriginUrlValidationRegExp.test(pattern);
4866
+ }
4867
+ /**
4868
+ * Creates an instance of InternalURLPattern with the provided pattern and logger.
4869
+ */
4870
+ static create(pattern, logger) {
4871
+ const splitPattern = pattern.split('://');
4872
+ return new InternalURLPattern(splitPattern[0], splitPattern[1], logger.extend('InternalURLPattern'));
4873
+ }
4874
+ /**
4875
+ * Tests the URL against the pattern.
4876
+ */
4877
+ test(url) {
4878
+ this.logger('Testing URL %s against pattern protocol: %s, host: %s', url, this.protocol, this.host);
4879
+ return url.protocol === `${this.protocol}:` && (!url.host || validateHostAgainstPattern(this.host, url.host));
4880
+ }
4881
+ }
4882
+ /**
4883
+ * @hidden
4884
+ * @internal
4885
+ * Limited to Microsoft-internal use.
4886
+ *
4887
+ * Checks if the provided pattern is valid for checking against URLs.
4888
+ * @param pattern - The pattern to validate.
4889
+ * @returns - True if the pattern is valid, false otherwise.
4890
+ */
4891
+ function isValidPatternUrl(pattern) {
4892
+ return InternalURLPattern.canUse(pattern);
4893
+ }
4894
+ /**
4895
+ * @hidden
4896
+ * @internal
4897
+ * Limited to Microsoft-internal use.
4898
+ *
4899
+ * Creates a URL verifier based on the provided pattern.
4900
+ */
4901
+ function createURLVerifier(pattern, logger) {
4902
+ if (InternalURLPattern.canUse(pattern)) {
4903
+ return InternalURLPattern.create(pattern, logger);
4904
+ }
4905
+ logger('No URL verifier available for pattern: %s', pattern);
4906
+ return undefined;
4907
+ }
4908
+
4813
4909
  ;// ./src/internal/internalAPIs.ts
4814
4910
 
4815
4911
 
@@ -4818,6 +4914,7 @@ function flushMessageQueue(targetWindow, targetOrigin, targetMessageQueue, targe
4818
4914
 
4819
4915
 
4820
4916
 
4917
+
4821
4918
  const internalLogger = getLogger('internal');
4822
4919
  const ensureInitializeCalledLogger = internalLogger.extend('ensureInitializeCalled');
4823
4920
  const ensureInitializedLogger = internalLogger.extend('ensureInitialized');
@@ -4927,7 +5024,7 @@ function throwExceptionIfMobileApiIsNotSupported(requiredVersion = defaultSDKVer
4927
5024
  */
4928
5025
  function processAdditionalValidOrigins(validMessageOrigins) {
4929
5026
  let combinedOriginUrls = GlobalVars.additionalValidOrigins.concat(validMessageOrigins.filter((_origin) => {
4930
- return typeof _origin === 'string' && userOriginUrlValidationRegExp.test(_origin);
5027
+ return typeof _origin === 'string' && isValidPatternUrl(_origin);
4931
5028
  }));
4932
5029
  const dedupUrls = {};
4933
5030
  combinedOriginUrls = combinedOriginUrls.filter((_originUrl) => {
@@ -5403,7 +5500,7 @@ logWhereTeamsJsIsBeingUsed();
5403
5500
  * @param validMessageOrigins - Optionally specify a list of cross-frame message origins. This parameter is used if you know that your app
5404
5501
  * will be hosted on a custom domain (i.e., not a standard Microsoft 365 host like Teams, Outlook, etc.) Most apps will never need
5405
5502
  * to pass a value for this parameter.
5406
- * Any domains passed in the array must have the https: protocol on the string otherwise they will be ignored. Example: https://www.example.com
5503
+ * Any domains passed in the array must define a scheme to be able to be processed. Examples: https://www.example.com, chrome://
5407
5504
  * @returns Promise that will be fulfilled when initialization has completed, or rejected if the initialization fails or times out
5408
5505
  */
5409
5506
  function initialize(validMessageOrigins) {
@@ -6756,6 +6853,7 @@ var validOrigins_awaiter = (undefined && undefined.__awaiter) || function (thisA
6756
6853
 
6757
6854
 
6758
6855
 
6856
+
6759
6857
  let validOriginsCache = [];
6760
6858
  const validateOriginLogger = getLogger('validateOrigin');
6761
6859
  let validOriginsPromise;
@@ -6840,30 +6938,23 @@ function isValidOriginsJSONValid(validOriginsJSON) {
6840
6938
  return true;
6841
6939
  }
6842
6940
  /**
6941
+ * Validates the origin against the full pattern including protocol and hostname.
6843
6942
  * @param pattern - reference pattern
6844
- * @param host - candidate string
6845
- * @returns returns true if host matches pre-know valid pattern
6846
- *
6847
- * @example
6848
- * validateHostAgainstPattern('*.teams.microsoft.com', 'subdomain.teams.microsoft.com') returns true
6849
- * validateHostAgainstPattern('teams.microsoft.com', 'team.microsoft.com') returns false
6850
- *
6851
- * @internal
6852
- * Limited to Microsoft-internal use
6943
+ * @param origin - candidate URL object
6853
6944
  */
6854
- function validateHostAgainstPattern(pattern, host) {
6855
- if (pattern.substring(0, 2) === '*.') {
6856
- const suffix = pattern.substring(1);
6857
- if (host.length > suffix.length &&
6858
- host.split('.').length === suffix.split('.').length &&
6859
- host.substring(host.length - suffix.length) === suffix) {
6860
- return true;
6945
+ function validateOriginAgainstFullPattern(pattern, origin) {
6946
+ let patternUrl;
6947
+ try {
6948
+ const createdURLVerifier = createURLVerifier(pattern, validateOriginLogger);
6949
+ if (!createdURLVerifier) {
6950
+ return false;
6861
6951
  }
6952
+ patternUrl = createdURLVerifier;
6862
6953
  }
6863
- else if (pattern === host) {
6864
- return true;
6954
+ catch (_a) {
6955
+ return false;
6865
6956
  }
6866
- return false;
6957
+ return patternUrl.test(origin);
6867
6958
  }
6868
6959
  /**
6869
6960
  * @internal
@@ -6875,29 +6966,25 @@ function validateOrigin(messageOrigin, disableCache) {
6875
6966
  if (validateOriginWithValidOriginsList(messageOrigin, localList)) {
6876
6967
  return Promise.resolve(true);
6877
6968
  }
6878
- else {
6879
- validateOriginLogger('Origin %s is not in the local valid origins list, fetching from CDN', messageOrigin);
6880
- return getValidOriginsListFromCDN(disableCache).then((validOriginsList) => {
6881
- return validateOriginWithValidOriginsList(messageOrigin, validOriginsList);
6882
- });
6883
- }
6969
+ validateOriginLogger('Origin %s is not in the local valid origins list, fetching from CDN', messageOrigin);
6970
+ return getValidOriginsListFromCDN(disableCache).then((validOriginsList) => validateOriginWithValidOriginsList(messageOrigin, validOriginsList));
6884
6971
  }
6885
6972
  function validateOriginWithValidOriginsList(messageOrigin, validOriginsList) {
6886
- // Check whether the url is in the pre-known allowlist or supplied by user
6973
+ // User provided additional valid origins take precedence as they do not require https protocol
6974
+ for (const domainOrPattern of GlobalVars.additionalValidOrigins) {
6975
+ if (validateOriginAgainstFullPattern(domainOrPattern, messageOrigin)) {
6976
+ return true;
6977
+ }
6978
+ }
6979
+ const messageOriginHost = messageOrigin.host;
6980
+ // For standard valid origins, only allow https protocol
6887
6981
  if (!isValidHttpsURL(messageOrigin)) {
6888
6982
  validateOriginLogger('Origin %s is invalid because it is not using https protocol. Protocol being used: %s', messageOrigin, messageOrigin.protocol);
6889
6983
  return false;
6890
6984
  }
6891
- const messageOriginHost = messageOrigin.host;
6892
6985
  if (validOriginsList.some((pattern) => validateHostAgainstPattern(pattern, messageOriginHost))) {
6893
6986
  return true;
6894
6987
  }
6895
- for (const domainOrPattern of GlobalVars.additionalValidOrigins) {
6896
- const pattern = domainOrPattern.substring(0, 8) === 'https://' ? domainOrPattern.substring(8) : domainOrPattern;
6897
- if (validateHostAgainstPattern(pattern, messageOriginHost)) {
6898
- return true;
6899
- }
6900
- }
6901
6988
  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);
6902
6989
  return false;
6903
6990
  }
@@ -9305,6 +9392,9 @@ function openFilePreview(filePreviewParameters) {
9305
9392
  filePreviewParameters.fileOpenPreference,
9306
9393
  filePreviewParameters.conversationId,
9307
9394
  filePreviewParameters.sizeInBytes,
9395
+ filePreviewParameters.messageId,
9396
+ filePreviewParameters.callerInfo,
9397
+ filePreviewParameters.atpData,
9308
9398
  ];
9309
9399
  sendMessageToParent(getApiVersionTag(privateAPIsTelemetryVersionNumber, "openFilePreview" /* ApiName.PrivateAPIs_OpenFilePreview */), 'openFilePreview', params);
9310
9400
  }