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

Session Token Testnet Faucet #12

Merged
merged 35 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
7ec1d69
feat: create @session/auth package
Aerilym Jul 4, 2024
cfa8d9d
feat: add telegram and discord connect buttons to faucet
Aerilym Jul 4, 2024
38137ef
fix: add callback to auth
Aerilym Jul 4, 2024
a7a0ab8
fix: add callback url
Aerilym Jul 4, 2024
702e33b
fix: add hidden button click
Aerilym Jul 4, 2024
a664418
fix: test real button
Aerilym Jul 4, 2024
a4a774a
fix: parse json from telegram
Aerilym Jul 4, 2024
d59c7af
chore: log
Aerilym Jul 4, 2024
8b00a97
chore: properly type telegram object
Aerilym Jul 4, 2024
a2eedd6
chore: test log
Aerilym Jul 4, 2024
7f6b1ff
fix: add telegram session passer
Aerilym Jul 4, 2024
85baeb9
chore: session checks
Aerilym Jul 4, 2024
c1809fe
chore: add telegram session handler
Aerilym Jul 4, 2024
616d5f9
fix: add workaround for telegram id
Aerilym Jul 4, 2024
d41b166
fix: use styled button for telegram auth
Aerilym Jul 4, 2024
96f9642
chore: resolve auth imports
Aerilym Jul 4, 2024
c68e8b9
fix: add layered button
Aerilym Jul 4, 2024
89a33c9
chore: remove unused csrf
Aerilym Jul 4, 2024
9ead398
feat: add database logic to faucet
Aerilym Jul 8, 2024
0dc7afc
feat: create new auth module for the faucet
Aerilym Jul 8, 2024
a69ad50
fix: add correct telegram id logic to auth library
Aerilym Jul 8, 2024
6f8fa62
fix: update faucet constants and strings
Aerilym Jul 8, 2024
26ca5b0
chore: add eth decimals to wallet lib
Aerilym Jul 8, 2024
7e1559c
feat: add hide balance option to wallet button
Aerilym Jul 8, 2024
4404f7c
feat: add better-sqlite3-multiple-ciphers
Aerilym Jul 8, 2024
e530e76
fix: move wagmi wallet functions into useWallet hook
Aerilym Jul 8, 2024
b70cc5f
fix: render form error message in the faucet landing page if the subm…
Aerilym Jul 8, 2024
cd448e4
chore: comment spelling
Aerilym Jul 8, 2024
8b6a8ca
fix: add padding in mobile and add discord and telegram to faucet bac…
Aerilym Jul 8, 2024
5ad1a27
chore: capitalise back button on faucet
Aerilym Jul 9, 2024
8603a6a
fix: apply review changes
Aerilym Jul 9, 2024
8a710bb
chore: retype telegram auth callback
Aerilym Jul 9, 2024
28eeb71
fix: apply database fixes
Aerilym Jul 9, 2024
29f7050
chore: update faucet warning text
Aerilym Jul 9, 2024
4fac609
fix: remove lint ignoring from next config
Aerilym Jul 9, 2024
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
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,9 @@ yarn-error.log*
# Misc
.DS_Store
*.pem
.cache
.cache

# Databases
*.sqlite
*.sqlite3
*.db
10 changes: 9 additions & 1 deletion apps/staking/.env.local.template
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID=
NEXT_PUBLIC_SENT_STAKING_API_URL=
FAUCET_WALLET_PRIVATE_KEY=
NEXT_PUBLIC_ENV_FLAG= pick from dev, qa, stg, prd
FAUCET_DB_SECRET_KEY=
FAUCET_HOURS_BETWEEN_USES=
FAUCET_CHAIN=testnet
NEXT_PUBLIC_ENV_FLAG= pick from dev, qa, stg, prd
DISCORD_CLIENT_ID=
DISCORD_CLIENT_SECRET=
TELEGRAM_BOT_TOKEN=
NEXTAUTH_SECRET=
NEXTAUTH_URL=
32 changes: 32 additions & 0 deletions apps/staking/app/api/auth/[...nextauth]/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { createAuthHandler } from '@session/auth/api';
import { DiscordProvider, handleDiscordSession } from '@session/auth/providers/discord';
import { TelegramProvider, handleTelegramSession } from '@session/auth/providers/telegram';

const discordClientId = process.env.DISCORD_CLIENT_ID;
const discordClientSecret = process.env.DISCORD_CLIENT_SECRET;
const telegramBotToken = process.env.TELEGRAM_BOT_TOKEN;

if (!discordClientId || !discordClientSecret) {
throw new Error('Discord client ID and client secret must be provided');
}

if (!telegramBotToken) {
throw new Error('Telegram bot token must be provided');
}

export const { GET, POST } = createAuthHandler({
providers: [
DiscordProvider({
clientId: discordClientId,
clientSecret: discordClientSecret,
}),
TelegramProvider({ botToken: telegramBotToken }),
],
callbacks: {
async session({ session, token }) {
handleDiscordSession({ session, token });
handleTelegramSession({ session, token });
return session;
},
},
});
Loading