Skip to content

Commit 28d8dcf

Browse files
committed
fix(types): resolve pre-existing TypeScript errors across auth, secrets, and copilot
1 parent 2694390 commit 28d8dcf

6 files changed

Lines changed: 35 additions & 11 deletions

File tree

apps/sim/app/api/auth/socket-token/route.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ export async function POST() {
1010

1111
try {
1212
const hdrs = await headers()
13-
const response = await auth.api.generateOneTimeToken({
13+
const api = auth.api as typeof auth.api & {
14+
generateOneTimeToken: (ctx: { headers: Headers }) => Promise<{ token: string }>
15+
}
16+
const response = await api.generateOneTimeToken({
1417
headers: hdrs,
1518
})
1619

apps/sim/app/api/auth/sso/register/route.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,13 @@ export async function POST(request: NextRequest) {
377377
),
378378
})
379379

380-
const registration = await auth.api.registerSSOProvider({
380+
const api = auth.api as typeof auth.api & {
381+
registerSSOProvider: (ctx: {
382+
body: unknown
383+
headers: Headers
384+
}) => Promise<{ providerId: string }>
385+
}
386+
const registration = await api.registerSSOProvider({
381387
body: providerConfig,
382388
headers,
383389
})

apps/sim/app/api/tools/secrets_manager/utils.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { SecretListEntry, Tag } from '@aws-sdk/client-secrets-manager'
12
import {
23
CreateSecretCommand,
34
DeleteSecretCommand,
@@ -61,15 +62,15 @@ export async function listSecrets(
6162
})
6263

6364
const response = await client.send(command)
64-
const secrets = (response.SecretList ?? []).map((secret) => ({
65+
const secrets = (response.SecretList ?? []).map((secret: SecretListEntry) => ({
6566
name: secret.Name ?? '',
6667
arn: secret.ARN ?? '',
6768
description: secret.Description ?? null,
6869
createdDate: secret.CreatedDate?.toISOString() ?? null,
6970
lastChangedDate: secret.LastChangedDate?.toISOString() ?? null,
7071
lastAccessedDate: secret.LastAccessedDate?.toISOString() ?? null,
7172
rotationEnabled: secret.RotationEnabled ?? false,
72-
tags: secret.Tags?.map((t) => ({ key: t.Key ?? '', value: t.Value ?? '' })) ?? [],
73+
tags: secret.Tags?.map((t: Tag) => ({ key: t.Key ?? '', value: t.Value ?? '' })) ?? [],
7374
}))
7475

7576
return {

apps/sim/lib/auth/auth.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
oneTimeToken,
2020
organization,
2121
} from 'better-auth/plugins'
22+
import type { BetterAuthPlugin } from 'better-auth/types'
2223
import { emailHarmony } from 'better-auth-harmony'
2324
import { and, eq, inArray, sql } from 'drizzle-orm'
2425
import { headers } from 'next/headers'
@@ -559,12 +560,12 @@ export const auth = betterAuth({
559560
github: {
560561
clientId: env.GITHUB_CLIENT_ID as string,
561562
clientSecret: env.GITHUB_CLIENT_SECRET as string,
562-
scopes: ['user:email', 'repo'],
563+
scope: ['user:email', 'repo'],
563564
},
564565
google: {
565566
clientId: env.GOOGLE_CLIENT_ID as string,
566567
clientSecret: env.GOOGLE_CLIENT_SECRET as string,
567-
scopes: [
568+
scope: [
568569
'https://www.googleapis.com/auth/userinfo.email',
569570
'https://www.googleapis.com/auth/userinfo.profile',
570571
],
@@ -602,7 +603,6 @@ export const auth = betterAuth({
602603
emailAndPassword: {
603604
enabled: true,
604605
requireEmailVerification: isEmailVerificationEnabled,
605-
sendVerificationOnSignUp: isEmailVerificationEnabled, // Auto-send verification OTP on signup when verification is required
606606
throwOnMissingCredentials: true,
607607
throwOnInvalidCredentials: true,
608608
sendResetPassword: async ({ user, url, token }, request) => {
@@ -712,7 +712,7 @@ export const auth = betterAuth({
712712
},
713713
plugins: [
714714
nextCookies(),
715-
...(isSignupEmailValidationEnabled ? [emailHarmony()] : []),
715+
...(isSignupEmailValidationEnabled ? [emailHarmony() as BetterAuthPlugin] : []),
716716
...(env.TURNSTILE_SECRET_KEY
717717
? [
718718
captcha({

apps/sim/lib/copilot/orchestrator/tool-executor/index.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -954,10 +954,16 @@ async function generateOAuthLink(
954954
const { headers: getHeaders } = await import('next/headers')
955955
const reqHeaders = await getHeaders()
956956

957-
const data = (await auth.api.oAuth2LinkAccount({
957+
const api = auth.api as typeof auth.api & {
958+
oAuth2LinkAccount: (ctx: {
959+
body: { providerId: string; callbackURL: string }
960+
headers: Headers
961+
}) => Promise<{ url?: string; redirect?: boolean }>
962+
}
963+
const data = await api.oAuth2LinkAccount({
958964
body: { providerId, callbackURL },
959965
headers: reqHeaders,
960-
})) as { url?: string; redirect?: boolean }
966+
})
961967

962968
if (!data?.url) {
963969
throw new Error('oAuth2LinkAccount did not return an authorization URL')

apps/sim/socket/middleware/auth.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,15 @@ export async function authenticateSocket(socket: AuthenticatedSocket, next: (err
5555
origin,
5656
})
5757

58-
const session = await auth.api.verifyOneTimeToken({
58+
const api = auth.api as typeof auth.api & {
59+
verifyOneTimeToken: (ctx: {
60+
body: { token: string }
61+
}) => Promise<{
62+
user: { id: string; name: string; email: string; image?: string | null }
63+
session: { activeOrganizationId?: string | null }
64+
}>
65+
}
66+
const session = await api.verifyOneTimeToken({
5967
body: {
6068
token,
6169
},

0 commit comments

Comments
 (0)