diff --git a/apps/api/src/app/proxies/AccountProxy.ts b/apps/api/src/app/proxies/AccountProxy.ts index 8dd0576ce..93b785b86 100644 --- a/apps/api/src/app/proxies/AccountProxy.ts +++ b/apps/api/src/app/proxies/AccountProxy.ts @@ -142,7 +142,7 @@ class AccountProxy { userId, scopes, metadata, - })) as TToken[] + })) as TAccessToken[] ); } diff --git a/apps/api/src/app/services/TokenService.ts b/apps/api/src/app/services/TokenService.ts index 051bd1ade..851505256 100644 --- a/apps/api/src/app/services/TokenService.ts +++ b/apps/api/src/app/services/TokenService.ts @@ -6,7 +6,7 @@ import { logger } from '@thxnetwork/api/util/logger'; import { serviceMap } from '@thxnetwork/api/services/interfaces/IOAuthService'; class TokenService { - async get({ sub, kind }: Partial): Promise { + async get({ sub, kind }: Partial): Promise { const token = await Token.findOne({ sub, kind }); if (!token) return; @@ -19,11 +19,11 @@ class TokenService { } // Store the token for the new account - async set(token: Partial) { + async set(token: Partial) { return await Token.findOneAndUpdate({ sub: token.sub, kind: token.kind }, token, { upsert: true, new: true }); } - async unset({ sub, kind }: Partial) { + async unset({ sub, kind }: Partial) { const token = await this.get({ sub, kind }); // Revoke access at token provider if token has scopes @@ -56,7 +56,7 @@ class TokenService { return Token.findOneAndDelete({ sub, kind }); } - revoke(token: TToken) { + revoke(token: TAccessToken) { return serviceMap[token.kind].revokeToken(token); } } diff --git a/apps/app/src/utils/social.ts b/apps/app/src/utils/social.ts index bacb04599..65d2198e2 100644 --- a/apps/app/src/utils/social.ts +++ b/apps/app/src/utils/social.ts @@ -2,7 +2,9 @@ import { QuestSocialRequirement } from '../types/enums/rewards'; import { AccountVariant } from '../types/enums/accountVariant'; function getConnectedUser(account: TAccount, kind: AccessTokenKind, requiredScopes: TOAuthScope[] = []) { - return account.tokens.find((a) => a.kind === kind && requiredScopes.every((scope) => a.scopes.includes(scope))); + return account.tokens.find( + (a: TAccessToken) => a.kind === kind && requiredScopes.every((scope) => a.scopes.includes(scope)), + ); } export enum AccessTokenKind { diff --git a/libs/common/src/lib/types/Account.d.ts b/libs/common/src/lib/types/Account.d.ts index 1353139e0..430889591 100644 --- a/libs/common/src/lib/types/Account.d.ts +++ b/libs/common/src/lib/types/Account.d.ts @@ -18,7 +18,7 @@ type TAccount = { acceptUpdates: boolean; role: Role; goal: Goal[]; - tokens: TToken[]; + tokens: TAccessToken[]; identity: string; createdAt: Date; updatedAt: Date; diff --git a/libs/common/src/lib/types/Token.d.ts b/libs/common/src/lib/types/Token.d.ts index 4f706d2fb..ee7c1a02f 100644 --- a/libs/common/src/lib/types/Token.d.ts +++ b/libs/common/src/lib/types/Token.d.ts @@ -1,4 +1,4 @@ -type TToken = { +type TAccessToken = { sub: string; kind: AccessTokenKind; accessToken: string;