From c30813ebfc1f12a649f97755aef340b89463ab32 Mon Sep 17 00:00:00 2001 From: Ghadi Mhawej Date: Fri, 1 Nov 2024 15:23:46 +0200 Subject: [PATCH 1/3] 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; From 45c9c70986505bcd3a4f0ed795d25e81d6196af7 Mon Sep 17 00:00:00 2001 From: Ghadi Mhawej Date: Fri, 1 Nov 2024 17:36:19 +0200 Subject: [PATCH 2/3] feat: added env var to k8s files --- k8s-staging/staging-secrets.yaml | 4 ++++ k8s-staging/vc-api-deployment.yaml | 5 +++++ k8s/secrets.yaml | 5 ++++- k8s/vc-api-deployment.yaml | 5 +++++ 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/k8s-staging/staging-secrets.yaml b/k8s-staging/staging-secrets.yaml index dc99383..2c4bf37 100644 --- a/k8s-staging/staging-secrets.yaml +++ b/k8s-staging/staging-secrets.yaml @@ -63,6 +63,8 @@ spec: key: ORIGIN - objectName: domain key: DOMAIN + - objectName: telegram_static_page_url + key: TELEGRAM_STATIC_PAGE_URL parameters: @@ -115,3 +117,5 @@ spec: objectAlias: origin - path: DOMAIN objectAlias: domain + - path: TELEGRAM_STATIC_PAGE_URL + objectAlias: telegram_static_page_url diff --git a/k8s-staging/vc-api-deployment.yaml b/k8s-staging/vc-api-deployment.yaml index 35a6cf2..eb2ef7c 100644 --- a/k8s-staging/vc-api-deployment.yaml +++ b/k8s-staging/vc-api-deployment.yaml @@ -143,6 +143,11 @@ spec: secretKeyRef: name: foosecret-verifications key: DOMAIN + - name: TELEGRAM_STATIC_PAGE_URL + valueFrom: + secretKeyRef: + name: foosecret-verifications + key: TELEGRAM_STATIC_PAGE_URL --- apiVersion: v1 kind: Service diff --git a/k8s/secrets.yaml b/k8s/secrets.yaml index 75ccdd1..efb1ef4 100644 --- a/k8s/secrets.yaml +++ b/k8s/secrets.yaml @@ -61,7 +61,8 @@ spec: key: ORIGIN - objectName: domain key: DOMAIN - + - objectName: telegram_static_page_url + key: TELEGRAM_STATIC_PAGE_URL parameters: region: eu-central-1 @@ -111,3 +112,5 @@ spec: objectAlias: origin - path: DOMAIN objectAlias: domain + - path: TELEGRAM_STATIC_PAGE_URL + objectAlias: telegram_static_page_url diff --git a/k8s/vc-api-deployment.yaml b/k8s/vc-api-deployment.yaml index 5c1b050..e2f7165 100644 --- a/k8s/vc-api-deployment.yaml +++ b/k8s/vc-api-deployment.yaml @@ -138,6 +138,11 @@ spec: secretKeyRef: name: foosecret-verifications key: DOMAIN + - name: TELEGRAM_STATIC_PAGE_URL + valueFrom: + secretKeyRef: + name: foosecret-verifications + key: TELEGRAM_STATIC_PAGE_URL --- apiVersion: v1 kind: Service From 004b6ee172e83d55dd449a7bc8372707fa2bdf27 Mon Sep 17 00:00:00 2001 From: Ghadi Mhawej Date: Fri, 1 Nov 2024 17:49:34 +0200 Subject: [PATCH 3/3] fix: fix telegram hash --- .../social-resolver/telegram.social.resolver.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 a3a03ba..967440b 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 @@ -30,7 +30,7 @@ export class TelegramSocialResolver extends AbstractSocialResolver< async extractCredentialSubject( params: TelegramCallback ): Promise { - const { hash, ...telegramData } = params; + const { hash, state, ...telegramData } = params; const dataCheckString = Object.keys(telegramData) .sort()