Spaces:
Sleeping
Sleeping
Download src/modules/n8n/application/useCases/GetInternalCredentialsUseCase.ts from fouadkhalid123/asd: direct link, hf CLI and curl.
- Browser
- Download file 1.24 kB
-
https://huggingface.co/spaces/fouadkhalid123/asd/resolve/main/src/modules/n8n/application/useCases/GetInternalCredentialsUseCase.ts
- Command line
-
hf download hf://spaces/fouadkhalid123/asd/src/modules/n8n/application/useCases/GetInternalCredentialsUseCase.ts
-
curl -L -o GetInternalCredentialsUseCase.ts https://huggingface.co/spaces/fouadkhalid123/asd/resolve/main/src/modules/n8n/application/useCases/GetInternalCredentialsUseCase.ts
1.24 kB
| // application/useCases/internal/GetInternalCredentialsUseCase.ts | |
| import { Vault } from "src/libs/shared/crypto/vault"; | |
| import { UnitOfWorkFactory } from "src/libs/shared/infrastructure/postgres/unitOfWork/UnitOfWorkFactory"; | |
| export interface InternalCredentialsOutput { | |
| accessToken: string; | |
| webhookSecret: string; | |
| shopDomain: string; | |
| apiVersion: string; | |
| phoneNumberId: string | null; | |
| storeId: string; | |
| organizationId: string; | |
| } | |
| export class GetInternalCredentialsUseCase { | |
| constructor(private readonly uowFactory: UnitOfWorkFactory) { } | |
| async execute(storeId: string): Promise<InternalCredentialsOutput | null> { | |
| const cred = await this.uowFactory.execute(async (uow) => | |
| uow.credentials.findByStoreId(storeId) | |
| ); | |
| if (!cred) return null; | |
| const { accessToken, webhookSecret } = JSON.parse( | |
| Vault.decrypt(cred.encryptedCredentials) | |
| ); | |
| return { | |
| accessToken, | |
| webhookSecret, | |
| shopDomain: cred.shopDomain, | |
| apiVersion: cred.apiVersion, | |
| phoneNumberId: cred.phoneNumberId, | |
| storeId: cred.storeId, | |
| organizationId: cred.organizationId | |
| }; | |
| } | |
| } |