feat(connector): add native SSE transport (/sse, /messages), Accept normalizer, query token auth & 20-test CI suite

This commit is contained in:
Amirul Islam Redwan
2026-11-10 18:19:54 +00:00
parent c174a60b82
commit 07d43dfae2
10 changed files with 546 additions and 135 deletions
+14 -6
View File
@@ -12,6 +12,7 @@ declare global {
namespace Express {
interface Request {
auraAuth?: AuraAuthContext;
rawBody?: string | Buffer;
}
}
}
@@ -23,10 +24,16 @@ export interface AuditEntry {
outcome: "ok" | "denied" | "error";
}
export declare const auditLogBuffer: AuditEntry[];
/**
* F10 Fix: Accept BYOK credentials STRICTLY from request headers.
* Query parameters are completely ignored to avoid leaking secrets in proxy/access logs.
*/
export declare function hasByokCredentials(req: Request): boolean;
export declare function extractBearerToken(req: Request): string | undefined;
export declare function registerApiKey(token: string, tenantId: string, scopes?: AuthScope[], isAdmin?: boolean): void;
/**
* Resolve bearer token into tenant context and scopes (read / write).
* F01 Fix: Cryptographic Token Resolution without prefix bypass.
* Prefix matching (aura_rw_*, aura_tenant_*) is strictly abolished.
*/
export declare function resolveAuthContext(req: Request): AuraAuthContext;
/**
@@ -34,12 +41,12 @@ export declare function resolveAuthContext(req: Request): AuraAuthContext;
*/
export declare function optionalAuthMiddleware(req: Request, _res: Response, next: NextFunction): void;
/**
* Strict /mcp Authentication & Per-Key Rate Limit Guard (T1)
* Missing or invalid Bearer token -> HTTP 401 + UNAUTHORIZED envelope
* Strict /mcp Authentication & Per-Key Rate Limit Guard
* F14: Allows unauthenticated read-only discovery on tools/list.
*/
export declare function requireMcpAuth(req: Request, res: Response, next: NextFunction): void;
/**
* Verify scope permission for a specific tool and record a privacy-safe audit log entry (T1)
* Verify scope permission for a specific tool and record a privacy-safe audit log entry
*/
export declare function isActionPermitted(req: Request, toolName: string, args?: Record<string, any>): {
permitted: boolean;
@@ -50,7 +57,8 @@ export declare function isActionPermitted(req: Request, toolName: string, args?:
*/
export declare function recordAuditLog(tenant: string, tool: string, args: Record<string, any> | undefined, outcome: "ok" | "denied" | "error"): void;
/**
* Verify inbound courier webhook authentication / signature (T1)
* Rejects unsigned/invalid webhook calls with HTTP 401/403.
* F09 Fix: Native Carrier Webhook HMAC-SHA256 & Token Verification.
* Pathao uses HMAC-SHA256 with PATHAO_CLIENT_SECRET over raw request body.
* Steadfast uses secret key header comparison.
*/
export declare function verifyWebhookSignature(req: Request, provider: string): boolean;