Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

experimental google auth redirect #146

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 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,14 @@ import { ExtendedWalletList } from './ExtendedWalletList'
interface ConnectWalletContentProps extends KitConnectProviderProps {
emailConflictInfo?: FormattedEmailConflictInfo | null
onClose: () => void
googleUseRedirectMode?: boolean
googleRedirectModeLoginUri?: string
}

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

const { onClose, emailConflictInfo, config = {} } = props
const { onClose, emailConflictInfo, config = {}, googleUseRedirectMode, googleRedirectModeLoginUri } = props
const { signIn = {} } = config as KitConfig
const { isConnected } = useAccount()
const storage = useStorage()
Expand Down Expand Up @@ -233,7 +235,12 @@ 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}
googleRedirectModeLoginUri={googleRedirectModeLoginUri}
/>
) : 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 @@ -11,6 +11,8 @@ interface ConnectWalletContent extends KitConnectProviderProps {
emailConflictInfo?: FormattedEmailConflictInfo | null
onClose: () => void
isPreview?: boolean
googleUseRedirectMode?: boolean
googleRedirectModeLoginUri?: string
}

export const ConnectWalletContent = (props: ConnectWalletContent) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ interface ConnectButtonProps {
connector: ExtendedConnector
label?: string
onConnect: (connector: ExtendedConnector) => void
googleUseRedirectMode?: boolean
googleRedirectModeLoginUri?: string
}

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

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

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

export type StorageItem = {
Expand Down