@chat21/chat21-web-widget 5.1.0-rc13 → 5.1.0-rc14

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/CHANGELOG.md CHANGED
@@ -6,6 +6,9 @@
6
6
  ### **Copyrigth**:
7
7
  *Tiledesk SRL*
8
8
 
9
+ # 5.1.0-rc14
10
+ - **added**: ability to hide widget on selected domains based on hideOnSpecificDomainList variable
11
+
9
12
  # 5.1.0-rc13
10
13
  - **added**: ability to manage embedded chatbot-panel.html page into an iframe and hide some elements
11
14
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@chat21/chat21-web-widget",
3
3
  "author": "Tiledesk SRL",
4
- "version": "5.1.0-rc13",
4
+ "version": "5.1.0-rc14",
5
5
  "license": "MIT",
6
6
  "homepage": "https://www.tiledesk.com",
7
7
  "repository": {
@@ -262,6 +262,14 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
262
262
  this.tabTitle = this.g.windowContext.window.document.title
263
263
  this.appStorageService.initialize(environment.storage_prefix, this.g.persistence, this.g.projectid)
264
264
 
265
+ //check if allowed to load
266
+ let canLoad = this.globalSettingsService.manageLoadingDomains();
267
+ if(!canLoad){
268
+ this.logger.error('[Check canLoad] Widget is not able to load on this domain!!!')
269
+ this.hideWidget()
270
+ this.disposeWidget();
271
+ }
272
+
265
273
  //set visibility
266
274
  if((this.g.isMobile && !this.g.displayOnMobile) || (!this.g.isMobile && !this.g.displayOnDesktop)){
267
275
  this.disposeWidget()
@@ -10,7 +10,7 @@ import { TemplateBindingParseResult } from '@angular/compiler';
10
10
  import { AppStorageService } from '../../chat21-core/providers/abstract/app-storage.service';
11
11
  import { LoggerService } from '../../chat21-core/providers/abstract/logger.service';
12
12
  import { LoggerInstance } from '../../chat21-core/providers/logger/loggerInstance';
13
- import { invertColor, isJsonArray } from '../../chat21-core/utils/utils';
13
+ import { invertColor, isAllowedUrlInText, isJsonArray } from '../../chat21-core/utils/utils';
14
14
  import { AppConfigService } from './app-config.service';
15
15
 
16
16
 
@@ -516,6 +516,9 @@ export class GlobalSettingsService {
516
516
  if (variables.hasOwnProperty('showAudioRecorderFooterButton')) {
517
517
  globals['showAudioRecorderFooterButton'] = variables['showAudioRecorderFooterButton'];
518
518
  }
519
+ if (variables.hasOwnProperty('hideOnSpecificDomainList')) {
520
+ globals['hideOnSpecificDomainList'] = variables['hideOnSpecificDomainList'];
521
+ }
519
522
 
520
523
  }
521
524
  }
@@ -1970,4 +1973,12 @@ export class GlobalSettingsService {
1970
1973
  }
1971
1974
  }
1972
1975
 
1976
+ manageLoadingDomains(): boolean {
1977
+ if(!this.globals.hideOnSpecificDomainList){
1978
+ return true
1979
+ }
1980
+ let isAllowedToLoad = !isAllowedUrlInText(this.globals.windowContext.location.origin, [])
1981
+ return isAllowedToLoad
1982
+ }
1983
+
1973
1984
  }
@@ -218,6 +218,8 @@ export class Globals {
218
218
  showEmojiFooterButton: boolean // ******* new ********
219
219
  showAttachmentFooterButton: boolean // ******* new ********
220
220
  showAudioRecorderFooterButton: boolean // ******* new ********
221
+
222
+ hideOnSpecificDomainList: Array<string> // ******* new ********
221
223
  constructor(
222
224
  ) { }
223
225
 
@@ -417,6 +419,8 @@ export class Globals {
417
419
  this.showAttachmentFooterButton = true;
418
420
  /** show/hide rec audio option in footer chat-detail page */
419
421
  this.showAudioRecorderFooterButton = true;
422
+ /** set a list of domain not able to load the widget */
423
+ this.hideOnSpecificDomainList = [];
420
424
 
421
425
  // ============ END: SET EXTERNAL PARAMETERS ==============//
422
426
 
@@ -470,6 +470,7 @@ export class FirebaseConversationHandler extends ConversationHandlerService {
470
470
  const that = this;
471
471
  const commands = msg.attributes.commands;
472
472
  let i=0;
473
+ if(commands.length === 0) return;
473
474
  return new Promise((resolve, reject)=>{
474
475
  function execute(command){
475
476
  if(command.type === "message"){
@@ -465,6 +465,7 @@ export class MQTTConversationHandler extends ConversationHandlerService {
465
465
  const that = this;
466
466
  const commands = msg.attributes.commands;
467
467
  let i=0;
468
+ if(commands.length === 0) return;
468
469
  return new Promise((resolve, reject)=>{
469
470
  function execute(command){
470
471
  if(command.type === "message"){
@@ -619,7 +619,6 @@ function componentFromStr(numStr, percent) {
619
619
 
620
620
  export function isAllowedUrlInText(text: string, allowedUrls: string[]) {
621
621
  const urlsInMessage = extractUrls(text);
622
- console.log('urlsInMessage ++++ :', urlsInMessage);
623
622
 
624
623
  const allowedPatterns = allowedUrls.map((url) => {
625
624
  try {
@@ -634,6 +633,9 @@ export function isAllowedUrlInText(text: string, allowedUrls: string[]) {
634
633
 
635
634
  const matchesAllowed = (domain: string) => {
636
635
  return allowedPatterns.some((pattern) => {
636
+ if (pattern === '*') {
637
+ return true; //accept all
638
+ }
637
639
  if (pattern.startsWith('*.')) {
638
640
  const base = pattern.replace(/^\*\./, '');
639
641
  return domain === base || domain.endsWith('.' + base);