tldraw/packages
Mime Čuvalo 6ba3fb0722
csp: followup fixes/dx/tweaks (#4159)
couple interesting things here as followups to the CSP work.
- first of all, again, good call on doing the report-only to start with
@SomeHats 🤘
- I combed through all the Sentry logs, looking for issues. a lot of
them were browser extensions and could be ignored.
- there were some other ones that needed fixing up though.

fixes in this PR:
- [x] CSP emulation in dev: make sure it's running in development so
that we can catch things locally. this is done via the meta tag.
- [x] `connect-src` add `blob`: this was breaking copy/export as svg/png
- [x] image testing: expand list of pasted image extensions to include
avif and some others
- [x] image pasting: this didn't really work in the first place because
typically even with CSP disabled, you'll mainly run into CORS issues. I
think it's a pretty crap user experience. So, I moved this logic to
actually be in the URL unfurling. Lemme know what you think! I don't
think we should proxy the actual image data - that sounds ... intense 😬
even though it would produce a better user experience technically.
- [x] investigated `manifest-src` errors: but it actually seems fine?
Weird thing here is that `manifest-src` isn't explicitly in the CSP so
it falls back to the `default-src` of `self` which is fine. Trying it on
tldraw.com it seems just fine with no errors but inexplicably some users
are hitting these errors. I'm guessing maybe it's an ad-blocker type
behavior maybe.
- [x] `font-src` add `data`: I'm actually unsure if this is quite
necessary but I _think_ embedded fonts in SVGs are causing the problem.
However, I can't reproduce this, I just don't mind adding this.


Before / After for pasting image URLs (not a CSP issue, to be clear, but
a CORS issue)

## Before
<img width="448" alt="Screenshot 2024-07-12 at 17 59 42"
src="https://github.com/user-attachments/assets/e8ce267b-48fd-49cd-b0f7-0fd20c0b9a1d">

## After
<img width="461" alt="Screenshot 2024-07-12 at 18 00 06"
src="https://github.com/user-attachments/assets/9956590d-fe37-4708-bc26-0c454f8151b4">

### Change type

- [ ] `bugfix`
- [ ] `improvement`
- [ ] `feature`
- [ ] `api`
- [x] `other`

### Release notes

- Security: more CSP work on dotcom
2024-07-16 14:20:38 +00:00
..
assets serve icons via a single merged .svg file (#4150) 2024-07-15 11:03:11 +00:00
dotcom-shared license: show on dotcom dev mode (#4158) 2024-07-12 16:53:31 +00:00
editor csp: followup fixes/dx/tweaks (#4159) 2024-07-16 14:20:38 +00:00
namespaced-tldraw Update CHANGELOG.md [skip ci] 2024-06-25 13:27:57 +00:00
state Split @tldraw/state into @tldraw/state and @tldraw/state-react (#4170) 2024-07-15 11:18:59 +00:00
state-react Split @tldraw/state into @tldraw/state and @tldraw/state-react (#4170) 2024-07-15 11:18:59 +00:00
store Update CHANGELOG.md [skip ci] 2024-06-25 13:27:57 +00:00
sync bemo custom shape example (#4174) 2024-07-16 11:24:01 +00:00
sync-core publish bemo canaries (#4175) 2024-07-15 16:08:42 +00:00
tldraw csp: followup fixes/dx/tweaks (#4159) 2024-07-16 14:20:38 +00:00
tlschema Explicitly type shape props and defaults (#4191) 2024-07-16 13:16:39 +00:00
utils Initial bemo worker setup (#4017) 2024-07-01 11:35:23 +00:00
validate Demo server bookmark unfurl endpoint (#4062) 2024-07-03 10:48:34 +00:00
worker-shared csp: followup fixes/dx/tweaks (#4159) 2024-07-16 14:20:38 +00:00