Skip to content

fix(clerk-js): Use first-party cookies when running on Cypress - #3245

Merged
brkalow merged 5 commits into
mainfrom
stefanos/fix-cookies-on-cypress
May 9, 2024
Merged

fix(clerk-js): Use first-party cookies when running on Cypress#3245
brkalow merged 5 commits into
mainfrom
stefanos/fix-cookies-on-cypress

Conversation

@anagstef

Copy link
Copy Markdown
Contributor

Description

The issue:

Cypress discards third-party cookies. Also, it runs in an iframe.
If we detect that clerk-js runs inside an iframe, we set our cookies with SameSite: None (third-party).
So, the following cookies never get set in the browser:

  • __session
  • __client_uat
  • __clerk_db_jwt

Proposed solution:

Cypress adds a global object on the window, on the window.Cypress property. We can exclude cookies getting set as third-party if we detect that the app runs inside Cypress.

Checklist

  • npm test runs as expected.
  • npm run build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

@anagstef anagstef self-assigned this Apr 23, 2024
@changeset-bot

changeset-bot Bot commented Apr 23, 2024

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: fc3a263

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@clerk/clerk-js Patch
@clerk/chrome-extension Patch
@clerk/clerk-expo Patch

Not sure what this means? Click here to learn what changesets are.

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

@anagstef

Copy link
Copy Markdown
Contributor Author

!snapshot

@clerk-cookie

Copy link
Copy Markdown
Collaborator

Hey @anagstef - the snapshot version command generated the following package versions:

Package Version
@clerk/chrome-extension 1.0.1-snapshot.v3a06a37
@clerk/clerk-js 5.1.0-snapshot.v3a06a37
@clerk/clerk-expo 1.0.1-snapshot.v3a06a37
@clerk/fastify 1.0.1-snapshot.v3a06a37
gatsby-plugin-clerk 5.0.0-beta.45
@clerk/localizations 2.1.0-snapshot.v3a06a37
@clerk/nextjs 5.0.2-snapshot.v3a06a37
@clerk/clerk-react 5.0.1-snapshot.v3a06a37
@clerk/remix 4.0.1-snapshot.v3a06a37
@clerk/themes 2.0.1-snapshot.v3a06a37
@clerk/types 4.1.0-snapshot.v3a06a37

Tip: Use the snippet copy button below to quickly install the required packages.
@clerk/chrome-extension

npm i @clerk/chrome-extension@1.0.1-snapshot.v3a06a37 --save-exact

@clerk/clerk-js

npm i @clerk/clerk-js@5.1.0-snapshot.v3a06a37 --save-exact

@clerk/clerk-expo

npm i @clerk/clerk-expo@1.0.1-snapshot.v3a06a37 --save-exact

@clerk/fastify

npm i @clerk/fastify@1.0.1-snapshot.v3a06a37 --save-exact

gatsby-plugin-clerk

npm i gatsby-plugin-clerk@5.0.0-beta.45 --save-exact

@clerk/localizations

npm i @clerk/localizations@2.1.0-snapshot.v3a06a37 --save-exact

@clerk/nextjs

npm i @clerk/nextjs@5.0.2-snapshot.v3a06a37 --save-exact

@clerk/clerk-react

npm i @clerk/clerk-react@5.0.1-snapshot.v3a06a37 --save-exact

@clerk/remix

npm i @clerk/remix@4.0.1-snapshot.v3a06a37 --save-exact

@clerk/themes

npm i @clerk/themes@2.0.1-snapshot.v3a06a37 --save-exact

@clerk/types

npm i @clerk/types@4.1.0-snapshot.v3a06a37 --save-exact

@anagstef
anagstef force-pushed the stefanos/fix-cookies-on-cypress branch from 3a06a37 to bd3f75e Compare April 24, 2024 12:52
@anagstef
anagstef marked this pull request as ready for review April 24, 2024 12:54
@anagstef
anagstef requested review from dimkl and nikosdouvlis April 24, 2024 12:54
@anagstef

Copy link
Copy Markdown
Contributor Author

!snapshot

@clerk-cookie

Copy link
Copy Markdown
Collaborator

Hey @anagstef - the snapshot version command generated the following package versions:

Package Version
@clerk/backend 1.0.1-snapshot.vbd3f75e
@clerk/chrome-extension 1.0.1-snapshot.vbd3f75e
@clerk/clerk-js 5.1.0-snapshot.vbd3f75e
@clerk/clerk-expo 1.0.1-snapshot.vbd3f75e
@clerk/express 0.0.2-snapshot.vbd3f75e
@clerk/fastify 1.0.1-snapshot.vbd3f75e
gatsby-plugin-clerk 5.0.0-beta.45
@clerk/localizations 2.1.0-snapshot.vbd3f75e
@clerk/nextjs 5.0.2-snapshot.vbd3f75e
@clerk/clerk-react 5.0.1-snapshot.vbd3f75e
@clerk/remix 4.0.1-snapshot.vbd3f75e
@clerk/clerk-sdk-node 5.0.1-snapshot.vbd3f75e
@clerk/testing 1.0.0-snapshot.vbd3f75e
@clerk/themes 2.0.1-snapshot.vbd3f75e
@clerk/types 4.1.0-snapshot.vbd3f75e

Tip: Use the snippet copy button below to quickly install the required packages.
@clerk/backend

npm i @clerk/backend@1.0.1-snapshot.vbd3f75e --save-exact

@clerk/chrome-extension

npm i @clerk/chrome-extension@1.0.1-snapshot.vbd3f75e --save-exact

@clerk/clerk-js

npm i @clerk/clerk-js@5.1.0-snapshot.vbd3f75e --save-exact

@clerk/clerk-expo

npm i @clerk/clerk-expo@1.0.1-snapshot.vbd3f75e --save-exact

@clerk/express

npm i @clerk/express@0.0.2-snapshot.vbd3f75e --save-exact

@clerk/fastify

npm i @clerk/fastify@1.0.1-snapshot.vbd3f75e --save-exact

gatsby-plugin-clerk

npm i gatsby-plugin-clerk@5.0.0-beta.45 --save-exact

@clerk/localizations

npm i @clerk/localizations@2.1.0-snapshot.vbd3f75e --save-exact

@clerk/nextjs

npm i @clerk/nextjs@5.0.2-snapshot.vbd3f75e --save-exact

@clerk/clerk-react

npm i @clerk/clerk-react@5.0.1-snapshot.vbd3f75e --save-exact

@clerk/remix

npm i @clerk/remix@4.0.1-snapshot.vbd3f75e --save-exact

@clerk/clerk-sdk-node

npm i @clerk/clerk-sdk-node@5.0.1-snapshot.vbd3f75e --save-exact

@clerk/testing

npm i @clerk/testing@1.0.0-snapshot.vbd3f75e --save-exact

@clerk/themes

npm i @clerk/themes@2.0.1-snapshot.vbd3f75e --save-exact

@clerk/types

npm i @clerk/types@4.1.0-snapshot.vbd3f75e --save-exact

@anagstef

anagstef commented May 9, 2024

Copy link
Copy Markdown
Contributor Author

!snapshot

@clerk-cookie

Copy link
Copy Markdown
Collaborator

Hey @anagstef - the snapshot version command generated the following package versions:

Package Version
@clerk/chrome-extension 1.0.7-snapshot.v47a3ff9
@clerk/clerk-js 5.2.3-snapshot.v47a3ff9
@clerk/clerk-expo 1.0.7-snapshot.v47a3ff9
gatsby-plugin-clerk 5.0.0-beta.45

Tip: Use the snippet copy button below to quickly install the required packages.
@clerk/chrome-extension

npm i @clerk/chrome-extension@1.0.7-snapshot.v47a3ff9 --save-exact

@clerk/clerk-js

npm i @clerk/clerk-js@5.2.3-snapshot.v47a3ff9 --save-exact

@clerk/clerk-expo

npm i @clerk/clerk-expo@1.0.7-snapshot.v47a3ff9 --save-exact

gatsby-plugin-clerk

npm i gatsby-plugin-clerk@5.0.0-beta.45 --save-exact

@brkalow
brkalow enabled auto-merge (squash) May 9, 2024 21:03
@brkalow
brkalow merged commit 7b213d5 into main May 9, 2024
@brkalow
brkalow deleted the stefanos/fix-cookies-on-cypress branch May 9, 2024 21:12
@clerk-cookie clerk-cookie mentioned this pull request May 9, 2024
anagstef added a commit that referenced this pull request May 15, 2024
* fix(clerk-js): Use first-party cookies when running on Cypress

* fix(clerk-js): Create isCypress util

(cherry picked from commit 7b213d5)
anagstef added a commit that referenced this pull request May 15, 2024
…lure logging (#3384)

* fix(clerk-js): Improve logging for CAPTCHA script loading errors (#3374)

* fix(clerk-js): Improve logging for CAPTCHA script loading errors

* fix(clerk-js): Remove the generic CAPTCHA console error

(cherry picked from commit 34befee)

* fix(clerk-js): Use first-party cookies when running on Cypress (#3245)

* fix(clerk-js): Use first-party cookies when running on Cypress

* fix(clerk-js): Create isCypress util

(cherry picked from commit 7b213d5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants