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 Nov 14, 2024
1 parent 2ef4f33 commit 255ad38
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 3 deletions.
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
2 changes: 2 additions & 0 deletions packages/kit/src/components/Connect/ConnectWalletContent.tsx
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
6 changes: 5 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,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

0 comments on commit 255ad38

Please sign in to comment.