| 92 | let activeCredentialHandler: ((credential: string) => void) | null = null; |
| 93 | |
| 94 | const initializeOnce = (googleId: GoogleId, clientId: string): void => { |
| 95 | if (initializedClients.get(googleId) === clientId) { |
| 96 | return; |
| 97 | } |
| 98 | |
| 99 | initializedClients.set(googleId, clientId); |
| 100 | googleId.initialize({ |
| 101 | client_id: clientId, |
| 102 | context: 'signin', |
| 103 | auto_select: false, |
| 104 | cancel_on_tap_outside: false, |
| 105 | ux_mode: 'popup', |
| 106 | itp_support: true, |
| 107 | callback: ({ credential }) => { |
| 108 | if (credential) { |
| 109 | activeCredentialHandler?.(credential); |
| 110 | } |
| 111 | }, |
| 112 | }); |
| 113 | }; |
| 114 | |
| 115 | type UseGoogleOneTapProps = { |
| 116 | enabled: boolean; |