diff --git a/src/algoan/dto/customer.enums.ts b/src/algoan/dto/customer.enums.ts index 6b47b31..ad75c36 100644 --- a/src/algoan/dto/customer.enums.ts +++ b/src/algoan/dto/customer.enums.ts @@ -4,7 +4,7 @@ export enum AggregationDetailsMode { redirect = 'REDIRECT', api = 'API', - iframe = 'IFRAME' + iframe = 'IFRAME', } /** diff --git a/src/algoan/dto/customer.objects.ts b/src/algoan/dto/customer.objects.ts index ca1377c..aec48eb 100644 --- a/src/algoan/dto/customer.objects.ts +++ b/src/algoan/dto/customer.objects.ts @@ -20,7 +20,7 @@ export interface AggregationDetails { mode?: AggregationDetailsMode; redirectUrl?: string; apiUrl?: string; - iframeUrl?: string + iframeUrl?: string; userId?: string; clientId?: string; } diff --git a/src/hooks/services/hooks.service.spec.ts b/src/hooks/services/hooks.service.spec.ts index 003f6ef..ce4be67 100644 --- a/src/hooks/services/hooks.service.spec.ts +++ b/src/hooks/services/hooks.service.spec.ts @@ -41,7 +41,7 @@ import { TINK_LINK_ACTOR_CLIENT_ID } from '../../tink/contstants/tink.constants' import { bankDetailsRequiredMock } from '../dto/bank-details-required-payload.dto.mock'; import { mapTinkDataToAlgoanAnalysis } from '../mappers/analysis.mapper'; -import { AggregationDetailsMode } from '../../algoan/dto/customer.enums' +import { AggregationDetailsMode } from '../../algoan/dto/customer.enums'; import { HooksService } from './hooks.service'; describe('HookService', () => { @@ -286,7 +286,7 @@ describe('HookService', () => { ...customerMock, aggregationDetails: { ...customerMock.aggregationDetails, - mode: AggregationDetailsMode.iframe + mode: AggregationDetailsMode.iframe, }, }); await hookService.handleAggregatorLinkRequiredEvent(aggregatorLinkRequiredMock); @@ -298,7 +298,7 @@ describe('HookService', () => { scope: 'accounts:read,transactions:read,credentials:read', test: config.tink.test, authorization_code: createAuthorizationObjectMock.code, - iframe: true + iframe: true, }); // update @@ -404,7 +404,7 @@ describe('HookService', () => { expect(tinkAuthenticateWithRefreshTokenSpy).toHaveBeenCalledWith( serviceAccountConfigMock.clientId, serviceAccountConfigMock.clientSecret, - 'mockRefreshToken' + 'mockRefreshToken', ); expect(tinkAuthenticateAsUserWithCodesSpy).not.toHaveBeenCalled(); diff --git a/src/hooks/services/hooks.service.ts b/src/hooks/services/hooks.service.ts index aadf88b..d5a129c 100644 --- a/src/hooks/services/hooks.service.ts +++ b/src/hooks/services/hooks.service.ts @@ -3,8 +3,8 @@ import { ServiceAccount } from '@algoan/rest'; import { Injectable, Inject } from '@nestjs/common'; import { Config } from 'node-config-ts'; -import { AggregationDetailsMode } from '../../algoan/dto/customer.enums' -import { CustomerUpdateInput } from '../../algoan/dto/customer.inputs' +import { AggregationDetailsMode } from '../../algoan/dto/customer.enums'; +import { CustomerUpdateInput } from '../../algoan/dto/customer.inputs'; import { assertsTypeValidation } from '../../shared/utils/common.utils'; import { TinkAccountObject } from '../../tink/dto/account.objects'; import { TinkAccountService } from '../../tink/services/tink-account.service'; @@ -29,7 +29,7 @@ import { AlgoanHttpService } from '../../algoan/services/algoan-http.service'; import { AggregatorLinkRequiredDTO } from '../dto/aggregator-link-required-payload.dto'; import { BankDetailsRequiredDTO } from '../dto/bank-details-required-payload.dto'; import { mapTinkDataToAlgoanAnalysis } from '../mappers/analysis.mapper'; -import { AccountCheckArgs } from '../../tink/dto/account-check.args' +import { AccountCheckArgs } from '../../tink/dto/account-check.args'; /** * Hook service @@ -109,7 +109,10 @@ export class HooksService { }); } - const linkData: CustomerUpdateInput["aggregationDetails"] = this.generateLinkDataFromAggregationMode(customer.aggregationDetails.mode, { clientConfig, callbackUrl, authorizationCode}) + const linkData: CustomerUpdateInput['aggregationDetails'] = this.generateLinkDataFromAggregationMode( + customer.aggregationDetails.mode, + { clientConfig, callbackUrl, authorizationCode }, + ); // Update user with redirect link information and userId if provided await this.algoanCustomerService.updateCustomer(payload.customerId, { @@ -128,8 +131,11 @@ export class HooksService { * @param data the input data used for to generate the link data * @returns */ - private generateLinkDataFromAggregationMode(mode: AggregationDetailsMode | undefined, data: { clientConfig: ClientConfig, callbackUrl: string, authorizationCode?: string}): CustomerUpdateInput["aggregationDetails"] { - const { clientConfig, callbackUrl, authorizationCode} = data + private generateLinkDataFromAggregationMode( + mode: AggregationDetailsMode | undefined, + data: { clientConfig: ClientConfig; callbackUrl: string; authorizationCode?: string }, + ): CustomerUpdateInput['aggregationDetails'] { + const { clientConfig, callbackUrl, authorizationCode } = data; const sharedLinkParameters: AccountCheckArgs = { client_id: clientConfig.clientId, redirect_uri: callbackUrl, @@ -142,18 +148,20 @@ export class HooksService { 'credentials:read', // To list providers: https://docs.tink.com/api#provider-list-providers-required-scopes- ].join(','), authorization_code: authorizationCode, - } - + }; switch (mode) { case AggregationDetailsMode.redirect: const redirectUrl: string | undefined = this.tinkLinkService.getAuthorizeLink(sharedLinkParameters); - return { redirectUrl } + return { redirectUrl }; case AggregationDetailsMode.iframe: - const iframeUrl: string | undefined = this.tinkLinkService.getAuthorizeLink({...sharedLinkParameters, iframe: true}); + const iframeUrl: string | undefined = this.tinkLinkService.getAuthorizeLink({ + ...sharedLinkParameters, + iframe: true, + }); - return { iframeUrl } + return { iframeUrl }; default: throw new Error(`Invalid bank connection mode ${mode}`); diff --git a/src/tink/dto/account-check.args.ts b/src/tink/dto/account-check.args.ts index 35e7a76..29ea812 100644 --- a/src/tink/dto/account-check.args.ts +++ b/src/tink/dto/account-check.args.ts @@ -13,5 +13,5 @@ export interface AccountCheckArgs { scope?: string; test: boolean; authorization_code?: string; - iframe?: boolean + iframe?: boolean; }