Skip to content

Commit

Permalink
experimental google auth redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
bunnybones1 committed Sep 26, 2024
1 parent 56597d9 commit 878e07d
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 3 deletions.
9 changes: 7 additions & 2 deletions packages/kit/src/components/Connect/Connect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@ import { ExtendedWalletList } from './ExtendedWalletList'
interface ConnectWalletContentProps extends KitConnectProviderProps {
emailConflictInfo?: FormattedEmailConflictInfo | null
onClose: () => void
googleUseRedirectMode?: boolean
}

export const Connect = (props: ConnectWalletContentProps) => {
useScript(appleAuthHelpers.APPLE_SCRIPT_SRC)

const { onClose, emailConflictInfo, config = {} } = props
const { onClose, emailConflictInfo, config = {}, googleUseRedirectMode } = props
const { signIn = {} } = config as KitConfig
const { isConnected } = useAccount()
const storage = useStorage()
Expand Down Expand Up @@ -231,7 +232,11 @@ export const Connect = (props: ConnectWalletContentProps) => {
return (
<Box key={connector.uid} aspectRatio="1/1" alignItems="center" justifyContent="center">
{connector._wallet.id === 'google-waas' ? (
<GoogleWaasConnectButton connector={connector} onConnect={onConnect} />
<GoogleWaasConnectButton
connector={connector}
onConnect={onConnect}
googleUseRedirectMode={googleUseRedirectMode}
/>
) : connector._wallet.id === 'apple-waas' ? (
<AppleWaasConnectButton connector={connector} onConnect={onConnect} />
) : connector._wallet.id.includes('email') ? (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { Connect } from './Connect'
interface ConnectWalletContent extends KitConnectProviderProps {
emailConflictInfo?: FormattedEmailConflictInfo | null
onClose: () => void
googleUseRedirectMode?: boolean
}

export const ConnectWalletContent = (props: ConnectWalletContent) => {
Expand Down
4 changes: 3 additions & 1 deletion packages/kit/src/components/ConnectButton/ConnectButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ interface ConnectButtonProps {
connector: ExtendedConnector
label?: string
onConnect: (connector: ExtendedConnector) => void
googleUseRedirectMode?: boolean
}

export const ConnectButton = (props: ConnectButtonProps) => {
Expand Down Expand Up @@ -47,7 +48,7 @@ export const ConnectButton = (props: ConnectButtonProps) => {
}

export const GoogleWaasConnectButton = (props: ConnectButtonProps) => {
const { connector, onConnect } = props
const { connector, onConnect, googleUseRedirectMode } = props
const storage = useStorage()

const [enableGoogleTooltip, setEnableGoogleTooltip] = useState(false)
Expand Down Expand Up @@ -95,6 +96,7 @@ export const GoogleWaasConnectButton = (props: ConnectButtonProps) => {
onError={() => {
console.log('Login Failed')
}}
ux_mode={googleUseRedirectMode ? 'redirect' : 'popup'}
/>
</Box>
<Box
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ export const KitPreviewProvider = (props: KitConnectProviderProps) => {
<ConnectWalletContent
onClose={() => setOpenConnectModal(false)}
emailConflictInfo={emailConflictInfo}
googleUseRedirectMode={props.config.googleUseRedirectMode}
{...props}
/>
</ThemeProvider>
Expand Down
1 change: 1 addition & 0 deletions packages/kit/src/components/KitProvider/KitProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ export const KitProvider = (props: KitConnectProviderProps) => {
<ConnectWalletContent
onClose={() => setOpenConnectModal(false)}
emailConflictInfo={emailConflictInfo}
googleUseRedirectMode={props.config.googleUseRedirectMode}
{...props}
/>
</Modal>
Expand Down
1 change: 1 addition & 0 deletions packages/kit/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export interface KitConfig {
displayedAssets?: DisplayedAsset[]
ethAuth?: EthAuthSettings
isDev?: boolean
googleUseRedirectMode?: boolean
}

export type StorageItem = {
Expand Down

0 comments on commit 878e07d

Please sign in to comment.