Skip to content

Trusted Types API violation fix#5561

Closed
rafaelhovhannisyan24 wants to merge 1 commit intoueberdosis:developfrom
rafaelhovhannisyan24:fix/trusted_types_violation
Closed

Trusted Types API violation fix#5561
rafaelhovhannisyan24 wants to merge 1 commit intoueberdosis:developfrom
rafaelhovhannisyan24:fix/trusted_types_violation

Conversation

@rafaelhovhannisyan24
Copy link

Fix for Trusted Types Issue with TipTap on YouTube
YouTube recently enforced a stricter Content Security Policy with Trusted Types, causing TipTap to stop working in our Chrome extension. The issue arose because Trusted Types restrict certain operations like innerHTML, which TipTap relies on.

Solution:
We implemented a custom Trusted Types policy that allows TipTap to function correctly within YouTube's security framework. This fix involves defining and applying a policy that permits the necessary unsafe operations while maintaining security.

https://web.dev/articles/trusted-types#fix_the_violations

@changeset-bot
Copy link

changeset-bot bot commented Aug 27, 2024

⚠️ No Changeset found

Latest commit: f69cf5e

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@netlify
Copy link

netlify bot commented Aug 27, 2024

Deploy Preview for tiptap-embed ready!

Name Link
🔨 Latest commit f69cf5e
🔍 Latest deploy log https://app.netlify.com/sites/tiptap-embed/deploys/66cdd88374b2340008127794
😎 Deploy Preview https://deploy-preview-5561--tiptap-embed.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@llusinepetrosyan
Copy link

@nperez0111 I also had same issue and seems @rafaelhovhannisyan24(thank you) fixed it on this pr - #5561
Can we speed up review/merge process please @nperez0111 ?

Copy link
Contributor

@nperez0111 nperez0111 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not mergable as is.

if (window.trustedTypes) {
// @ts-ignore
// eslint-disable-next-line no-undef
policy = window.trustedTypes.createPolicy('tiptap', {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't make sense on why it's being repeated

}

styleNode.setAttribute(`data-tiptap-style${suffix ? `-${suffix}` : ''}`, '')
styleNode.innerHTML = style
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this actually equivalent?

export function elementFromString(value: string): HTMLElement {
// add a wrapper to preserve leading and trailing whitespace
const wrappedValue = `<body>${value}</body>`
const wrappedValue = policy.createHTML(`<body>${value}</body>`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does prosemirror support this because I am not willing to use this if prosemirror does not even support this.

A link to the source would be enough to convince me. Probably in prosemirror view since that touches the DOM

@bdbch bdbch added the Stale The issue or pullrequest has not been updated in a while and might be stale label Dec 2, 2024
@bdbch
Copy link
Member

bdbch commented Dec 2, 2024

Closing this for now as the PR is stale - if you want to update it, feel free to reopen.

@bdbch bdbch closed this Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Stale The issue or pullrequest has not been updated in a while and might be stale

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants