From 2a3acfa5b3bebd8fbdb56d6908149ae6d1412b6c Mon Sep 17 00:00:00 2001 From: gregfromstl Date: Fri, 26 Jul 2024 11:49:52 -0500 Subject: [PATCH] feat: telegram login --- apps/playground-web/src/lib/constants.ts | 2 +- .../thirdweb/src/react/core/utils/socialIcons.ts | 3 +++ .../src/react/native/ui/components/WalletImage.tsx | 3 +++ .../src/react/native/ui/connect/InAppWalletUI.tsx | 2 ++ packages/thirdweb/src/react/native/ui/icons/svgs.ts | 13 +++++++++++++ .../src/react/web/ui/components/WalletImage.tsx | 4 ++++ .../wallets/shared/ConnectWalletSocialOptions.tsx | 1 + .../src/react/web/wallets/shared/oauthSignIn.ts | 1 + .../src/wallets/in-app/core/authentication/type.ts | 1 + .../src/wallets/in-app/native/native-connector.ts | 1 + .../src/wallets/in-app/web/lib/web-connector.ts | 1 + packages/thirdweb/src/wallets/types.ts | 1 + 12 files changed, 32 insertions(+), 1 deletion(-) diff --git a/apps/playground-web/src/lib/constants.ts b/apps/playground-web/src/lib/constants.ts index bb775241a19..73214b98047 100644 --- a/apps/playground-web/src/lib/constants.ts +++ b/apps/playground-web/src/lib/constants.ts @@ -10,7 +10,7 @@ export const WALLETS = [ options: [ "google", "discord", - "apple", + "telegram", "email", "passkey", "phone", diff --git a/packages/thirdweb/src/react/core/utils/socialIcons.ts b/packages/thirdweb/src/react/core/utils/socialIcons.ts index 432a0392fc6..5465d902200 100644 --- a/packages/thirdweb/src/react/core/utils/socialIcons.ts +++ b/packages/thirdweb/src/react/core/utils/socialIcons.ts @@ -21,6 +21,8 @@ export const discordIconUri = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGVuYWJsZS1iYWNrZ3JvdW5kPSJuZXcgMCAwIDEwMCAxMDAiIHZpZXdCb3g9IjAgMCAxMDAgMTAwIiBpZD0iZGlzY29yZCI+PHBhdGggZmlsbD0iIzY2NjVkMiIgZD0iTTg1LjIyLDI0Ljk1OGM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Q9IlBhdGgtMyIgZmlsbD0iI0ZGRkZGRiI+PC9wYXRoPgogICAgPC9nPgo8L3N2Zz4="; export const microsoftIconUri = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciICB2aWV3Qm94PSIwIDAgNDggNDgiIHdpZHRoPSI0OHB4IiBoZWlnaHQ9IjQ4cHgiPjxwYXRoIGZpbGw9IiNmZjU3MjIiIGQ9Ik02IDZIMjJWMjJINnoiIHRyYW5zZm9ybT0icm90YXRlKC0xODAgMTQgMTQpIi8+PHBhdGggZmlsbD0iIzRjYWY1MCIgZD0iTTI2IDZINDJWMjJIMjZ6IiB0cmFuc2Zvcm09InJvdGF0ZSgtMTgwIDM0IDE0KSIvPjxwYXRoIGZpbGw9IiNmZmMxMDciIGQ9Ik0yNiAyNkg0MlY0MkgyNnoiIHRyYW5zZm9ybT0icm90YXRlKC0xODAgMzQgMzQpIi8+PHBhdGggZmlsbD0iIzAzYTlmNCIgZD0iTTYgMjZIMjJWNDJINnoiIHRyYW5zZm9ybT0icm90YXRlKC0xODAgMTQgMzQpIi8+PC9zdmc+"; @@ -51,4 +53,5 @@ export const socialIcons = { facebook: facebookIconUri, discord: discordIconUri, farcaster: farcasterIconUri, + telegram: telegramIconUri, }; diff --git a/packages/thirdweb/src/react/native/ui/components/WalletImage.tsx b/packages/thirdweb/src/react/native/ui/components/WalletImage.tsx index b8913f64ae9..2b2d5f687f2 100644 --- a/packages/thirdweb/src/react/native/ui/components/WalletImage.tsx +++ b/packages/thirdweb/src/react/native/ui/components/WalletImage.tsx @@ -13,6 +13,7 @@ import { FARCASTER_ICON, GOOGLE_ICON, PHONE_ICON, + TELEGRAM_ICON, WALLET_ICON, } from "../icons/svgs.js"; import { RNImage } from "./RNImage.js"; @@ -79,6 +80,8 @@ export function getAuthProviderImage(lastAuthProvider: string | null): string { return DISCORD_ICON; case "farcaster": return FARCASTER_ICON; + case "telegram": + return TELEGRAM_ICON; default: return WALLET_ICON; } diff --git a/packages/thirdweb/src/react/native/ui/connect/InAppWalletUI.tsx b/packages/thirdweb/src/react/native/ui/connect/InAppWalletUI.tsx index c062a35a3ea..a0841a81e04 100644 --- a/packages/thirdweb/src/react/native/ui/connect/InAppWalletUI.tsx +++ b/packages/thirdweb/src/react/native/ui/connect/InAppWalletUI.tsx @@ -33,6 +33,7 @@ import { FARCASTER_ICON, GOOGLE_ICON, PHONE_ICON, + TELEGRAM_ICON, } from "../icons/svgs.js"; import type { ModalState } from "./ConnectModal.js"; @@ -50,6 +51,7 @@ const socialIcons = { apple: APPLE_ICON, discord: DISCORD_ICON, farcaster: FARCASTER_ICON, + telegram: TELEGRAM_ICON, }; type InAppWalletFormUIProps = { diff --git a/packages/thirdweb/src/react/native/ui/icons/svgs.ts b/packages/thirdweb/src/react/native/ui/icons/svgs.ts index d655eac47de..e4b9c7ed9ae 100644 --- a/packages/thirdweb/src/react/native/ui/icons/svgs.ts +++ b/packages/thirdweb/src/react/native/ui/icons/svgs.ts @@ -44,6 +44,19 @@ export const FARCASTER_ICON = ` `; +export const TELEGRAM_ICON = ` + + + + + + + + + + +`; + export const EMAIL_ICON = ` diff --git a/packages/thirdweb/src/react/web/ui/components/WalletImage.tsx b/packages/thirdweb/src/react/web/ui/components/WalletImage.tsx index 4a7d3271dfb..de8340613a8 100644 --- a/packages/thirdweb/src/react/web/ui/components/WalletImage.tsx +++ b/packages/thirdweb/src/react/web/ui/components/WalletImage.tsx @@ -18,6 +18,7 @@ import { googleIconUri, passkeyIcon, phoneIcon, + telegramIconUri, } from "../../../core/utils/socialIcons.js"; import { getLastAuthProvider } from "../../../core/utils/storage.js"; import { useWalletImage } from "../../../core/utils/wallet.js"; @@ -81,6 +82,9 @@ export function WalletImage(props: { case "farcaster": image = farcasterIconUri; break; + case "telegram": + image = telegramIconUri; + break; } } else { const mipdImage = getInstalledWalletProviders().find( diff --git a/packages/thirdweb/src/react/web/wallets/shared/ConnectWalletSocialOptions.tsx b/packages/thirdweb/src/react/web/wallets/shared/ConnectWalletSocialOptions.tsx index 1b2b745038e..a30bacb2bbd 100644 --- a/packages/thirdweb/src/react/web/wallets/shared/ConnectWalletSocialOptions.tsx +++ b/packages/thirdweb/src/react/web/wallets/shared/ConnectWalletSocialOptions.tsx @@ -92,6 +92,7 @@ export const ConnectWalletSocialOptions = ( apple: locale.signInWithApple, discord: locale.signInWithDiscord, farcaster: "Farcaster", + telegram: "Telegram", }; const { data: ecosystemAuthOptions, isLoading } = useQuery({ diff --git a/packages/thirdweb/src/react/web/wallets/shared/oauthSignIn.ts b/packages/thirdweb/src/react/web/wallets/shared/oauthSignIn.ts index f71e6203354..be1fa6d8184 100644 --- a/packages/thirdweb/src/react/web/wallets/shared/oauthSignIn.ts +++ b/packages/thirdweb/src/react/web/wallets/shared/oauthSignIn.ts @@ -34,6 +34,7 @@ function getOauthLoginPath( case "facebook": case "google": case "farcaster": + case "telegram": case "discord": return getSocialAuthLoginPath({ authOption, client, ecosystem }); default: diff --git a/packages/thirdweb/src/wallets/in-app/core/authentication/type.ts b/packages/thirdweb/src/wallets/in-app/core/authentication/type.ts index cd01604cfba..056ad901240 100644 --- a/packages/thirdweb/src/wallets/in-app/core/authentication/type.ts +++ b/packages/thirdweb/src/wallets/in-app/core/authentication/type.ts @@ -63,6 +63,7 @@ export enum AuthProvider { PASSKEY = "Passkey", DISCORD = "Discord", FARCASTER = "Farcaster", + TELEGRAM = "Telegram", } export type OauthOption = { diff --git a/packages/thirdweb/src/wallets/in-app/native/native-connector.ts b/packages/thirdweb/src/wallets/in-app/native/native-connector.ts index cf5eefde379..712bb1d87a4 100644 --- a/packages/thirdweb/src/wallets/in-app/native/native-connector.ts +++ b/packages/thirdweb/src/wallets/in-app/native/native-connector.ts @@ -110,6 +110,7 @@ export class InAppNativeConnector implements InAppConnector { case "facebook": case "discord": case "farcaster": + case "telegram": case "apple": { const ExpoLinking = require("expo-linking"); const redirectUrl = diff --git a/packages/thirdweb/src/wallets/in-app/web/lib/web-connector.ts b/packages/thirdweb/src/wallets/in-app/web/lib/web-connector.ts index 159d5ba56a3..776d00f8f54 100644 --- a/packages/thirdweb/src/wallets/in-app/web/lib/web-connector.ts +++ b/packages/thirdweb/src/wallets/in-app/web/lib/web-connector.ts @@ -223,6 +223,7 @@ export class InAppWebConnector implements InAppConnector { case "facebook": case "google": case "farcaster": + case "telegram": case "discord": { const authToken = await loginWithOauth({ authOption: strategy, diff --git a/packages/thirdweb/src/wallets/types.ts b/packages/thirdweb/src/wallets/types.ts index a422b3246f4..4e9d0c42ce1 100644 --- a/packages/thirdweb/src/wallets/types.ts +++ b/packages/thirdweb/src/wallets/types.ts @@ -25,6 +25,7 @@ export const socialAuthOptions = [ "facebook", "discord", "farcaster", + "telegram", ] as const; export type SocialAuthOption = (typeof socialAuthOptions)[number];