From c30813ebfc1f12a649f97755aef340b89463ab32 Mon Sep 17 00:00:00 2001 From: Ghadi Mhawej Date: Fri, 1 Nov 2024 15:23:46 +0200 Subject: [PATCH] feat: change auth url telegram --- apps/vc-api/.env.example | 1 + apps/vc-api/src/config/env.validation.ts | 3 +++ .../social-resolver/telegram.social.resolver.ts | 14 ++++---------- .../applications/environment/environment.getter.ts | 4 ++++ .../environment/ienvironment.getter.ts | 1 + .../vc-api/src/core/domain/entities/environment.ts | 2 ++ 6 files changed, 15 insertions(+), 10 deletions(-) diff --git a/apps/vc-api/.env.example b/apps/vc-api/.env.example index c6275c0..d96212a 100644 --- a/apps/vc-api/.env.example +++ b/apps/vc-api/.env.example @@ -17,6 +17,7 @@ TWITTER_CLIENT_SECRET= TELEGRAM_BOT_USERNAME= +TELEGRAM_STATIC_PAGE_URL= DISCORD_CLIENT_ID= DISCORD_CLIENT_SECRET= diff --git a/apps/vc-api/src/config/env.validation.ts b/apps/vc-api/src/config/env.validation.ts index c4a425e..7bee6d7 100644 --- a/apps/vc-api/src/config/env.validation.ts +++ b/apps/vc-api/src/config/env.validation.ts @@ -58,6 +58,9 @@ class EnvironmentVariables implements Environment{ @IsString({message: 'TELEGRAM_BOT_USERNAME must be a string'}) TELEGRAM_BOT_USERNAME!: string; + @IsString({message: 'TELEGRAM_STATIC_PAGE_URL must be a string'}) + TELEGRAM_STATIC_PAGE_URL!: string; + @IsString({message: 'JWT_SECRET must be a string'}) JWT_SECRET: string; diff --git a/apps/vc-api/src/core/applications/credentials/facade/social-credential-resolver/social-resolver/telegram.social.resolver.ts b/apps/vc-api/src/core/applications/credentials/facade/social-credential-resolver/social-resolver/telegram.social.resolver.ts index 687ba7d..a3a03ba 100644 --- a/apps/vc-api/src/core/applications/credentials/facade/social-credential-resolver/social-resolver/telegram.social.resolver.ts +++ b/apps/vc-api/src/core/applications/credentials/facade/social-credential-resolver/social-resolver/telegram.social.resolver.ts @@ -21,16 +21,10 @@ export class TelegramSocialResolver extends AbstractSocialResolver< } getAuthUrl(authUrlRequest: GetAuthUrlRequest): string { const state = this.encryptState(authUrlRequest); - return ` - - - - `; + + const telegramStaticPageUrl = this.environmentGetter.getTelegramStaticPageUrl(); + + return `${telegramStaticPageUrl}?state=${state}`; } async extractCredentialSubject( diff --git a/apps/vc-api/src/core/applications/environment/environment.getter.ts b/apps/vc-api/src/core/applications/environment/environment.getter.ts index 05be818..81145c5 100644 --- a/apps/vc-api/src/core/applications/environment/environment.getter.ts +++ b/apps/vc-api/src/core/applications/environment/environment.getter.ts @@ -67,6 +67,10 @@ export class EnvironmentGetter implements IEnvironmentGetter { return this.configService.get('TELEGRAM_BOT_USERNAME'); } + getTelegramStaticPageUrl(): string { + return this.configService.get('TELEGRAM_STATIC_PAGE_URL'); + } + getEncryptKey(): string { return this.configService.get('ENCRYPT_KEY'); } diff --git a/apps/vc-api/src/core/applications/environment/ienvironment.getter.ts b/apps/vc-api/src/core/applications/environment/ienvironment.getter.ts index d6e78a8..b8175d6 100644 --- a/apps/vc-api/src/core/applications/environment/ienvironment.getter.ts +++ b/apps/vc-api/src/core/applications/environment/ienvironment.getter.ts @@ -18,6 +18,7 @@ export interface IEnvironmentGetter { getTwitterClientSecret(): string; getTelegramBotToken(): string; getTelegramBotUsername(): string; + getTelegramStaticPageUrl(): string; getEncryptKey(): string; getEncryptSalt(): string; getResendApiKey(): string; diff --git a/apps/vc-api/src/core/domain/entities/environment.ts b/apps/vc-api/src/core/domain/entities/environment.ts index 1acd00e..e1baaf3 100644 --- a/apps/vc-api/src/core/domain/entities/environment.ts +++ b/apps/vc-api/src/core/domain/entities/environment.ts @@ -41,6 +41,8 @@ export class Environment { TELEGRAM_BOT_USERNAME!: string; + TELEGRAM_STATIC_PAGE_URL!: string; + JWT_SECRET!: string; ENCRYPT_KEY!: string;