diff --git a/packages/dapp-toolkit/src/modules/wallet-request/transport/radix-connect-relay/deep-link.module.ts b/packages/dapp-toolkit/src/modules/wallet-request/transport/radix-connect-relay/deep-link.module.ts index 54924169..e2f5b5be 100644 --- a/packages/dapp-toolkit/src/modules/wallet-request/transport/radix-connect-relay/deep-link.module.ts +++ b/packages/dapp-toolkit/src/modules/wallet-request/transport/radix-connect-relay/deep-link.module.ts @@ -1,4 +1,4 @@ -import type { Result, ResultAsync } from 'neverthrow' +import { Result, ResultAsync } from 'neverthrow' import { errAsync, ok, okAsync } from 'neverthrow' import { Logger } from '../../../../helpers' import { ReplaySubject } from 'rxjs' @@ -16,6 +16,27 @@ export const DeepLinkModule = (input: { const { platform, browser } = userAgent const logger = input?.logger?.getSubLogger({ name: 'DeepLinkModule' }) + const getNavigator = (): Navigator | undefined => globalThis?.navigator + + // Only exists in Brave browser + const getBrave = (): { isBrave: () => Promise } | undefined => + (getNavigator() as any)?.brave + + const isBrave = () => { + const maybeBrave = getBrave() + return maybeBrave + ? ResultAsync.fromPromise(maybeBrave.isBrave(), (error) => error as Error) + : okAsync(false) + } + + isBrave().map((isBrave) => { + if (isBrave) { + browser.name = 'Brave' + } + + logger?.debug({ platform, browser }) + }) + const walletResponseSubject = new ReplaySubject>(1) const isCallbackUrl = () => window.location.href.includes(callBackPath)