clerk / javascript

Official Javascript repository for Clerk authentication
https://clerk.com
MIT License
1.12k stars 246 forks source link

fix(clerk-expo): Ensure correct mobile detection for native requests #4137

Closed wobsoriano closed 1 month ago

wobsoriano commented 1 month ago

Description

This PR addresses an issue where the isMobile value of a SessionActivity is incorrectly set to false for iOS devices. The problem is caused by some iOS devices sending an empty user-agent header:

Here's an example of an expo login request in iOS (notice there's no user-agent header and isMobile is false):

Screenshot 2024-09-10 at 7 49 14β€―AM Screenshot 2024-09-10 at 8 47 05β€―AM

The backend relies on either the x-mobile or user-agent headers to determine if a request is from a mobile device. This update adds the x-mobile header for all native requests, ensuring that the backend correctly records session activities as mobile, regardless of the user-agent value.

Here's a SessionActivity record after signing in with a x-mobile header (notice isMobile is true):

Screenshot 2024-09-10 at 8 06 16β€―AM

Resolves ECO-189

Checklist

Type of change

changeset-bot[bot] commented 1 month ago

πŸ¦‹ Changeset detected

Latest commit: 2fc27051cd384dea57777f68502cd609db29b2cb

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

This PR includes changesets to release 1 package | Name | Type | | ----------------- | ----- | | @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

wobsoriano commented 1 month ago

!snapshot

clerk-cookie commented 1 month ago
Hey @wobsoriano - the snapshot version command generated the following package versions: Package Version
@clerk/astro 1.3.1-snapshot.v2fc2705
@clerk/backend 1.10.1-snapshot.v2fc2705
@clerk/chrome-extension 1.3.3-snapshot.v2fc2705
@clerk/clerk-js 5.21.1-snapshot.v2fc2705
@clerk/elements 0.15.1-snapshot.v2fc2705
@clerk/clerk-expo 2.2.9-snapshot.v2fc2705
@clerk/express 0.0.38-snapshot.v2fc2705
@clerk/fastify 1.0.40-snapshot.v2fc2705
@clerk/localizations 3.0.1-snapshot.v2fc2705
@clerk/nextjs 5.5.1-snapshot.v2fc2705
@clerk/clerk-react 5.8.1-snapshot.v2fc2705
@clerk/remix 4.2.24-snapshot.v2fc2705
@clerk/clerk-sdk-node 5.0.37-snapshot.v2fc2705
@clerk/shared 2.7.1-snapshot.v2fc2705
@clerk/tanstack-start 0.3.7-snapshot.v2fc2705
@clerk/testing 1.2.20-snapshot.v2fc2705
@clerk/themes 2.1.29-snapshot.v2fc2705
@clerk/types 4.20.1-snapshot.v2fc2705

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

npm i @clerk/astro@1.3.1-snapshot.v2fc2705 --save-exact

@clerk/backend

npm i @clerk/backend@1.10.1-snapshot.v2fc2705 --save-exact

@clerk/chrome-extension

npm i @clerk/chrome-extension@1.3.3-snapshot.v2fc2705 --save-exact

@clerk/clerk-js

npm i @clerk/clerk-js@5.21.1-snapshot.v2fc2705 --save-exact

@clerk/elements

npm i @clerk/elements@0.15.1-snapshot.v2fc2705 --save-exact

@clerk/clerk-expo

npm i @clerk/clerk-expo@2.2.9-snapshot.v2fc2705 --save-exact

@clerk/express

npm i @clerk/express@0.0.38-snapshot.v2fc2705 --save-exact

@clerk/fastify

npm i @clerk/fastify@1.0.40-snapshot.v2fc2705 --save-exact

@clerk/localizations

npm i @clerk/localizations@3.0.1-snapshot.v2fc2705 --save-exact

@clerk/nextjs

npm i @clerk/nextjs@5.5.1-snapshot.v2fc2705 --save-exact

@clerk/clerk-react

npm i @clerk/clerk-react@5.8.1-snapshot.v2fc2705 --save-exact

@clerk/remix

npm i @clerk/remix@4.2.24-snapshot.v2fc2705 --save-exact

@clerk/clerk-sdk-node

npm i @clerk/clerk-sdk-node@5.0.37-snapshot.v2fc2705 --save-exact

@clerk/shared

npm i @clerk/shared@2.7.1-snapshot.v2fc2705 --save-exact

@clerk/tanstack-start

npm i @clerk/tanstack-start@0.3.7-snapshot.v2fc2705 --save-exact

@clerk/testing

npm i @clerk/testing@1.2.20-snapshot.v2fc2705 --save-exact

@clerk/themes

npm i @clerk/themes@2.1.29-snapshot.v2fc2705 --save-exact

@clerk/types

npm i @clerk/types@4.20.1-snapshot.v2fc2705 --save-exact