Skip to content

Commit

Permalink
#6: Some more improvements in device detection
Browse files Browse the repository at this point in the history
  • Loading branch information
andreyjamer committed Mar 14, 2024
1 parent 44a88ba commit 767d042
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import {
} from '@wharfkit/protocol-esr'

import WebSocket from 'isomorphic-ws'
import {createIdentityRequest, Deferred, getChainId} from './utils'
import {createIdentityRequest, Deferred, getChainId, isAndroid} from './utils'
import {BrowserTransport} from './browser'
import {inBrowserPayload, isInBrowserPayload} from './types'

Expand Down Expand Up @@ -374,7 +374,8 @@ export class WalletPluginWebAuth extends AbstractWalletPlugin {
const request = modifiedRequest.encode(true, false, `${this.scheme}:`)

// Mobile will return true or false, desktop will return undefined
const isSameDevice = this.data.sameDevice === true
const isSameDevice =
isAppleHandheld() || isAndroid() ? true : this.data.sameDevice === true

// Same device request
const sameDeviceRequest = modifiedRequest.clone()
Expand Down
4 changes: 4 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,7 @@ function prepareCallbackChannel(buoyUrl): ReceiveOptions {
channel: uuid(),
}
}

export function isAndroid(): boolean {
return /Android/.test(navigator.userAgent)
}

0 comments on commit 767d042

Please sign in to comment.