export interface SessionCredential { tenantId?: string; clientId?: string; scopes?: string[]; } export function resolveCredential(req: any): SessionCredential { const headerTenant = req.header('x-tenant-id'); const headerClientId = req.header('x-client-id'); const headerScopes = req.header('x-graph-scopes'); if (headerTenant || headerClientId || headerScopes) { return { tenantId: headerTenant, clientId: headerClientId, scopes: headerScopes ? headerScopes.split(' ') : undefined, }; } // fallback to ENV return { tenantId: process.env.TENANT_ID, clientId: process.env.CLIENT_ID, scopes: (process.env.GRAPH_SCOPES || '').split(' ').filter(Boolean), }; }