Skip to content

Commit

Permalink
Merge branch 'torusresearch:feat/telegram-verifier' into feat/telegra…
Browse files Browse the repository at this point in the history
…m-verifier
  • Loading branch information
guru-web3 authored Jan 27, 2025
2 parents fc17148 + b831c65 commit dfe7507
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 14 deletions.
1 change: 1 addition & 0 deletions .husky/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npx lint-staged
11 changes: 2 additions & 9 deletions examples/nextjs-app/.gitignore
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
# .gitignore
/.pnp
.pnp.js

# testing
/coverage

# next.js
/.next/
/out/

# production
Expand All @@ -28,7 +24,4 @@ yarn-error.log*
.env.local
.env.development.local
.env.test.local
.env.production.local

# vercel
.vercel
.env.production.local
2 changes: 1 addition & 1 deletion examples/nextjs-app/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const verifierMap = {
[TELEGRAM]: {
name: "Telegram",
typeOfLogin: "telegram",
clientId: "7974448012:AAGLN8ee4WnJhJt6Jc7_Sb275smMs-8K00I",
clientId: "7974448012",
verifier: "test-telegram-2",
},
[EMAIL_PASSWORD]: {
Expand Down
8 changes: 4 additions & 4 deletions src/handlers/TelegramHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,20 @@ export default class TelegramHandler extends AbstractLoginHandler {
this.finalURL = finalUrl;
}

objectToAuthDataMap(tgAuthenticationResulr: string) {
return JSON.parse(atob(tgAuthenticationResulr)) as { first_name: string; last_name: string; photo_url: string; username: string };
objectToAuthDataMap(tgAuthenticationResult: string) {
return JSON.parse(atob(tgAuthenticationResult)) as { first_name: string; last_name: string; photo_url: string; username: string; id: number };
}

async getUserInfo(params: LoginWindowResponse): Promise<TorusVerifierResponse> {
const { idToken } = params;
const userInfo = this.objectToAuthDataMap(idToken);
const { photo_url: profileImage = "", username = "", first_name = "", last_name = "" } = userInfo;
const { photo_url: profileImage = "", first_name = "", last_name = "", id } = userInfo;
return {
email: "", // Telegram does not provide email
name: `${first_name} ${last_name}`,
profileImage,
verifier: this.params.verifier,
verifierId: username.toLowerCase(),
verifierId: id.toString(),
typeOfLogin: this.params.typeOfLogin,
};
}
Expand Down

0 comments on commit dfe7507

Please sign in to comment.