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

Enhanced Telegram MiniApp #689

Merged
merged 13 commits into from
Nov 13, 2024
2 changes: 1 addition & 1 deletion single-factor-auth-web/sfa-web-ton-telegram-example/.env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VITE_SERVER_URL="" # server-url
VITE_SERVER_URL="http://localhost:3000" # server-url
VITE_W3A_VERIFIER_NAME="" # w3a-verifier-name
VITE_W3A_CLIENT_ID="" # w3a-client-id from web3auth dashboard
REACT_APP_SERVER_URL="http://localhost:3000" # server-url
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"@web3auth/base": "^9.3.0",
"@web3auth/base-provider": "^9.3.0",
"@web3auth/single-factor-auth": "^9.2.0",
"lucide-react": "^0.454.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"source-map-loader": "^4.0.1",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { Telegraf } from "telegraf";

export default async function handler(req, res) {
if (req.method !== 'POST') {
return res.status(405).json({ error: 'Method not allowed' });
}

const bot = new Telegraf(process.env.TELEGRAM_BOT_TOKEN);

bot.command('start', async (ctx) => {
await ctx.reply(
`Welcome to Web3Auth Telegram MiniApp! 🌟

Experience blockchain wallets reimagined inside Telegram! Our demo showcases integration with the TON blockchain, but that's just the beginning - the same seamless experience can be adapted for any blockchain network.

How does it work? It's brilliantly simple:
- Your Telegram identity securely powers your Web3 wallet creation
- Access your wallet seamlessly across all your Telegram devices
- No repeated setups - your wallet is always ready when you are

Ready to experience the future of Web3 authentication?`,
{
reply_markup: {
inline_keyboard: [[
{
text: "Launch Web3Auth Telegram MiniApp 🚀",
web_app: { url: process.env.APP_URL }
}
]]
}
}
);
});

try {
await bot.handleUpdate(req.body);
res.status(200).json({ ok: true });
} catch (error) {
console.error('Webhook handling error:', error);
res.status(500).json({ error: 'Failed to process update' });
}
}

export const config = {
api: {
bodyParser: false,
},
};

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"express": "^4.19.2",
"express-rate-limit": "^7.4.0",
"express-session": "^1.18.0",
"jsonwebtoken": "^8.5.1"
"jsonwebtoken": "^8.5.1",
"telegraf": "^4.16.3"
},
"description": "",
"keywords": [],
Expand Down
Loading