MCPcopy
hub / github.com/simstudioai/sim / assertToolFileAccess

Function assertToolFileAccess

apps/sim/app/api/files/authorization.ts:762–778  ·  view source on GitHub ↗
(
  key: unknown,
  userId: string,
  requestId: string,
  routeLogger: ReturnType<typeof createLogger>
)

Source from the content-addressed store, hash-verified

760 * access is granted.
761 */
762export async function assertToolFileAccess(
763 key: unknown,
764 userId: string,
765 requestId: string,
766 routeLogger: ReturnType<typeof createLogger>
767): Promise<NextResponse | null> {
768 if (typeof key !== 'string' || key.length === 0) {
769 routeLogger.warn(`[${requestId}] File access check rejected: missing key`)
770 return NextResponse.json({ success: false, error: 'File not found' }, { status: 404 })
771 }
772 const hasAccess = await verifyFileAccess(key, userId)
773 if (!hasAccess) {
774 routeLogger.warn(`[${requestId}] File access denied for user`, { userId, key })
775 return NextResponse.json({ success: false, error: 'File not found' }, { status: 404 })
776 }
777 return null
778}
779
780/**
781 * Get chat storage configuration based on current storage provider

Callers 15

route.tsFile · 0.90
route.tsFile · 0.90
route.tsFile · 0.90
route.tsFile · 0.90
route.tsFile · 0.90
route.tsFile · 0.90
route.tsFile · 0.90
route.tsFile · 0.90
route.tsFile · 0.90
route.tsFile · 0.90
route.tsFile · 0.90
route.tsFile · 0.90

Calls 2

verifyFileAccessFunction · 0.85
warnMethod · 0.65

Tested by

no test coverage detected