You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -330,6 +330,8 @@ Notes: web developers are advised to use [`~` (tilde range)](https://github.com/
330
330
- Fixed `botframework-webchat/decorator` import in legacy CommonJS environments, in [#5616](https://github.com/microsoft/BotFramework-WebChat/pull/5616), by [@OEvgeny](https://github.com/OEvgeny)
331
331
- Fixed `npm start` for efficiency and reliability, in PR [#5621](https://github.com/microsoft/BotFramework-WebChat/pull/5621) and [#5629](https://github.com/microsoft/BotFramework-WebChat/pull/5629), by [@compulim](https://github.com/compulim)
332
332
- Fixed activity sorting introduced in PR [#5622](https://github.com/microsoft/BotFramework-WebChat/pull/5622), part grouping, and livestreaming, by [@compulim](https://github.com/compulim) in PR [#5635](https://github.com/microsoft/BotFramework-WebChat/pull/5635)
333
+
- Fixed Content Security Policy documentation and sample in PR, by [@compulim](https://github.com/compulim) in PR [#5648](https://github.com/microsoft/BotFramework-WebChat/pull/5648)
Copy file name to clipboardExpand all lines: docs/CONTENT_SECURITY_POLICY.md
+38-29Lines changed: 38 additions & 29 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,21 +2,29 @@
2
2
3
3
Starting from 4.10.1, [Content Security Policy](https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP) is supported.
4
4
5
-
> In this article, we are using a nonce of `a1b2c3d`. In a production system, it should be a random and unguessable value that changes every time a policy is applied.
5
+
> In this article, we are using a nonce of `a1b2c3d`. In production environment, it should be a value generated by random number generator (RNG) with high entropy. The value should change every time the policy is applied.
6
+
7
+
> New in 4.19.0: `img-src data:` is required for display icons used in Web Chat.
6
8
7
9
To enable Web Chat in a CSP-enforced environment, the following directives must be configured:
- REST call to https://directline.botframework.com for starting conversation, posting activities, etc.
45
+
- Web Socket connection to wss://directline.botframework.com for receiving activities
46
+
- When using protocols other than Direct Line or Web Chat channel, the source will be different
47
+
-`img-src blob:`
48
+
-`blob:` will allow images in Web Chat to be loaded via `blob:` scheme. Types of images using `blob:` scheme:
49
+
- Bot attached images using data URI, will be converted to URL with scheme of `blob:`
50
+
- User uploaded images are downscaled as thumbnails with scheme of `blob:`
51
+
-`img-src data:`
52
+
-`data:` will allow images in Web Chat to be loaded via `data:` scheme. Types of images using `data:` scheme:
53
+
- Inlined assets. For example, connectivity status spinner and typing indicator
54
+
-`script-src 'strict-dynamic'`
55
+
- (Optional) `strict-dynamic` will allow Web Chat to use Web Worker to downscale image on upload
56
+
- If `strict-dynamic` is not provided, Web Chat will fallback to main thread to downscale image
57
+
-`style-src 'nonce-a1b2c3d'`
58
+
-`'nonce-a1b2c3d'` will allow CSS injection through this nonce. This should be a per-policy, unique, and unguessable value
59
+
- Web Chat inject `<style>` element using [`emotion`](https://emotion.sh/) with `nonce` attribute
60
+
- You will need to pass this nonce when rendering Web Chat
52
61
53
62
## Setting up the nonce
54
63
55
64
When rendering Web Chat, pass the nonce as a prop named `nonce`.
56
65
57
66
```js
58
67
WebChat.renderWebChat({
59
-
directLine:createDirectLine({ token }),
60
-
nonce:'a1b2c3d'
68
+
directLine:createDirectLine({ token }),
69
+
nonce:'a1b2c3d'
61
70
});
62
71
```
63
72
64
73
## Limitations
65
74
66
-
Currently, the nonce is used for injecting `<style>` elements only. It is not used for other elements, including `<img>` and other media elements. For details, please see [#3445](https://github.com/microsoft/BotFramework-WebChat/issues/3445.
75
+
Currently, the nonce is used for injecting `<style>` elements only. It is not used for other elements, including `<img>` and other media elements. For details, please see [#3445](https://github.com/microsoft/BotFramework-WebChat/issues/3445).
This CDN points to the latest official release of Web Chat. If you need to test against Web Chat's latest bits, please refer to using Web Chat's latest bits:
0 commit comments