Skip to content

Commit

Permalink
fix: resolves #3853
Browse files Browse the repository at this point in the history
  • Loading branch information
jxom committed Apr 25, 2024
1 parent cb3a671 commit e3c832a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
7 changes: 7 additions & 0 deletions .changeset/old-fans-count.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@wagmi/connectors": patch
"@wagmi/core": patch
"wagmi": patch
---

Fixed undefined `navigator` issue in MetaMask connector.
12 changes: 7 additions & 5 deletions packages/connectors/src/metaMask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@ export type MetaMaskParameters = Evaluate<
ExactPartial<Omit<MetaMaskSDKOptions, '_source' | 'readonlyRPCMap'>>
>

const isMobileBrowser =
/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
navigator.userAgent,
)

metaMask.type = 'metaMask' as const
export function metaMask(parameters: MetaMaskParameters = {}) {
type Provider = SDKProvider
Expand Down Expand Up @@ -149,6 +144,13 @@ export function metaMask(parameters: MetaMaskParameters = {}) {
},
async isAuthorized() {
try {
const isMobileBrowser =
typeof navigator !== 'undefined'
? /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
navigator.userAgent,
)
: false

// MetaMask Mobile doesn't support persisted sessions.
if (isMobileBrowser) return false

Expand Down

0 comments on commit e3c832a

Please sign in to comment.