yelda-webchat 1.1.23 → 1.1.25
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/AGENTS.md +1 -1
- package/README.md +2 -2
- package/dist/css/yeldaWebchatInjector.css.gz +0 -0
- package/dist/css/yeldaWebchatInjector.min.css.gz +0 -0
- package/dist/js/yeldaWebchatInjector.js +2 -2
- package/dist/js/yeldaWebchatInjector.js.gz +0 -0
- package/dist/js/yeldaWebchatInjector.js.map +1 -1
- package/dist/js/yeldaWebchatInjector.min.js +2 -2
- package/dist/js/yeldaWebchatInjector.min.js.gz +0 -0
- package/dist/js/yeldaWebchatInjector.min.js.map +1 -1
- package/package.json +9 -7
- package/src/config/index.js +2 -0
- package/src/js/yeldaWebchatInjector.js +18 -19
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yelda-webchat",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.25",
|
|
4
4
|
"description": "Website Chat Plugin",
|
|
5
5
|
"main": "./dist/js/yeldaWebchatInjector.min.js",
|
|
6
6
|
"license": "MIT",
|
|
@@ -15,12 +15,16 @@
|
|
|
15
15
|
"type": "git",
|
|
16
16
|
"url": "https://github.com/Yeldaai/chat-plugin.git"
|
|
17
17
|
},
|
|
18
|
+
"engines": {
|
|
19
|
+
"node": ">=18"
|
|
20
|
+
},
|
|
18
21
|
"scripts": {
|
|
19
22
|
"build": "rimraf dist && webpack -p",
|
|
20
|
-
"prepack": "npm
|
|
23
|
+
"prepack": "npm test",
|
|
24
|
+
"pretest": "npm run build",
|
|
21
25
|
"lint:check": "eslint --ext .js src",
|
|
22
26
|
"lint:fix": "eslint --fix --ext .js src",
|
|
23
|
-
"test": "mocha
|
|
27
|
+
"test": "mocha ./test/*.js",
|
|
24
28
|
"uploadBuildToS3": "npm run prepack && node uploadBuildToS3 build -s $npm_config_semver -d $npm_config_destinationPath -o $otp"
|
|
25
29
|
},
|
|
26
30
|
"devDependencies": {
|
|
@@ -40,8 +44,6 @@
|
|
|
40
44
|
"css-loader": "^1.0.0",
|
|
41
45
|
"dotenv": "^8.2.0",
|
|
42
46
|
"eslint": "^5.16.0",
|
|
43
|
-
"esm": "^3.2.25",
|
|
44
|
-
"extract-text-webpack-plugin": "^3.0.2",
|
|
45
47
|
"file-loader": "^1.1.11",
|
|
46
48
|
"inject-loader": "^4.0.1",
|
|
47
49
|
"jsdom": "^16.5.0",
|
|
@@ -49,7 +51,7 @@
|
|
|
49
51
|
"less-loader": "^4.1.0",
|
|
50
52
|
"mime": "^2.4.6",
|
|
51
53
|
"mini-css-extract-plugin": "^0.4.1",
|
|
52
|
-
"mocha": "^
|
|
54
|
+
"mocha": "^12.0.1",
|
|
53
55
|
"optimize-css-assets-webpack-plugin": "^5.0.8",
|
|
54
56
|
"postcss-import": "^12.0.0",
|
|
55
57
|
"postcss-loader": "^3.0.0",
|
|
@@ -58,7 +60,7 @@
|
|
|
58
60
|
"style-loader": "^0.22.1",
|
|
59
61
|
"uglifyjs-webpack-plugin": "^2.2.0",
|
|
60
62
|
"url-loader": "^1.1.1",
|
|
61
|
-
"webpack": "^4.
|
|
63
|
+
"webpack": "^4.47.0",
|
|
62
64
|
"webpack-cli": "^3.3.10",
|
|
63
65
|
"xhr-mock": "^2.5.1",
|
|
64
66
|
"yargs": "^15.4.1"
|
package/src/config/index.js
CHANGED
|
@@ -4,6 +4,8 @@ module.exports = {
|
|
|
4
4
|
YELDA_PARAMETER: 'yparam',
|
|
5
5
|
DEFAULT_PUBLICATION_STATUS: true,
|
|
6
6
|
ALWAYS_ALLOWED_SITES_REGEX : /^([a-z-]*.yelda.ai|localhost|0.0.0.0|127.0.0.1)$/,
|
|
7
|
+
// Prefix of an allowed domain that allows all its subdomains, but not the domain itself
|
|
8
|
+
ALLOWED_DOMAIN_WILDCARD_PREFIX: '*.',
|
|
7
9
|
REGEX_HOST: {
|
|
8
10
|
STAGING: /staging.yelda.ai/,
|
|
9
11
|
YELDA: /.yelda.ai/
|
|
@@ -334,28 +334,9 @@ class YeldaChat {
|
|
|
334
334
|
return
|
|
335
335
|
}
|
|
336
336
|
|
|
337
|
-
const isVoiceFirstUI = this.webchatSettings.hasOwnProperty('isVoiceFirstUI')
|
|
338
|
-
? this.webchatSettings.isVoiceFirstUI
|
|
339
|
-
: false
|
|
340
337
|
const customImage = this.webchatSettings.image && this.webchatSettings.image.url
|
|
341
338
|
const hasCustomStyle = this.webchatSettings.hasOwnProperty('isDefaultStyle') && !this.webchatSettings.isDefaultStyle
|
|
342
339
|
|
|
343
|
-
/**
|
|
344
|
-
* in isVoiceFirstUI mode
|
|
345
|
-
* - the assistant should be opened directly and will never be closed
|
|
346
|
-
* => we call directly openChat and do not add the assistant image
|
|
347
|
-
* - we don't want the box-shadow css style
|
|
348
|
-
* => we add voiceFirstUI to iframeContainer
|
|
349
|
-
* - /chat vue render the voice first UI
|
|
350
|
-
* => nothing more to do here
|
|
351
|
-
*/
|
|
352
|
-
if (isVoiceFirstUI) {
|
|
353
|
-
this.iframeContainer.classList.add('voiceFirstUI')
|
|
354
|
-
this.openChat()
|
|
355
|
-
this.assistantImage = null
|
|
356
|
-
return
|
|
357
|
-
}
|
|
358
|
-
|
|
359
340
|
if (!hasCustomStyle || !customImage) {
|
|
360
341
|
this.addAssistantImageToWebChatContainer()
|
|
361
342
|
return
|
|
@@ -1155,9 +1136,27 @@ class YeldaChat {
|
|
|
1155
1136
|
return false
|
|
1156
1137
|
}
|
|
1157
1138
|
|
|
1139
|
+
// allowedDomains is only sent when the admins restricted the webchat to some websites
|
|
1140
|
+
if (webchatSettings.allowedDomains && !this.isHostAllowed(currentHost, webchatSettings.allowedDomains)) {
|
|
1141
|
+
return false
|
|
1142
|
+
}
|
|
1143
|
+
|
|
1158
1144
|
return true
|
|
1159
1145
|
}
|
|
1160
1146
|
|
|
1147
|
+
/**
|
|
1148
|
+
* Check the current website is in the webchat allowed domains
|
|
1149
|
+
* @param {String} host - hostname of the current website, e.g. 'www.site.com'
|
|
1150
|
+
* @param {Array<String>} allowedDomains - e.g. ['www.site.com', '*.site.com'], '*.site.com' allows the subdomains only
|
|
1151
|
+
* @returns {Boolean}
|
|
1152
|
+
*/
|
|
1153
|
+
isHostAllowed(host, allowedDomains) {
|
|
1154
|
+
return allowedDomains.some(domain => domain.startsWith(config.ALLOWED_DOMAIN_WILDCARD_PREFIX)
|
|
1155
|
+
// '*.site.com' gives '.site.com', matched by 'www.site.com' but not by 'site.com' or 'mysite.com'
|
|
1156
|
+
? host.endsWith(domain.slice(config.ALLOWED_DOMAIN_WILDCARD_PREFIX.length - 1))
|
|
1157
|
+
: host === domain)
|
|
1158
|
+
}
|
|
1159
|
+
|
|
1161
1160
|
/**
|
|
1162
1161
|
* Return if the webchat loadChat settings are different from the yeldaChat global assistant settings
|
|
1163
1162
|
*
|