|  | 
| 3 | 3 | 
 | 
| 4 | 4 | import * as models from 'powerbi-models'; | 
| 5 | 5 | import * as sdkConfig from './config'; | 
| 6 |  | -import { EmbedUrlNotSupported } from './errors'; | 
|  | 6 | +import { EmbedUrlNotSupported, invalidEmbedUrlErrorMessage } from './errors'; | 
| 7 | 7 | import { ICustomEvent, IEvent, IEventHandler, Service } from './service'; | 
| 8 |  | -import { addParamToUrl, assign, autoAuthInEmbedUrl, createRandomString, getTimeDiffInMilliseconds, remove, isCreate } from './util'; | 
|  | 8 | +import { addParamToUrl, assign, autoAuthInEmbedUrl, createRandomString, getTimeDiffInMilliseconds, remove, isCreate, validateEmbedUrl } from './util'; | 
| 9 | 9 | 
 | 
| 10 | 10 | declare global { | 
| 11 | 11 |   interface Document { | 
| @@ -573,7 +573,7 @@ export abstract class Embed { | 
| 573 | 573 | 
 | 
| 574 | 574 |     const accessTokenProvider = eventHooks.accessTokenProvider; | 
| 575 | 575 |     if (!!accessTokenProvider) { | 
| 576 |  | -      if ((['create', 'quickcreate', 'report'].indexOf(this.embedtype.toLowerCase()) ===  -1) || this.config.tokenType !== models.TokenType.Aad) { | 
|  | 576 | +      if ((['create', 'quickcreate', 'report'].indexOf(this.embedtype.toLowerCase()) === -1) || this.config.tokenType !== models.TokenType.Aad) { | 
| 577 | 577 |         throw new Error("accessTokenProvider is only supported in report SaaS embed"); | 
| 578 | 578 |       } | 
| 579 | 579 |     } | 
| @@ -634,10 +634,6 @@ export abstract class Embed { | 
| 634 | 634 |     // Trim spaces to fix user mistakes. | 
| 635 | 635 |     hostname = hostname.toLowerCase().trim(); | 
| 636 | 636 | 
 | 
| 637 |  | -    if (hostname.indexOf("http://") === 0) { | 
| 638 |  | -      throw new Error("HTTP is not allowed. HTTPS is required"); | 
| 639 |  | -    } | 
| 640 |  | - | 
| 641 | 637 |     if (hostname.indexOf("https://") === 0) { | 
| 642 | 638 |       return `${hostname}/${endpoint}`; | 
| 643 | 639 |     } | 
| @@ -745,6 +741,9 @@ export abstract class Embed { | 
| 745 | 741 |     if (!this.iframe) { | 
| 746 | 742 |       const iframeContent = document.createElement("iframe"); | 
| 747 | 743 |       const embedUrl = this.config.uniqueId ? addParamToUrl(this.config.embedUrl, 'uid', this.config.uniqueId) : this.config.embedUrl; | 
|  | 744 | +      if (!validateEmbedUrl(embedUrl)) { | 
|  | 745 | +        throw new Error(invalidEmbedUrlErrorMessage); | 
|  | 746 | +      } | 
| 748 | 747 | 
 | 
| 749 | 748 |       iframeContent.style.width = '100%'; | 
| 750 | 749 |       iframeContent.style.height = '100%'; | 
|  | 
0 commit comments