♻️ Remove @typebot.io/schemas from @typebot.io/lib
This commit is contained in:
@ -1,6 +1,5 @@
|
||||
import { env } from '@typebot.io/env'
|
||||
import { Credentials as CredentialsFromDb } from '@typebot.io/prisma'
|
||||
import { GoogleSheetsCredentials } from '@typebot.io/schemas'
|
||||
import { decrypt } from './api/encryption/decrypt'
|
||||
import { encrypt } from './api/encryption/encrypt'
|
||||
import prisma from './prisma'
|
||||
@ -14,10 +13,7 @@ export const getAuthenticatedGoogleClient = async (
|
||||
where: { id: credentialsId },
|
||||
})) as CredentialsFromDb | undefined
|
||||
if (!credentials) return
|
||||
const data = (await decrypt(
|
||||
credentials.data,
|
||||
credentials.iv
|
||||
)) as GoogleSheetsCredentials['data']
|
||||
const data = await decrypt(credentials.data, credentials.iv)
|
||||
|
||||
const oauth2Client = new OAuth2Client(
|
||||
env.GOOGLE_CLIENT_ID,
|
||||
@ -30,17 +26,14 @@ export const getAuthenticatedGoogleClient = async (
|
||||
}
|
||||
|
||||
const updateTokens =
|
||||
(
|
||||
credentialsId: string,
|
||||
existingCredentials: GoogleSheetsCredentials['data']
|
||||
) =>
|
||||
(credentialsId: string, existingCredentials: any) =>
|
||||
async (credentials: Credentials) => {
|
||||
if (
|
||||
isDefined(existingCredentials.id_token) &&
|
||||
credentials.id_token !== existingCredentials.id_token
|
||||
)
|
||||
return
|
||||
const newCredentials: GoogleSheetsCredentials['data'] = {
|
||||
const newCredentials = {
|
||||
...existingCredentials,
|
||||
expiry_date: credentials.expiry_date,
|
||||
access_token: credentials.access_token,
|
||||
|
Reference in New Issue
Block a user