mirror of
https://github.com/simstudioai/sim.git
synced 2026-01-08 22:48:14 -05:00
chore: added husky + ran format
This commit is contained in:
1
.husky/pre-commit
Executable file
1
.husky/pre-commit
Executable file
@@ -0,0 +1 @@
|
||||
cd sim && npx lint-staged
|
||||
@@ -43,7 +43,7 @@ export async function GET(request: NextRequest) {
|
||||
.from(user)
|
||||
.where(eq(user.id, session.user.id))
|
||||
.limit(1)
|
||||
|
||||
|
||||
const userEmail = userRecord.length > 0 ? userRecord[0].email : null
|
||||
|
||||
// Process accounts to determine connections
|
||||
@@ -56,7 +56,7 @@ export async function GET(request: NextRequest) {
|
||||
if (provider && VALID_PROVIDERS.includes(provider)) {
|
||||
// Try multiple methods to get a user-friendly display name
|
||||
let displayName = ''
|
||||
|
||||
|
||||
// Method 1: Try to extract email from ID token (works for Google, etc.)
|
||||
if (acc.idToken) {
|
||||
try {
|
||||
@@ -70,17 +70,17 @@ export async function GET(request: NextRequest) {
|
||||
logger.warn(`[${requestId}] Error decoding ID token`, { accountId: acc.id })
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Method 2: For GitHub, the accountId might be the username
|
||||
if (!displayName && provider === 'github') {
|
||||
displayName = `${acc.accountId} (GitHub)`
|
||||
}
|
||||
|
||||
|
||||
// Method 3: Use the user's email from our database
|
||||
if (!displayName && userEmail) {
|
||||
displayName = userEmail
|
||||
}
|
||||
|
||||
|
||||
// Fallback: Use accountId with provider type as context
|
||||
if (!displayName) {
|
||||
displayName = `${acc.accountId} (${provider})`
|
||||
@@ -90,9 +90,7 @@ export async function GET(request: NextRequest) {
|
||||
const connectionKey = acc.providerId
|
||||
|
||||
// Find existing connection for this specific provider ID
|
||||
const existingConnection = connections.find(
|
||||
(conn) => conn.provider === connectionKey
|
||||
)
|
||||
const existingConnection = connections.find((conn) => conn.provider === connectionKey)
|
||||
|
||||
if (existingConnection) {
|
||||
// Add account to existing connection
|
||||
|
||||
@@ -58,7 +58,7 @@ export async function GET(request: NextRequest) {
|
||||
|
||||
// Try multiple methods to get a user-friendly display name
|
||||
let displayName = ''
|
||||
|
||||
|
||||
// Method 1: Try to extract email from ID token (works for Google, etc.)
|
||||
if (acc.idToken) {
|
||||
try {
|
||||
@@ -72,12 +72,12 @@ export async function GET(request: NextRequest) {
|
||||
logger.warn(`[${requestId}] Error decoding ID token`, { accountId: acc.id })
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Method 2: For GitHub, the accountId might be the username
|
||||
if (!displayName && baseProvider === 'github') {
|
||||
displayName = `${acc.accountId} (GitHub)`
|
||||
}
|
||||
|
||||
|
||||
// Method 3: Try to get the user's email from our database
|
||||
if (!displayName) {
|
||||
try {
|
||||
@@ -86,7 +86,7 @@ export async function GET(request: NextRequest) {
|
||||
.from(user)
|
||||
.where(eq(user.id, acc.userId))
|
||||
.limit(1)
|
||||
|
||||
|
||||
if (userRecord.length > 0) {
|
||||
displayName = userRecord[0].email
|
||||
}
|
||||
@@ -94,7 +94,7 @@ export async function GET(request: NextRequest) {
|
||||
logger.warn(`[${requestId}] Error fetching user email`, { userId: acc.userId })
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Fallback: Use accountId with provider type as context
|
||||
if (!displayName) {
|
||||
displayName = `${acc.accountId} (${baseProvider})`
|
||||
|
||||
@@ -18,6 +18,12 @@ import { cn } from '@/lib/utils'
|
||||
// This file is not typed correctly from shadcn, so we're disabling the type checker
|
||||
// @ts-nocheck
|
||||
|
||||
// This file is not typed correctly from shadcn, so we're disabling the type checker
|
||||
// @ts-nocheck
|
||||
|
||||
// This file is not typed correctly from shadcn, so we're disabling the type checker
|
||||
// @ts-nocheck
|
||||
|
||||
const Command = React.forwardRef<
|
||||
React.ElementRef<typeof CommandPrimitive>,
|
||||
React.ComponentPropsWithoutRef<typeof CommandPrimitive> & {
|
||||
|
||||
@@ -132,7 +132,7 @@ export function OAuthRequiredModal({
|
||||
providerId,
|
||||
requiredScopes,
|
||||
})
|
||||
|
||||
|
||||
await client.oauth2.link({
|
||||
providerId,
|
||||
callbackURL: window.location.href,
|
||||
|
||||
@@ -31,7 +31,7 @@ export const auth = betterAuth({
|
||||
accountLinking: {
|
||||
enabled: true,
|
||||
allowDifferentEmails: true,
|
||||
trustedProviders: ["google", "github", "email-password"],
|
||||
trustedProviders: ['google', 'github', 'email-password'],
|
||||
},
|
||||
},
|
||||
socialProviders: {
|
||||
|
||||
@@ -20,10 +20,14 @@ const redactApiKeys = (obj: any): any => {
|
||||
}
|
||||
|
||||
const result: Record<string, any> = {}
|
||||
|
||||
|
||||
for (const [key, value] of Object.entries(obj)) {
|
||||
// Check if the key is 'apiKey' (case insensitive)
|
||||
if (key.toLowerCase() === 'apikey' || key.toLowerCase() === 'api_key' || key.toLowerCase() === 'access_token') {
|
||||
if (
|
||||
key.toLowerCase() === 'apikey' ||
|
||||
key.toLowerCase() === 'api_key' ||
|
||||
key.toLowerCase() === 'access_token'
|
||||
) {
|
||||
result[key] = '***REDACTED***'
|
||||
} else if (typeof value === 'object' && value !== null) {
|
||||
result[key] = redactApiKeys(value)
|
||||
@@ -31,7 +35,7 @@ const redactApiKeys = (obj: any): any => {
|
||||
result[key] = value
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
@@ -46,12 +50,12 @@ export const useConsoleStore = create<ConsoleStore>()(
|
||||
set((state) => {
|
||||
// Create a new entry with redacted API keys
|
||||
const redactedEntry = { ...entry }
|
||||
|
||||
|
||||
// If the entry has output and it's an object, redact API keys
|
||||
if (redactedEntry.output && typeof redactedEntry.output === 'object') {
|
||||
redactedEntry.output = redactApiKeys(redactedEntry.output)
|
||||
}
|
||||
|
||||
|
||||
const newEntry: ConsoleEntry = {
|
||||
...redactedEntry,
|
||||
id: crypto.randomUUID(),
|
||||
|
||||
@@ -75,8 +75,8 @@ export function Credentials({ onOpenChange }: CredentialsProps) {
|
||||
// Find matching connection - now we can do an exact match on providerId
|
||||
const connection = connections.find((conn: any) => {
|
||||
// Exact match on providerId is the most reliable
|
||||
return conn.provider === service.providerId;
|
||||
});
|
||||
return conn.provider === service.providerId
|
||||
})
|
||||
|
||||
// If we found an exact match, use it
|
||||
if (connection) {
|
||||
@@ -92,16 +92,16 @@ export function Credentials({ onOpenChange }: CredentialsProps) {
|
||||
const connectionWithScopes = connections.find((conn: any) => {
|
||||
// Only consider connections from the same base provider
|
||||
if (!conn.baseProvider || !service.providerId.startsWith(conn.baseProvider)) {
|
||||
return false;
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
// Check if all required scopes for this service are included in the connection
|
||||
if (conn.scopes && service.scopes) {
|
||||
return service.scopes.every(scope => conn.scopes.includes(scope));
|
||||
return service.scopes.every((scope) => conn.scopes.includes(scope))
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
return false
|
||||
})
|
||||
|
||||
if (connectionWithScopes) {
|
||||
return {
|
||||
@@ -112,7 +112,7 @@ export function Credentials({ onOpenChange }: CredentialsProps) {
|
||||
}
|
||||
}
|
||||
|
||||
return service;
|
||||
return service
|
||||
})
|
||||
|
||||
setServices(updatedServices)
|
||||
@@ -209,7 +209,7 @@ export function Credentials({ onOpenChange }: CredentialsProps) {
|
||||
saveToStorage<string[]>('pending_oauth_scopes', service.scopes)
|
||||
saveToStorage<string>('pending_oauth_return_url', window.location.href)
|
||||
saveToStorage<string>('pending_oauth_provider_id', service.providerId)
|
||||
|
||||
|
||||
logger.info('Connecting service:', {
|
||||
serviceId: service.id,
|
||||
providerId: service.providerId,
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { NextRequest, NextResponse } from 'next/server'
|
||||
import { getSessionCookie } from "better-auth/cookies"
|
||||
import { getSessionCookie } from 'better-auth/cookies'
|
||||
|
||||
export async function middleware(request: NextRequest) {
|
||||
// Check if the path is exactly /w
|
||||
if (request.nextUrl.pathname === '/w') {
|
||||
// Check if the path is exactly /w
|
||||
if (request.nextUrl.pathname === '/w') {
|
||||
return NextResponse.redirect(new URL('/w/1', request.url))
|
||||
}
|
||||
|
||||
@@ -25,4 +25,4 @@ export const config = {
|
||||
'/w', // Match exactly /w
|
||||
'/w/:path*', // Keep existing matcher for protected routes
|
||||
],
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
"@/db": ["./app/db"],
|
||||
"@/db/*": ["./app/db/*"],
|
||||
"@/executor": ["./app/executor"],
|
||||
"@/executor/*": ["./app/executor/*"],
|
||||
"@/executor/*": ["./app/executor/*"]
|
||||
},
|
||||
"allowJs": true,
|
||||
"noEmit": true,
|
||||
|
||||
Reference in New Issue
Block a user