Skip to content

Commit f441f28

Browse files
committed
cleanup
1 parent a0f559f commit f441f28

File tree

3 files changed

+5
-39
lines changed

3 files changed

+5
-39
lines changed

apps/dashboard/app/api/integrations/vercel/callback/route.ts

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { randomUUID } from 'node:crypto';
22
import { auth } from '@databuddy/auth';
33
import { account, and, db, eq } from '@databuddy/db';
4-
import { encryptToken } from '@databuddy/shared';
54
import { headers } from 'next/headers';
65
import { type NextRequest, NextResponse } from 'next/server';
76

@@ -98,30 +97,19 @@ export async function GET(request: NextRequest) {
9897
where: and(eq(account.userId, userId), eq(account.providerId, 'vercel')),
9998
});
10099

101-
const now = new Date();
100+
const now = new Date().toISOString();
102101
const scopeData = JSON.stringify({
103102
configurationId,
104103
teamId,
105104
installationId: tokens.installation_id,
106105
tokenType: tokens.token_type,
107106
});
108107

109-
// Encrypt the access token using Better Auth secret
110-
const betterAuthSecret = process.env.BETTER_AUTH_SECRET;
111-
if (!betterAuthSecret) {
112-
throw new Error('BETTER_AUTH_SECRET environment variable is required');
113-
}
114-
115-
const encryptedAccessToken = encryptToken(
116-
tokens.access_token,
117-
betterAuthSecret
118-
);
119-
120108
if (existingAccount) {
121109
await db
122110
.update(account)
123111
.set({
124-
accessToken: encryptedAccessToken,
112+
accessToken: tokens.access_token,
125113
scope: scopeData,
126114
updatedAt: now,
127115
})
@@ -132,7 +120,7 @@ export async function GET(request: NextRequest) {
132120
accountId: userInfo.id,
133121
providerId: 'vercel',
134122
userId,
135-
accessToken: encryptedAccessToken,
123+
accessToken: tokens.access_token,
136124
scope: scopeData,
137125
createdAt: now,
138126
updatedAt: now,

apps/dashboard/next.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ const nextConfig: NextConfig = {
2525
},
2626

2727
output: 'standalone',
28+
transpilePackages: ['@t3-oss/env-nextjs', '@t3-oss/env-core'],
2829
};
2930

3031
export function headers() {

packages/rpc/src/routers/vercel.ts

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { account } from '@databuddy/db';
2-
import { decryptToken } from '@databuddy/shared';
32
import { TRPCError } from '@trpc/server';
43
import { and, eq } from 'drizzle-orm';
54
import { z } from 'zod';
@@ -28,29 +27,7 @@ const getVercelToken = async (userId: string, db: any): Promise<string> => {
2827
});
2928
}
3029

31-
// Decrypt the access token using Better Auth secret
32-
const betterAuthSecret = process.env.BETTER_AUTH_SECRET;
33-
if (!betterAuthSecret) {
34-
throw new TRPCError({
35-
code: 'INTERNAL_SERVER_ERROR',
36-
message: 'Server configuration error: BETTER_AUTH_SECRET is missing',
37-
});
38-
}
39-
40-
try {
41-
const decryptedToken = decryptToken(
42-
vercelAccount.accessToken,
43-
betterAuthSecret
44-
);
45-
return decryptedToken;
46-
} catch (decryptionError) {
47-
console.error('Token decryption failed:', decryptionError);
48-
throw new TRPCError({
49-
code: 'UNAUTHORIZED',
50-
message:
51-
'Failed to decrypt Vercel access token. Please reconnect your Vercel account.',
52-
});
53-
}
30+
return vercelAccount.accessToken;
5431
} catch (error) {
5532
if (error instanceof TRPCError) {
5633
throw error;

0 commit comments

Comments
 (0)