feat(v2.6.0): implement GlobalEnvelope, T1-T9 hardening, 12 tools, and CI acceptance test suite
This commit is contained in:
Vendored
+34
-12
@@ -1,7 +1,11 @@
|
||||
import { Request, Response, NextFunction } from "express";
|
||||
export type AuthScope = "read" | "write";
|
||||
export interface AuraAuthContext {
|
||||
authenticated: boolean;
|
||||
tenantId: string;
|
||||
scopes: AuthScope[];
|
||||
isByok: boolean;
|
||||
isMasterAuthorized: boolean;
|
||||
isAdmin: boolean;
|
||||
callerToken?: string;
|
||||
}
|
||||
declare global {
|
||||
@@ -11,24 +15,42 @@ declare global {
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Check if the inbound request has merchant custom carrier credentials (BYOK - Bring Your Own Keys)
|
||||
*/
|
||||
export interface AuditEntry {
|
||||
timestamp: string;
|
||||
tenant: string;
|
||||
tool: string;
|
||||
args_hash: string;
|
||||
outcome: "ok" | "denied" | "error";
|
||||
}
|
||||
export declare const auditLogBuffer: AuditEntry[];
|
||||
export declare function hasByokCredentials(req: Request): boolean;
|
||||
export declare function extractBearerToken(req: Request): string | undefined;
|
||||
/**
|
||||
* Extract bearer token or API key from request
|
||||
* Resolve bearer token into tenant context and scopes (read / write).
|
||||
*/
|
||||
export declare function extractAuthToken(req: Request): string | undefined;
|
||||
export declare function resolveAuthContext(req: Request): AuraAuthContext;
|
||||
/**
|
||||
* Optional Auth Evaluator:
|
||||
* Public endpoints, discovery, and BYOK requests are permitted.
|
||||
* If server has AURA_API_KEY set, master-account mutating actions require authentication.
|
||||
* Middleware: Evaluates auth context for all requests
|
||||
*/
|
||||
export declare function optionalAuthMiddleware(req: Request, res: Response, next: NextFunction): void;
|
||||
export declare function optionalAuthMiddleware(req: Request, _res: Response, next: NextFunction): void;
|
||||
/**
|
||||
* Helper to verify whether an action requires master auth and whether it is granted
|
||||
* Strict /mcp Authentication & Per-Key Rate Limit Guard (T1)
|
||||
* Missing or invalid Bearer token -> HTTP 401 + UNAUTHORIZED envelope
|
||||
*/
|
||||
export declare function isActionPermitted(req: Request, toolName: string): {
|
||||
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)
|
||||
*/
|
||||
export declare function isActionPermitted(req: Request, toolName: string, args?: Record<string, any>): {
|
||||
permitted: boolean;
|
||||
reason?: string;
|
||||
};
|
||||
/**
|
||||
* Record privacy-safe audit log: hashes sanitized arguments; NEVER logs raw phone numbers or addresses.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
export declare function verifyWebhookSignature(req: Request, provider: string): boolean;
|
||||
|
||||
Reference in New Issue
Block a user