@@ -5,7 +5,7 @@ import { getConnectors } from "@/lib/composio/connectors";
55import { disconnectConnector } from "@/lib/composio/connectors/disconnectConnector" ;
66import { validateDisconnectConnectorBody } from "@/lib/composio/connectors/validateDisconnectConnectorBody" ;
77import { verifyConnectorOwnership } from "@/lib/composio/connectors/verifyConnectorOwnership" ;
8- import { getApiKeyAccountId } from "@/lib/auth/getApiKeyAccountId " ;
8+ import { validateAccountIdHeaders } from "@/lib/accounts/validateAccountIdHeaders " ;
99
1010/**
1111 * OPTIONS handler for CORS preflight requests.
@@ -22,20 +22,20 @@ export async function OPTIONS() {
2222 *
2323 * List all available connectors and their connection status for a user.
2424 *
25- * Authentication: x-api-key header required.
25+ * Authentication: x-api-key OR Authorization Bearer token required.
2626 *
2727 * @returns List of connectors with connection status
2828 */
2929export async function GET ( request : NextRequest ) : Promise < NextResponse > {
3030 const headers = getCorsHeaders ( ) ;
3131
3232 try {
33- const accountIdOrError = await getApiKeyAccountId ( request ) ;
34- if ( accountIdOrError instanceof NextResponse ) {
35- return accountIdOrError ;
33+ const authResult = await validateAccountIdHeaders ( request ) ;
34+ if ( authResult instanceof NextResponse ) {
35+ return authResult ;
3636 }
3737
38- const accountId = accountIdOrError ;
38+ const { accountId } = authResult ;
3939
4040 const connectors = await getConnectors ( accountId ) ;
4141
@@ -60,20 +60,20 @@ export async function GET(request: NextRequest): Promise<NextResponse> {
6060 *
6161 * Disconnect a connected account from Composio.
6262 *
63- * Authentication: x-api-key header required.
63+ * Authentication: x-api-key OR Authorization Bearer token required.
6464 *
6565 * Body: { connected_account_id: string }
6666 */
6767export async function DELETE ( request : NextRequest ) : Promise < NextResponse > {
6868 const headers = getCorsHeaders ( ) ;
6969
7070 try {
71- const accountIdOrError = await getApiKeyAccountId ( request ) ;
72- if ( accountIdOrError instanceof NextResponse ) {
73- return accountIdOrError ;
71+ const authResult = await validateAccountIdHeaders ( request ) ;
72+ if ( authResult instanceof NextResponse ) {
73+ return authResult ;
7474 }
7575
76- const accountId = accountIdOrError ;
76+ const { accountId } = authResult ;
7777 const body = await request . json ( ) ;
7878
7979 const validated = validateDisconnectConnectorBody ( body ) ;
0 commit comments