Skip to content

Commit

Permalink
fix: domain final url telegram
Browse files Browse the repository at this point in the history
  • Loading branch information
guru-web3 committed Jan 28, 2025
1 parent 5146e4c commit ec71a75
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion examples/nextjs-app/pages/popupMode/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ class MyApp extends React.Component<IProps, IState> {
[LINE]: { domain: AUTH_DOMAIN },
[COGNITO]: { domain: COGNITO_AUTH_DOMAIN, identity_provider: "Google", response_type: "token", user_info_endpoint: "userInfo" },
[TELEGRAM]: {
domain: AUTH_DOMAIN,
identity_provider: "Telegram",
domain: "https://oauth.tg.dev/auth",
origin: "https://custom-auth-beta.vercel.app/serviceworker/redirect",
},
[REDDIT]: { domain: AUTH_DOMAIN, connection: "Reddit", verifierIdField: "name", isVerifierIdCaseSensitive: false },
Expand Down
6 changes: 5 additions & 1 deletion examples/nextjs-app/pages/redirectMode/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,11 @@ class RedirectMode extends React.Component<IProps, IState> {
[WEIBO]: { domain: AUTH_DOMAIN },
[LINE]: { domain: AUTH_DOMAIN },
[COGNITO]: { domain: COGNITO_AUTH_DOMAIN, identity_provider: "Google", response_type: "token", user_info_endpoint: "userInfo" },
[TELEGRAM]: { domain: AUTH_DOMAIN, identity_provider: "Telegram", origin: "https://custom-auth-beta.vercel.app/auth" },
[TELEGRAM]: {
domain: "https://oauth.tg.dev/auth",
identity_provider: "Telegram",
origin: "https://custom-auth-beta.vercel.app/auth"
},
[REDDIT]: { domain: AUTH_DOMAIN, connection: "Reddit", verifierIdField: "name", isVerifierIdCaseSensitive: false },
};
};
Expand Down
6 changes: 4 additions & 2 deletions src/handlers/TelegramHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import base64url from "base64url";
import deepmerge from "deepmerge";

import { UX_MODE } from "../utils/enums";
import { broadcastChannelOptions, getTimeout } from "../utils/helpers";
import { broadcastChannelOptions, getTimeout, validateAndConstructUrl } from "../utils/helpers";
import log from "../utils/loglevel";
import PopupHandler from "../utils/PopupHandler";
import AbstractLoginHandler from "./AbstractLoginHandler";
Expand Down Expand Up @@ -35,7 +35,9 @@ export default class TelegramHandler extends AbstractLoginHandler {
}

setFinalUrl(): void {
const finalUrl = new URL("https://oauth.telegram.org/auth");
const { domain } = this.params.jwtParams;
const finalUrl = validateAndConstructUrl(domain || "https://oauth.telegram.org/auth");

const clonedParams = JSON.parse(JSON.stringify(this.params.jwtParams || {}));
clonedParams.origin = `${this.params.redirect_uri}?state=${this.state}&nonce=${this.nonce}`;

Expand Down

0 comments on commit ec71a75

Please sign in to comment.