Skip to content

Commit ec71a75

Browse files
author
Guru
committed
fix: domain final url telegram
1 parent 5146e4c commit ec71a75

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

examples/nextjs-app/pages/popupMode/login.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ class MyApp extends React.Component<IProps, IState> {
105105
[LINE]: { domain: AUTH_DOMAIN },
106106
[COGNITO]: { domain: COGNITO_AUTH_DOMAIN, identity_provider: "Google", response_type: "token", user_info_endpoint: "userInfo" },
107107
[TELEGRAM]: {
108-
domain: AUTH_DOMAIN,
109108
identity_provider: "Telegram",
109+
domain: "https://oauth.tg.dev/auth",
110110
origin: "https://custom-auth-beta.vercel.app/serviceworker/redirect",
111111
},
112112
[REDDIT]: { domain: AUTH_DOMAIN, connection: "Reddit", verifierIdField: "name", isVerifierIdCaseSensitive: false },

examples/nextjs-app/pages/redirectMode/login.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,11 @@ class RedirectMode extends React.Component<IProps, IState> {
9595
[WEIBO]: { domain: AUTH_DOMAIN },
9696
[LINE]: { domain: AUTH_DOMAIN },
9797
[COGNITO]: { domain: COGNITO_AUTH_DOMAIN, identity_provider: "Google", response_type: "token", user_info_endpoint: "userInfo" },
98-
[TELEGRAM]: { domain: AUTH_DOMAIN, identity_provider: "Telegram", origin: "https://custom-auth-beta.vercel.app/auth" },
98+
[TELEGRAM]: {
99+
domain: "https://oauth.tg.dev/auth",
100+
identity_provider: "Telegram",
101+
origin: "https://custom-auth-beta.vercel.app/auth"
102+
},
99103
[REDDIT]: { domain: AUTH_DOMAIN, connection: "Reddit", verifierIdField: "name", isVerifierIdCaseSensitive: false },
100104
};
101105
};

src/handlers/TelegramHandler.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import base64url from "base64url";
22
import deepmerge from "deepmerge";
33

44
import { UX_MODE } from "../utils/enums";
5-
import { broadcastChannelOptions, getTimeout } from "../utils/helpers";
5+
import { broadcastChannelOptions, getTimeout, validateAndConstructUrl } from "../utils/helpers";
66
import log from "../utils/loglevel";
77
import PopupHandler from "../utils/PopupHandler";
88
import AbstractLoginHandler from "./AbstractLoginHandler";
@@ -35,7 +35,9 @@ export default class TelegramHandler extends AbstractLoginHandler {
3535
}
3636

3737
setFinalUrl(): void {
38-
const finalUrl = new URL("https://oauth.telegram.org/auth");
38+
const { domain } = this.params.jwtParams;
39+
const finalUrl = validateAndConstructUrl(domain || "https://oauth.telegram.org/auth");
40+
3941
const clonedParams = JSON.parse(JSON.stringify(this.params.jwtParams || {}));
4042
clonedParams.origin = `${this.params.redirect_uri}?state=${this.state}&nonce=${this.nonce}`;
4143

0 commit comments

Comments
 (0)