@microsoft/teams-js 2.48.1 → 2.49.0-beta.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/dist/esm/packages/teams-js/dts/internal/constants.d.ts +0 -8
- package/dist/esm/packages/teams-js/dts/internal/urlPattern.d.ts +47 -0
- package/dist/esm/packages/teams-js/dts/public/app/app.d.ts +1 -1
- package/dist/esm/packages/teams-js/dts/public/stageView/stageView.d.ts +1 -1
- package/dist/esm/packages/teams-js/src/internal/constants.js +1 -1
- package/dist/esm/packages/teams-js/src/internal/internalAPIs.js +1 -1
- package/dist/esm/packages/teams-js/src/internal/urlPattern.js +1 -0
- package/dist/esm/packages/teams-js/src/internal/validOrigins.js +1 -1
- package/dist/esm/packages/teams-js/src/public/version.js +1 -1
- package/dist/umd/MicrosoftTeams.js +113 -44
- package/dist/umd/MicrosoftTeams.js.map +1 -1
- package/dist/umd/MicrosoftTeams.min.js +1 -1
- package/dist/umd/MicrosoftTeams.min.js.map +1 -1
- package/package.json +1 -53
|
@@ -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,47 @@
|
|
|
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
|
+
* @param pattern - reference pattern
|
|
19
|
+
* @param host - candidate string
|
|
20
|
+
* @returns returns true if host matches pre-know valid pattern
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* validateHostAgainstPattern('*.teams.microsoft.com', 'subdomain.teams.microsoft.com') returns true
|
|
24
|
+
* validateHostAgainstPattern('teams.microsoft.com', 'team.microsoft.com') returns false
|
|
25
|
+
*
|
|
26
|
+
* @internal
|
|
27
|
+
* Limited to Microsoft-internal use
|
|
28
|
+
*/
|
|
29
|
+
export declare function validateHostAgainstPattern(pattern: string, host: string): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* @hidden
|
|
32
|
+
* @internal
|
|
33
|
+
* Limited to Microsoft-internal use.
|
|
34
|
+
*
|
|
35
|
+
* Checks if the provided pattern is valid for checking against URLs.
|
|
36
|
+
* @param pattern - The pattern to validate.
|
|
37
|
+
* @returns - True if the pattern is valid, false otherwise.
|
|
38
|
+
*/
|
|
39
|
+
export declare function isValidPatternUrl(pattern: string): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* @hidden
|
|
42
|
+
* @internal
|
|
43
|
+
* Limited to Microsoft-internal use.
|
|
44
|
+
*
|
|
45
|
+
* Creates a URL verifier based on the provided pattern.
|
|
46
|
+
*/
|
|
47
|
+
export declare function createURLVerifier(pattern: string, logger: Debugger): URLVerifier | undefined;
|
|
@@ -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
|
|
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
|
|
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
|
|
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
|
|
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 s(t,s){const n=t.substring(1);return t===s||"*."===t.substring(0,2)&&s.length>n.length&&s.split(".").length===n.split(".").length&&s.substring(s.length-n.length)===n}class n{constructor(t,s,n){this.protocol=t,this.host=s,this.logger=n}static canUse(s){return t.test(s)}static create(t,s){const e=t.split("://");return new n(e[0],e[1],s.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||s(this.host,t.host))}}function e(t){return n.canUse(t)}function o(t,s){if(n.canUse(t))return n.create(t,s);s("No URL verifier available for pattern: %s",t)}export{o as createURLVerifier,e as isValidPatternUrl,s 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
|
|
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
|
-
const
|
|
1
|
+
const t="2.49.0-beta.0";export{t 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.
|
|
4672
|
+
const version = "2.49.0-beta.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,92 @@ 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
|
+
* @param pattern - reference pattern
|
|
4812
|
+
* @param host - candidate string
|
|
4813
|
+
* @returns returns true if host matches pre-know valid pattern
|
|
4814
|
+
*
|
|
4815
|
+
* @example
|
|
4816
|
+
* validateHostAgainstPattern('*.teams.microsoft.com', 'subdomain.teams.microsoft.com') returns true
|
|
4817
|
+
* validateHostAgainstPattern('teams.microsoft.com', 'team.microsoft.com') returns false
|
|
4818
|
+
*
|
|
4819
|
+
* @internal
|
|
4820
|
+
* Limited to Microsoft-internal use
|
|
4821
|
+
*/
|
|
4822
|
+
function validateHostAgainstPattern(pattern, host) {
|
|
4823
|
+
const suffix = pattern.substring(1);
|
|
4824
|
+
return (pattern === host ||
|
|
4825
|
+
(pattern.substring(0, 2) === '*.' &&
|
|
4826
|
+
host.length > suffix.length &&
|
|
4827
|
+
host.split('.').length === suffix.split('.').length &&
|
|
4828
|
+
host.substring(host.length - suffix.length) === suffix));
|
|
4829
|
+
}
|
|
4830
|
+
/**
|
|
4831
|
+
* @hidden
|
|
4832
|
+
* @internal
|
|
4833
|
+
* Limited to Microsoft-internal use.
|
|
4834
|
+
*
|
|
4835
|
+
* Internal class when widely-available URLPattern is not available.
|
|
4836
|
+
*/
|
|
4837
|
+
class InternalURLPattern {
|
|
4838
|
+
constructor(protocol, host, logger) {
|
|
4839
|
+
this.protocol = protocol;
|
|
4840
|
+
this.host = host;
|
|
4841
|
+
this.logger = logger;
|
|
4842
|
+
}
|
|
4843
|
+
/**
|
|
4844
|
+
* Checks if InternalURLPattern can be used with the provided pattern.
|
|
4845
|
+
*/
|
|
4846
|
+
static canUse(pattern) {
|
|
4847
|
+
return userOriginUrlValidationRegExp.test(pattern);
|
|
4848
|
+
}
|
|
4849
|
+
/**
|
|
4850
|
+
* Creates an instance of InternalURLPattern with the provided pattern and logger.
|
|
4851
|
+
*/
|
|
4852
|
+
static create(pattern, logger) {
|
|
4853
|
+
const splitPattern = pattern.split('://');
|
|
4854
|
+
return new InternalURLPattern(splitPattern[0], splitPattern[1], logger.extend('InternalURLPattern'));
|
|
4855
|
+
}
|
|
4856
|
+
/**
|
|
4857
|
+
* Tests the URL against the pattern.
|
|
4858
|
+
*/
|
|
4859
|
+
test(url) {
|
|
4860
|
+
this.logger('Testing URL %s against pattern protocol: %s, host: %s', url, this.protocol, this.host);
|
|
4861
|
+
return url.protocol === `${this.protocol}:` && (!url.host || validateHostAgainstPattern(this.host, url.host));
|
|
4862
|
+
}
|
|
4863
|
+
}
|
|
4864
|
+
/**
|
|
4865
|
+
* @hidden
|
|
4866
|
+
* @internal
|
|
4867
|
+
* Limited to Microsoft-internal use.
|
|
4868
|
+
*
|
|
4869
|
+
* Checks if the provided pattern is valid for checking against URLs.
|
|
4870
|
+
* @param pattern - The pattern to validate.
|
|
4871
|
+
* @returns - True if the pattern is valid, false otherwise.
|
|
4872
|
+
*/
|
|
4873
|
+
function isValidPatternUrl(pattern) {
|
|
4874
|
+
return InternalURLPattern.canUse(pattern);
|
|
4875
|
+
}
|
|
4876
|
+
/**
|
|
4877
|
+
* @hidden
|
|
4878
|
+
* @internal
|
|
4879
|
+
* Limited to Microsoft-internal use.
|
|
4880
|
+
*
|
|
4881
|
+
* Creates a URL verifier based on the provided pattern.
|
|
4882
|
+
*/
|
|
4883
|
+
function createURLVerifier(pattern, logger) {
|
|
4884
|
+
if (InternalURLPattern.canUse(pattern)) {
|
|
4885
|
+
return InternalURLPattern.create(pattern, logger);
|
|
4886
|
+
}
|
|
4887
|
+
logger('No URL verifier available for pattern: %s', pattern);
|
|
4888
|
+
return undefined;
|
|
4889
|
+
}
|
|
4890
|
+
|
|
4813
4891
|
;// ./src/internal/internalAPIs.ts
|
|
4814
4892
|
|
|
4815
4893
|
|
|
@@ -4818,6 +4896,7 @@ function flushMessageQueue(targetWindow, targetOrigin, targetMessageQueue, targe
|
|
|
4818
4896
|
|
|
4819
4897
|
|
|
4820
4898
|
|
|
4899
|
+
|
|
4821
4900
|
const internalLogger = getLogger('internal');
|
|
4822
4901
|
const ensureInitializeCalledLogger = internalLogger.extend('ensureInitializeCalled');
|
|
4823
4902
|
const ensureInitializedLogger = internalLogger.extend('ensureInitialized');
|
|
@@ -4927,7 +5006,7 @@ function throwExceptionIfMobileApiIsNotSupported(requiredVersion = defaultSDKVer
|
|
|
4927
5006
|
*/
|
|
4928
5007
|
function processAdditionalValidOrigins(validMessageOrigins) {
|
|
4929
5008
|
let combinedOriginUrls = GlobalVars.additionalValidOrigins.concat(validMessageOrigins.filter((_origin) => {
|
|
4930
|
-
return typeof _origin === 'string' &&
|
|
5009
|
+
return typeof _origin === 'string' && isValidPatternUrl(_origin);
|
|
4931
5010
|
}));
|
|
4932
5011
|
const dedupUrls = {};
|
|
4933
5012
|
combinedOriginUrls = combinedOriginUrls.filter((_originUrl) => {
|
|
@@ -5403,7 +5482,7 @@ logWhereTeamsJsIsBeingUsed();
|
|
|
5403
5482
|
* @param validMessageOrigins - Optionally specify a list of cross-frame message origins. This parameter is used if you know that your app
|
|
5404
5483
|
* 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
5484
|
* to pass a value for this parameter.
|
|
5406
|
-
* Any domains passed in the array must
|
|
5485
|
+
* Any domains passed in the array must define a scheme to be able to be processed. Examples: https://www.example.com, chrome://
|
|
5407
5486
|
* @returns Promise that will be fulfilled when initialization has completed, or rejected if the initialization fails or times out
|
|
5408
5487
|
*/
|
|
5409
5488
|
function initialize(validMessageOrigins) {
|
|
@@ -6756,6 +6835,7 @@ var validOrigins_awaiter = (undefined && undefined.__awaiter) || function (thisA
|
|
|
6756
6835
|
|
|
6757
6836
|
|
|
6758
6837
|
|
|
6838
|
+
|
|
6759
6839
|
let validOriginsCache = [];
|
|
6760
6840
|
const validateOriginLogger = getLogger('validateOrigin');
|
|
6761
6841
|
let validOriginsPromise;
|
|
@@ -6840,30 +6920,23 @@ function isValidOriginsJSONValid(validOriginsJSON) {
|
|
|
6840
6920
|
return true;
|
|
6841
6921
|
}
|
|
6842
6922
|
/**
|
|
6923
|
+
* Validates the origin against the full pattern including protocol and hostname.
|
|
6843
6924
|
* @param pattern - reference pattern
|
|
6844
|
-
* @param
|
|
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
|
|
6925
|
+
* @param origin - candidate URL object
|
|
6853
6926
|
*/
|
|
6854
|
-
function
|
|
6855
|
-
|
|
6856
|
-
|
|
6857
|
-
|
|
6858
|
-
|
|
6859
|
-
|
|
6860
|
-
return true;
|
|
6927
|
+
function validateOriginAgainstFullPattern(pattern, origin) {
|
|
6928
|
+
let patternUrl;
|
|
6929
|
+
try {
|
|
6930
|
+
const createdURLVerifier = createURLVerifier(pattern, validateOriginLogger);
|
|
6931
|
+
if (!createdURLVerifier) {
|
|
6932
|
+
return false;
|
|
6861
6933
|
}
|
|
6934
|
+
patternUrl = createdURLVerifier;
|
|
6862
6935
|
}
|
|
6863
|
-
|
|
6864
|
-
return
|
|
6936
|
+
catch (_a) {
|
|
6937
|
+
return false;
|
|
6865
6938
|
}
|
|
6866
|
-
return
|
|
6939
|
+
return patternUrl.test(origin);
|
|
6867
6940
|
}
|
|
6868
6941
|
/**
|
|
6869
6942
|
* @internal
|
|
@@ -6875,29 +6948,25 @@ function validateOrigin(messageOrigin, disableCache) {
|
|
|
6875
6948
|
if (validateOriginWithValidOriginsList(messageOrigin, localList)) {
|
|
6876
6949
|
return Promise.resolve(true);
|
|
6877
6950
|
}
|
|
6878
|
-
|
|
6879
|
-
|
|
6880
|
-
return getValidOriginsListFromCDN(disableCache).then((validOriginsList) => {
|
|
6881
|
-
return validateOriginWithValidOriginsList(messageOrigin, validOriginsList);
|
|
6882
|
-
});
|
|
6883
|
-
}
|
|
6951
|
+
validateOriginLogger('Origin %s is not in the local valid origins list, fetching from CDN', messageOrigin);
|
|
6952
|
+
return getValidOriginsListFromCDN(disableCache).then((validOriginsList) => validateOriginWithValidOriginsList(messageOrigin, validOriginsList));
|
|
6884
6953
|
}
|
|
6885
6954
|
function validateOriginWithValidOriginsList(messageOrigin, validOriginsList) {
|
|
6886
|
-
//
|
|
6955
|
+
// User provided additional valid origins take precedence as they do not require https protocol
|
|
6956
|
+
for (const domainOrPattern of GlobalVars.additionalValidOrigins) {
|
|
6957
|
+
if (validateOriginAgainstFullPattern(domainOrPattern, messageOrigin)) {
|
|
6958
|
+
return true;
|
|
6959
|
+
}
|
|
6960
|
+
}
|
|
6961
|
+
const messageOriginHost = messageOrigin.host;
|
|
6962
|
+
// For standard valid origins, only allow https protocol
|
|
6887
6963
|
if (!isValidHttpsURL(messageOrigin)) {
|
|
6888
6964
|
validateOriginLogger('Origin %s is invalid because it is not using https protocol. Protocol being used: %s', messageOrigin, messageOrigin.protocol);
|
|
6889
6965
|
return false;
|
|
6890
6966
|
}
|
|
6891
|
-
const messageOriginHost = messageOrigin.host;
|
|
6892
6967
|
if (validOriginsList.some((pattern) => validateHostAgainstPattern(pattern, messageOriginHost))) {
|
|
6893
6968
|
return true;
|
|
6894
6969
|
}
|
|
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
6970
|
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
6971
|
return false;
|
|
6903
6972
|
}
|