Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8aa306bf63 | |||
| eeba92042c |
@@ -1,5 +1,16 @@
|
||||
# Changelog
|
||||
|
||||
## [2.7.0] - 2026-11-24
|
||||
|
||||
### Added
|
||||
- **Standard MCP OAuth 2.1 + PKCE (`S256`) Authorization Server (`src/middleware/oauth.ts`)**:
|
||||
- **RFC 9728 Protected Resource Metadata**: `GET /.well-known/oauth-protected-resource` and `/.well-known/oauth-protected-resource/mcp` + `WWW-Authenticate` challenge on all `401 Unauthorized` `/mcp` responses (`POST`, `GET`, `DELETE`) with CORS exposure (`Access-Control-Expose-Headers: mcp-session-id, WWW-Authenticate`).
|
||||
- **RFC 8414 Authorization Server Metadata**: `GET /.well-known/oauth-authorization-server` and `/.well-known/openid-configuration` advertising PKCE `S256`, `authorization_code`, and `refresh_token` grants.
|
||||
- **RFC 7591 Dynamic Client Registration (`POST /oauth/register`)**: Restart-proof HMAC-signed client IDs supporting Google Gemini (`*.googleusercontent.com`), Claude, ChatGPT, Antigravity, Cursor, VS Code, and RFC 8252 loopback redirects while strictly rejecting untrusted redirect hosts.
|
||||
- **Silicon Valley Global Consent & Aura Cloud SSO (`GET/POST /oauth/authorize`)**: Instant 1-click consent for signed-in Aura Cloud accounts (`aura_access` cookie), native **Continue with Google** & Work Email sign-in via `auth.auraajenticai.cloud`, Developer/Merchant API Key tab, 1-click Read-Only Sandbox for evaluators, and crisp inline vector SVG branding.
|
||||
- **Gemini-Safe Non-Rotating Refresh & Dual-Auth (`POST /oauth/token`, `POST /oauth/revoke`, `src/middleware/auth.ts`)**: `application/x-www-form-urlencoded` + JSON token exchange with PKCE `S256`, 180-day non-rotating refresh tokens (preventing Google Gemini unlinking), and full Dual-Auth compatibility preserving static Bearer API Keys, PostgreSQL dynamic keys (`aura_courier_runtime`), and BYOK carrier headers.
|
||||
- **Automated OAuth 2.1 Acceptance Suite (`test/oauth21.test.mjs`)**: Full end-to-end verification of discovery, DCR, SSO cookie consent, Read-Only Sandbox, PKCE `S256`, non-rotating refresh, Dual-Auth, and RFC 7009 revocation alongside all 25 existing tests.
|
||||
|
||||
## [2.6.1] - 2026-11-13
|
||||
|
||||
### Fixed & Changed
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
# 🚚 AURA COURIER MCP v2.6.1 — THE ENTERPRISE LOGISTICS MASTER MANUAL
|
||||
# 🚚 AURA COURIER MCP v2.7.0 — THE ENTERPRISE LOGISTICS MASTER MANUAL
|
||||
### Universal Multi-Carrier Logistics Engine, Spatial Intelligence Hub & Zero-Risk COD Gateway
|
||||
**Published by Aura Agentic AI · Architected with DeepMind Principles & Google Maps Platform**
|
||||
|
||||
[](https://cloud.google.com/find-a-partner/partner/aura-ajentic-ai)
|
||||
[](https://glama.ai/mcp/servers/auraajenticai/aura-courier-mcp)
|
||||
[](plugin.json)
|
||||
[](plugin.json)
|
||||
[](https://courier.auraajenticai.cloud/guide)
|
||||
[](https://opensource.org/licenses/Apache-2.0)
|
||||
[](https://courier.auraajenticai.cloud)
|
||||
@@ -227,7 +227,7 @@ curl -s https://courier.auraajenticai.cloud/health | jq
|
||||
```json
|
||||
{
|
||||
"ok": true,
|
||||
"version": "2.6.1"
|
||||
"version": "2.7.0"
|
||||
}
|
||||
```
|
||||
|
||||
@@ -278,7 +278,7 @@ Add this configuration block to your client settings (`claude_desktop_config.jso
|
||||
"mcpServers": {
|
||||
"aura-courier": {
|
||||
"command": "npx",
|
||||
"args": ["-y", "aura-courier-mcp@2.6.1"],
|
||||
"args": ["-y", "aura-courier-mcp@2.7.0"],
|
||||
"env": {
|
||||
"PORT": "8080",
|
||||
"GOOGLE_MAPS_API_KEY": "<GOOGLE_MAPS_API_KEY>",
|
||||
@@ -340,6 +340,9 @@ Bundles the complete `courier-ops` skill (9 tools), `rules/COURIER_RULES.md` (sm
|
||||
|
||||
## 9. Version History & Glama TDQS 5.0 Audit Log
|
||||
|
||||
* **v2.7.0 (Nov 24, 2026)**:
|
||||
- **Standard MCP OAuth 2.1 + PKCE (`S256`) + RFC 9728 / 8414 / 7591 DCR**: Native remote OAuth connectivity for **Google Gemini**, **Antigravity Marketplace**, **ChatGPT**, and **Claude Web** with 1-click Aura Cloud SSO, Google Sign-In, Developer API Key Dual-Auth, and non-rotating refresh tokens.
|
||||
- **13 Live Logistics & Spatial Tools + Full Glama / Antigravity Plugin Parity**: Synchronized all manifests (`package.json`, `plugin.json`, `server.json`, `validate_plugin.js`) and expanded automated tests (`30+` passing).
|
||||
* **v2.6.1 (Nov 13, 2026)**:
|
||||
- **Single-Source-of-Truth Release Parity (`src/version.ts`)**: Unified version synchronization across `package.json`, `server.json`, `plugin.json`, `/health`, MCP Server metadata, GitHub Releases, Gitea, Glama Registry, and live web UI (`v2.6.1`).
|
||||
- **TypeScript Strict `pnpm` Compatibility & Silicon Valley UI**: Explicit Express typing resolving Glama Dockerfile `TS2742`, inline SVG carrier/tool iconography, RedX monogram badge, and interactive `#hubmap` canvas animation.
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ Connect any AI Agent / IDE to Aura Courier MCP in seconds.
|
||||
- **Server-Sent Events / SSE (Claude Desktop, Remote SSE)**:
|
||||
`https://courier.auraajenticai.cloud/sse`
|
||||
- **NPX Direct CLI**:
|
||||
`npx -y aura-courier-mcp@2.6.1`
|
||||
`npx -y aura-courier-mcp@2.7.0`
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
},
|
||||
"aura-courier-local": {
|
||||
"command": "npx",
|
||||
"args": ["-y", "aura-courier-mcp@2.6.1"],
|
||||
"args": ["-y", "aura-courier-mcp@2.7.0"],
|
||||
"env": {
|
||||
"PORT": "8080"
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
},
|
||||
"aura-courier-stdio": {
|
||||
"command": "npx",
|
||||
"args": ["-y", "aura-courier-mcp@2.6.1"]
|
||||
"args": ["-y", "aura-courier-mcp@2.7.0"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+7
-1
@@ -8,6 +8,7 @@ import { loadConfig } from "./config.js";
|
||||
import { buildMcpServer, executeToolCall, TOOLS } from "./server.js";
|
||||
import { createRateLimiter } from "./middleware/rate_limit.js";
|
||||
import { optionalAuthMiddleware, requireMcpAuth, isActionPermitted, resolveAuthContext, verifyWebhookSignature, recordAuditLog, initDynamicAuthStore, upsertDynamicKeyHash, setTenantDynamicKeyStatus, listDynamicKeySummaries, } from "./middleware/auth.js";
|
||||
import { registerOAuthRoutes, buildWwwAuthenticateHeader } from "./middleware/oauth.js";
|
||||
import { McpToolError, wrapError, wrapSuccess, maskPhone } from "./envelope.js";
|
||||
import { APP_VERSION } from "./version.js";
|
||||
import path from "node:path";
|
||||
@@ -127,12 +128,14 @@ export function keysFromRequest(req) {
|
||||
};
|
||||
}
|
||||
export const app = express();
|
||||
app.set("trust proxy", 1);
|
||||
app.use(express.json({
|
||||
limit: "1mb",
|
||||
verify: (req, _res, buf) => {
|
||||
req.rawBody = buf;
|
||||
},
|
||||
}));
|
||||
app.use(express.urlencoded({ extended: false, limit: "1mb" }));
|
||||
// Robust Malformed JSON Syntax Error Guard
|
||||
app.use((err, _req, res, next) => {
|
||||
if (err && (err.type === "entity.parse.failed" || err.status === 400)) {
|
||||
@@ -149,7 +152,7 @@ app.use((req, res, next) => {
|
||||
res.header("Access-Control-Allow-Origin", "*");
|
||||
res.header("Access-Control-Allow-Methods", "GET, POST, DELETE, OPTIONS, HEAD, PATCH, PUT");
|
||||
res.header("Access-Control-Allow-Headers", "Content-Type, Accept, Authorization, mcp-session-id, mcp-protocol-version, x-aura-signature, x-steadfast-signature, x-pathao-signature, x-redx-signature, x-paperfly-signature, x-webhook-secret, x-steadfast-api-key, x-steadfast-secret-key, x-steadfast-base-url, x-pathao-client-id, x-pathao-client-secret, x-pathao-username, x-pathao-password, x-pathao-store-id, x-pathao-base-url, x-redx-api-token, x-redx-base-url, x-redx-pickup-store-id, x-paperfly-api-key, x-paperfly-username, x-paperfly-password, x-paperfly-store-name, x-google-maps-key");
|
||||
res.header("Access-Control-Expose-Headers", "mcp-session-id");
|
||||
res.header("Access-Control-Expose-Headers", "mcp-session-id, WWW-Authenticate");
|
||||
if (req.method === "OPTIONS") {
|
||||
return res.sendStatus(204);
|
||||
}
|
||||
@@ -164,6 +167,8 @@ app.get("/favicon.ico", (_req, res) => {
|
||||
res.status(204).end();
|
||||
});
|
||||
});
|
||||
// Standard MCP OAuth 2.1 + PKCE (S256) + RFC 9728 + RFC 8414 + RFC 7591 Dynamic Client Registration
|
||||
registerOAuthRoutes(app);
|
||||
app.use(optionalAuthMiddleware);
|
||||
// Dynamic Tenant API Key Sync & Revocation Routes (Called by Snehalata / Admin Master Key)
|
||||
app.get("/admin/tokens", (req, res) => {
|
||||
@@ -347,6 +352,7 @@ app.get("/mcp", mcpLimiter, async (req, res) => {
|
||||
});
|
||||
}
|
||||
if (!req.auraAuth?.authenticated) {
|
||||
res.setHeader("WWW-Authenticate", buildWwwAuthenticateHeader(req, req.auraAuth?.tenantId === "invalid"));
|
||||
return res.status(401).json(wrapError(new McpToolError({
|
||||
code: "UNAUTHORIZED",
|
||||
message: "Missing or invalid Authorization: Bearer <AURA_API_KEY> header.",
|
||||
|
||||
Vendored
+24
-7
@@ -1,5 +1,6 @@
|
||||
import { createHash, createHmac, timingSafeEqual } from "node:crypto";
|
||||
import { maskPhone, wrapError, McpToolError } from "../envelope.js";
|
||||
import { verifyOAuthAccessToken, buildWwwAuthenticateHeader } from "./oauth.js";
|
||||
const READ_TOOLS = new Set([
|
||||
"list_couriers",
|
||||
"track_parcel",
|
||||
@@ -82,6 +83,8 @@ export async function initDynamicAuthStore(pool) {
|
||||
`);
|
||||
}
|
||||
catch (ddlErr) {
|
||||
// Least-privilege runtime DB roles (e.g. aura_courier_runtime) intentionally lack schema CREATE;
|
||||
// the table is pre-provisioned, so continue cleanly to load rows below.
|
||||
if (!/permission denied/i.test(String(ddlErr?.message || ""))) {
|
||||
console.warn("[Auth] Dynamic key table DDL skipped:", ddlErr?.message);
|
||||
}
|
||||
@@ -196,6 +199,20 @@ export function resolveAuthContext(req) {
|
||||
isAdmin: false,
|
||||
};
|
||||
}
|
||||
// 0. Standard MCP OAuth 2.1 JWT Access Token (Google Gemini, ChatGPT, Claude Web)
|
||||
if (token.startsWith("eyJ") && token.split(".").length === 3) {
|
||||
const oauthClaims = verifyOAuthAccessToken(token);
|
||||
if (oauthClaims) {
|
||||
return {
|
||||
authenticated: true,
|
||||
tenantId: oauthClaims.sub,
|
||||
scopes: Array.isArray(oauthClaims.scp) && oauthClaims.scp.length ? oauthClaims.scp : ["read"],
|
||||
isByok,
|
||||
isAdmin: Boolean(oauthClaims.adm),
|
||||
callerToken: token,
|
||||
};
|
||||
}
|
||||
}
|
||||
// 1. Master / Admin Key (Full Read + Write across all tenants)
|
||||
if (safeCompare(token, masterKey) || safeCompare(token, adminKey)) {
|
||||
return {
|
||||
@@ -376,20 +393,19 @@ export function requireMcpAuth(req, res, next) {
|
||||
})));
|
||||
return;
|
||||
}
|
||||
// If a caller explicitly passed an invalid / forged token, always reject with 401
|
||||
// If a caller explicitly passed an invalid / expired / forged token, always reject with 401 + RFC 9728 WWW-Authenticate
|
||||
if (ctx.tenantId === "invalid") {
|
||||
res.setHeader("WWW-Authenticate", buildWwwAuthenticateHeader(req, true));
|
||||
res.status(401).json(wrapError(new McpToolError({
|
||||
code: "UNAUTHORIZED",
|
||||
message: "Invalid or forged Authorization token.",
|
||||
message: "Invalid or expired Authorization token.",
|
||||
retryable: false,
|
||||
source: "validator",
|
||||
})));
|
||||
return;
|
||||
}
|
||||
// Allow unauthenticated discovery handshakes (initialize, notifications/initialized, tools/list, ping)
|
||||
const isDiscovery = method === "initialize" ||
|
||||
method === "notifications/initialized" ||
|
||||
method === "tools/list" ||
|
||||
// Allow stateless public catalog discovery (tools/list, ping) for MCP directories while requiring auth on initialize/tools/call so OAuth 2.1 clients (Gemini, ChatGPT, Claude Web) trigger automatic OAuth discovery via 401 WWW-Authenticate.
|
||||
const isDiscovery = method === "tools/list" ||
|
||||
method === "ping";
|
||||
if (isDiscovery) {
|
||||
return next();
|
||||
@@ -399,9 +415,10 @@ export function requireMcpAuth(req, res, next) {
|
||||
return next();
|
||||
}
|
||||
if (!ctx.authenticated) {
|
||||
res.setHeader("WWW-Authenticate", buildWwwAuthenticateHeader(req, false));
|
||||
res.status(401).json(wrapError(new McpToolError({
|
||||
code: "UNAUTHORIZED",
|
||||
message: "Missing or invalid Authorization: Bearer <key> header on /mcp. Please provide your API key or BYOK carrier keys.",
|
||||
message: "Missing or invalid Authorization: Bearer <key> header on /mcp. Authenticate via MCP OAuth 2.1 or provide your API key / BYOK carrier keys.",
|
||||
retryable: false,
|
||||
source: "validator",
|
||||
})));
|
||||
|
||||
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
import type { Express, Request } from "express";
|
||||
import { type AuthScope } from "./auth.js";
|
||||
export interface OAuthAccessClaims {
|
||||
iss: string;
|
||||
aud: string;
|
||||
sub: string;
|
||||
adm: boolean;
|
||||
scp: AuthScope[];
|
||||
cid: string;
|
||||
typ: "at";
|
||||
iat: number;
|
||||
exp: number;
|
||||
jti: string;
|
||||
}
|
||||
export declare function verifyOAuthAccessToken(token: string): OAuthAccessClaims | null;
|
||||
export declare function getPublicOrigin(req: Request): string;
|
||||
export declare function buildWwwAuthenticateHeader(req: Request, invalidToken?: boolean): string;
|
||||
export declare function isAllowedRedirectUri(uri: string): boolean;
|
||||
export declare function registerOAuthRoutes(app: Express): void;
|
||||
Vendored
+1349
File diff suppressed because it is too large
Load Diff
Vendored
+1
-1
@@ -11,6 +11,6 @@ function readPackageVersion() {
|
||||
catch {
|
||||
// Fallback if package.json is unavailable at runtime
|
||||
}
|
||||
return "2.6.1";
|
||||
return "2.7.0";
|
||||
}
|
||||
export const APP_VERSION = readPackageVersion();
|
||||
|
||||
+2
-2
@@ -1605,7 +1605,7 @@
|
||||
<img class="logo-img" src="/assets/courier-logo.png" onerror="this.onerror=null; this.src='/assets/courier-logo.jpg';" alt="Aura Courier MCP Logo" />
|
||||
<div>
|
||||
<span class="f-brand-title">Aura Courier MCP</span>
|
||||
<span class="version-pill">v2.6.1</span>
|
||||
<span class="version-pill">v2.7.0</span>
|
||||
</div>
|
||||
</div>
|
||||
<p class="footer-tagline">
|
||||
@@ -1657,7 +1657,7 @@
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://www.npmjs.com/package/@auraajenticai/aura-courier-mcp" target="_blank" rel="noopener">
|
||||
<span>📦 npm Package (v2.6.1)</span>
|
||||
<span>📦 npm Package (v2.7.0)</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
+2
-2
@@ -360,7 +360,7 @@
|
||||
</div>
|
||||
<div>
|
||||
<span class="brand-title">Aura Courier MCP</span>
|
||||
<span class="brand-sub">v2.6.1 · Telemetry</span>
|
||||
<span class="brand-sub">v2.7.0 · Telemetry</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="nav-actions">
|
||||
@@ -499,7 +499,7 @@
|
||||
</main>
|
||||
|
||||
<footer>
|
||||
<p>Aura Courier MCP v2.6.1 · Built with pride by <a href="https://auraajenticai.cloud" style="color:var(--text);font-weight:600;">Aura Ajentic AI</a> · Apache 2.0 License</p>
|
||||
<p>Aura Courier MCP v2.7.0 · Built with pride by <a href="https://auraajenticai.cloud" style="color:var(--text);font-weight:600;">Aura Ajentic AI</a> · Apache 2.0 License</p>
|
||||
</footer>
|
||||
|
||||
<script>
|
||||
|
||||
+7
-7
@@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />
|
||||
<title>Aura Courier MCP v2.6.1 — Multi-Courier Integration for Developers</title>
|
||||
<title>Aura Courier MCP v2.7.0 — Multi-Courier Integration for Developers</title>
|
||||
<meta name="description" content="Aura Courier MCP — এক কানেক্টরেই ৪ কুরিয়ার (Steadfast, Pathao, RedX, Paperfly) + Google Maps Spatial AI। Model Context Protocol (MCP) server for AI Agents and E-commerce." />
|
||||
|
||||
<link rel="icon" type="image/jpeg" href="/assets/courier-logo.jpg" />
|
||||
@@ -1201,7 +1201,7 @@
|
||||
<div class="logo-text-wrap">
|
||||
<div class="logo-title">
|
||||
<span>Aura Courier MCP</span>
|
||||
<span class="version-pill">v2.6.1</span>
|
||||
<span class="version-pill">v2.7.0</span>
|
||||
</div>
|
||||
<span class="logo-sub">Multi-Courier Integration for Developers</span>
|
||||
</div>
|
||||
@@ -2046,7 +2046,7 @@
|
||||
<img class="logo-img" src="/assets/courier-logo.png" onerror="this.onerror=null; this.src='/assets/courier-logo.jpg';" alt="Aura Courier MCP Logo" />
|
||||
<div>
|
||||
<span class="f-brand-title">Aura Courier MCP</span>
|
||||
<span class="version-pill">v2.6.1</span>
|
||||
<span class="version-pill">v2.7.0</span>
|
||||
</div>
|
||||
</div>
|
||||
<p class="footer-tagline">
|
||||
@@ -2098,7 +2098,7 @@
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://www.npmjs.com/package/@auraajenticai/aura-courier-mcp" target="_blank" rel="noopener">
|
||||
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"/><polyline points="3.27 6.96 12 12.01 20.73 6.96"/><line x1="12" y1="22.08" x2="12" y2="12"/></svg><span>npm Package (v2.6.1)</span>
|
||||
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"/><polyline points="3.27 6.96 12 12.01 20.73 6.96"/><line x1="12" y1="22.08" x2="12" y2="12"/></svg><span>npm Package (v2.7.0)</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
@@ -2176,7 +2176,7 @@
|
||||
</nav>
|
||||
|
||||
<!-- ===== Background Animation Canvas Script ===== -->
|
||||
<script src="/assets/courier-canvas.js?v=2.6.1"></script>
|
||||
<script src="/assets/courier-canvas.js?v=2.7.0"></script>
|
||||
<script>
|
||||
if (typeof initCourierCanvas === 'function') {
|
||||
initCourierCanvas('hubmap');
|
||||
@@ -3210,7 +3210,7 @@
|
||||
const ms = Math.round(performance.now() - t0);
|
||||
const pill = document.querySelector('.health-pill');
|
||||
if (pill && data.ok) {
|
||||
pill.innerHTML = `<span class="health-dot"></span><span>Health OK (v${data.version || '2.6.1'} · ${ms}ms)</span>`;
|
||||
pill.innerHTML = `<span class="health-dot"></span><span>Health OK (v${data.version || '2.7.0'} · ${ms}ms)</span>`;
|
||||
}
|
||||
const sbStatus = document.querySelector('.sandbox-status');
|
||||
if (sbStatus) {
|
||||
@@ -3220,7 +3220,7 @@
|
||||
.catch(() => {
|
||||
const pill = document.querySelector('.health-pill');
|
||||
if (pill) {
|
||||
pill.innerHTML = `<span class="health-dot" style="background:var(--emerald);"></span><span>Health OK (v2.6.1)</span>`;
|
||||
pill.innerHTML = `<span class="health-dot" style="background:var(--emerald);"></span><span>Health OK (v2.7.0)</span>`;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
+2
-2
@@ -361,7 +361,7 @@
|
||||
"capabilities": {},
|
||||
"clientInfo": {
|
||||
"name": "Aura-Playground",
|
||||
"version": "2.6.1"
|
||||
"version": "2.7.0"
|
||||
}
|
||||
}
|
||||
}</textarea>
|
||||
@@ -452,7 +452,7 @@
|
||||
</main>
|
||||
|
||||
<footer>
|
||||
<p>Aura Courier MCP v2.6.1 · Built with pride by <a href="https://auraajenticai.cloud" style="color:var(--text);font-weight:600;">Aura Ajentic AI</a> · Apache 2.0 License</p>
|
||||
<p>Aura Courier MCP v2.7.0 · Built with pride by <a href="https://auraajenticai.cloud" style="color:var(--text);font-weight:600;">Aura Ajentic AI</a> · Apache 2.0 License</p>
|
||||
</footer>
|
||||
|
||||
<script>
|
||||
|
||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "aura-courier-mcp",
|
||||
"version": "2.6.1",
|
||||
"version": "2.7.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "aura-courier-mcp",
|
||||
"version": "2.6.1",
|
||||
"version": "2.7.0",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@modelcontextprotocol/sdk": "^1.12.0",
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "aura-courier-mcp",
|
||||
"version": "2.6.1",
|
||||
"version": "2.7.0",
|
||||
"description": "Universal Bangladesh courier MCP server for Steadfast, Pathao, RedX, and Paperfly with zero-mock fraud risk, Google Maps routing, enterprise privacy, and token-bucket rate limiting.",
|
||||
"main": "dist/index.js",
|
||||
"type": "module",
|
||||
@@ -16,7 +16,7 @@
|
||||
},
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"test": "node --test test/v260.test.mjs",
|
||||
"test": "node --test test/v260.test.mjs test/oauth21.test.mjs",
|
||||
"prepublishOnly": "npm run test && npm run build",
|
||||
"start": "node dist/index.js",
|
||||
"start:http": "node dist/http.js",
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "aura-courier",
|
||||
"displayName": "Aura Courier MCP",
|
||||
"version": "2.6.1",
|
||||
"version": "2.7.0",
|
||||
"category": "Business / Logistics",
|
||||
"description": "Enterprise Bangladesh Courier & Logistics Automation Hub. Real-time multi-carrier parcel dispatch, nationwide COD balance tracking, zero-mock fraud risk defense, sublocality geocoding, and automated NDR dispute triage across Steadfast, Pathao, RedX, and Paperfly.",
|
||||
"logo": "assets/logo.svg",
|
||||
@@ -44,7 +44,7 @@
|
||||
"aura-courier": {
|
||||
"url": "https://courier.auraajenticai.cloud/mcp",
|
||||
"transport": "streamable-http",
|
||||
"description": "Universal Bangladesh Courier MCP Hub providing 9 live logistics tools"
|
||||
"description": "Universal Bangladesh Courier MCP Hub providing 13 live logistics & spatial intelligence tools with OAuth 2.1 + PKCE"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -254,7 +254,7 @@
|
||||
</main>
|
||||
|
||||
<footer>
|
||||
<p>Aura Courier MCP v2.6.1 · Developed by <b>Aura Agentic AI</b> · Released under <b>Apache License 2.0</b></p>
|
||||
<p>Aura Courier MCP v2.7.0 · Developed by <b>Aura Agentic AI</b> · Released under <b>Apache License 2.0</b></p>
|
||||
<p>
|
||||
<a href="https://auraajenticai.cloud" target="_blank" rel="noopener">auraajenticai.cloud</a> ·
|
||||
<a href="https://github.com/auraajenticai/aura-courier-mcp" target="_blank" rel="noopener">github.com/auraajenticai</a> ·
|
||||
|
||||
+2
-2
@@ -3,7 +3,7 @@
|
||||
"name": "io.github.auraajenticai/aura-courier-mcp",
|
||||
"title": "Aura Courier MCP",
|
||||
"description": "Bangladesh courier connector: Steadfast, Pathao, RedX, Paperfly normalized delivery and tracking.",
|
||||
"version": "2.6.1",
|
||||
"version": "2.7.0",
|
||||
"websiteUrl": "https://github.com/auraajenticai/aura-courier-mcp",
|
||||
"repository": {
|
||||
"url": "https://github.com/auraajenticai/aura-courier-mcp",
|
||||
@@ -13,7 +13,7 @@
|
||||
{
|
||||
"registryType": "npm",
|
||||
"identifier": "aura-courier-mcp",
|
||||
"version": "2.6.1",
|
||||
"version": "2.7.0",
|
||||
"transport": {
|
||||
"type": "stdio"
|
||||
},
|
||||
|
||||
+2
-2
@@ -1576,7 +1576,7 @@
|
||||
<img class="logo-img" src="/assets/courier-logo.png" onerror="this.onerror=null; this.src='/assets/courier-logo.jpg';" alt="Aura Courier MCP Logo" />
|
||||
<div>
|
||||
<span class="f-brand-title">Aura Courier MCP</span>
|
||||
<span class="version-pill">v2.6.1</span>
|
||||
<span class="version-pill">v2.7.0</span>
|
||||
</div>
|
||||
</div>
|
||||
<p class="footer-tagline">
|
||||
@@ -1628,7 +1628,7 @@
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://www.npmjs.com/package/@auraajenticai/aura-courier-mcp" target="_blank" rel="noopener">
|
||||
<span>📦 npm Package (v2.6.1)</span>
|
||||
<span>📦 npm Package (v2.7.0)</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
+8
-1
@@ -19,6 +19,7 @@ import {
|
||||
setTenantDynamicKeyStatus,
|
||||
listDynamicKeySummaries,
|
||||
} from "./middleware/auth.js";
|
||||
import { registerOAuthRoutes, buildWwwAuthenticateHeader } from "./middleware/oauth.js";
|
||||
import { McpToolError, wrapError, wrapSuccess, maskPhone } from "./envelope.js";
|
||||
import { SupportedCourier } from "./types.js";
|
||||
import { APP_VERSION } from "./version.js";
|
||||
@@ -149,12 +150,14 @@ export function keysFromRequest(req: Request): EnvSource {
|
||||
}
|
||||
|
||||
export const app: Express = express();
|
||||
app.set("trust proxy", 1);
|
||||
app.use(express.json({
|
||||
limit: "1mb",
|
||||
verify: (req: any, _res, buf) => {
|
||||
req.rawBody = buf;
|
||||
},
|
||||
}));
|
||||
app.use(express.urlencoded({ extended: false, limit: "1mb" }));
|
||||
|
||||
// Robust Malformed JSON Syntax Error Guard
|
||||
app.use((err: any, _req: Request, res: Response, next: any) => {
|
||||
@@ -184,7 +187,7 @@ app.use((req, res, next) => {
|
||||
"Access-Control-Allow-Headers",
|
||||
"Content-Type, Accept, Authorization, mcp-session-id, mcp-protocol-version, x-aura-signature, x-steadfast-signature, x-pathao-signature, x-redx-signature, x-paperfly-signature, x-webhook-secret, x-steadfast-api-key, x-steadfast-secret-key, x-steadfast-base-url, x-pathao-client-id, x-pathao-client-secret, x-pathao-username, x-pathao-password, x-pathao-store-id, x-pathao-base-url, x-redx-api-token, x-redx-base-url, x-redx-pickup-store-id, x-paperfly-api-key, x-paperfly-username, x-paperfly-password, x-paperfly-store-name, x-google-maps-key"
|
||||
);
|
||||
res.header("Access-Control-Expose-Headers", "mcp-session-id");
|
||||
res.header("Access-Control-Expose-Headers", "mcp-session-id, WWW-Authenticate");
|
||||
if (req.method === "OPTIONS") {
|
||||
return res.sendStatus(204);
|
||||
}
|
||||
@@ -200,6 +203,9 @@ app.get("/favicon.ico", (_req, res) => {
|
||||
});
|
||||
});
|
||||
|
||||
// Standard MCP OAuth 2.1 + PKCE (S256) + RFC 9728 + RFC 8414 + RFC 7591 Dynamic Client Registration
|
||||
registerOAuthRoutes(app);
|
||||
|
||||
app.use(optionalAuthMiddleware);
|
||||
|
||||
|
||||
@@ -420,6 +426,7 @@ app.get("/mcp", mcpLimiter, async (req: Request, res: Response) => {
|
||||
});
|
||||
}
|
||||
if (!req.auraAuth?.authenticated) {
|
||||
res.setHeader("WWW-Authenticate", buildWwwAuthenticateHeader(req, req.auraAuth?.tenantId === "invalid"));
|
||||
return res.status(401).json(
|
||||
wrapError(
|
||||
new McpToolError({
|
||||
|
||||
+22
-6
@@ -1,6 +1,7 @@
|
||||
import { Request, Response, NextFunction } from "express";
|
||||
import { createHash, createHmac, timingSafeEqual } from "node:crypto";
|
||||
import { maskPhone, wrapError, McpToolError } from "../envelope.js";
|
||||
import { verifyOAuthAccessToken, buildWwwAuthenticateHeader } from "./oauth.js";
|
||||
|
||||
export type AuthScope = "read" | "write";
|
||||
|
||||
@@ -269,6 +270,21 @@ export function resolveAuthContext(req: Request): AuraAuthContext {
|
||||
};
|
||||
}
|
||||
|
||||
// 0. Standard MCP OAuth 2.1 JWT Access Token (Google Gemini, ChatGPT, Claude Web)
|
||||
if (token.startsWith("eyJ") && token.split(".").length === 3) {
|
||||
const oauthClaims = verifyOAuthAccessToken(token);
|
||||
if (oauthClaims) {
|
||||
return {
|
||||
authenticated: true,
|
||||
tenantId: oauthClaims.sub,
|
||||
scopes: Array.isArray(oauthClaims.scp) && oauthClaims.scp.length ? oauthClaims.scp : ["read"],
|
||||
isByok,
|
||||
isAdmin: Boolean(oauthClaims.adm),
|
||||
callerToken: token,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// 1. Master / Admin Key (Full Read + Write across all tenants)
|
||||
if (safeCompare(token, masterKey) || safeCompare(token, adminKey)) {
|
||||
return {
|
||||
@@ -468,13 +484,14 @@ export function requireMcpAuth(req: Request, res: Response, next: NextFunction):
|
||||
return;
|
||||
}
|
||||
|
||||
// If a caller explicitly passed an invalid / forged token, always reject with 401
|
||||
// If a caller explicitly passed an invalid / expired / forged token, always reject with 401 + RFC 9728 WWW-Authenticate
|
||||
if (ctx.tenantId === "invalid") {
|
||||
res.setHeader("WWW-Authenticate", buildWwwAuthenticateHeader(req, true));
|
||||
res.status(401).json(
|
||||
wrapError(
|
||||
new McpToolError({
|
||||
code: "UNAUTHORIZED",
|
||||
message: "Invalid or forged Authorization token.",
|
||||
message: "Invalid or expired Authorization token.",
|
||||
retryable: false,
|
||||
source: "validator",
|
||||
})
|
||||
@@ -483,10 +500,8 @@ export function requireMcpAuth(req: Request, res: Response, next: NextFunction):
|
||||
return;
|
||||
}
|
||||
|
||||
// Allow unauthenticated discovery handshakes (initialize, notifications/initialized, tools/list, ping)
|
||||
// Allow stateless public catalog discovery (tools/list, ping) for MCP directories while requiring auth on initialize/tools/call so OAuth 2.1 clients (Gemini, ChatGPT, Claude Web) trigger automatic OAuth discovery via 401 WWW-Authenticate.
|
||||
const isDiscovery =
|
||||
method === "initialize" ||
|
||||
method === "notifications/initialized" ||
|
||||
method === "tools/list" ||
|
||||
method === "ping";
|
||||
|
||||
@@ -500,11 +515,12 @@ export function requireMcpAuth(req: Request, res: Response, next: NextFunction):
|
||||
}
|
||||
|
||||
if (!ctx.authenticated) {
|
||||
res.setHeader("WWW-Authenticate", buildWwwAuthenticateHeader(req, false));
|
||||
res.status(401).json(
|
||||
wrapError(
|
||||
new McpToolError({
|
||||
code: "UNAUTHORIZED",
|
||||
message: "Missing or invalid Authorization: Bearer <key> header on /mcp. Please provide your API key or BYOK carrier keys.",
|
||||
message: "Missing or invalid Authorization: Bearer <key> header on /mcp. Authenticate via MCP OAuth 2.1 or provide your API key / BYOK carrier keys.",
|
||||
retryable: false,
|
||||
source: "validator",
|
||||
})
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -11,7 +11,7 @@ function readPackageVersion(): string {
|
||||
} catch {
|
||||
// Fallback if package.json is unavailable at runtime
|
||||
}
|
||||
return "2.6.1";
|
||||
return "2.7.0";
|
||||
}
|
||||
|
||||
export const APP_VERSION: string = readPackageVersion();
|
||||
|
||||
@@ -0,0 +1,513 @@
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import http from "node:http";
|
||||
import { createHash, createHmac, randomBytes } from "node:crypto";
|
||||
|
||||
process.env.NODE_ENV = "test";
|
||||
process.env.AURA_API_KEY = "aura_test_master_key_oauth21";
|
||||
process.env.AURA_READONLY_KEY = "aura_ro_test_reader_oauth21";
|
||||
process.env.AURA_SSO_JWT_SECRET = "aura_test_sso_jwt_secret_2026";
|
||||
process.env.STEADFAST_API_KEY = "sf_test_key";
|
||||
process.env.STEADFAST_SECRET_KEY = "sf_test_secret";
|
||||
|
||||
const { app } = await import("../dist/http.js");
|
||||
const { SteadfastAdapter } = await import("../dist/adapters/steadfast.js");
|
||||
|
||||
SteadfastAdapter.prototype.getBalance = async function () {
|
||||
return {
|
||||
courier: "steadfast",
|
||||
status: "OK",
|
||||
amount_bdt: 14250,
|
||||
raw_response: { status: 200, current_balance: 14250 },
|
||||
};
|
||||
};
|
||||
|
||||
let server;
|
||||
let baseUrl;
|
||||
|
||||
function makePkcePair() {
|
||||
const verifier = randomBytes(32).toString("base64url");
|
||||
const challenge = createHash("sha256").update(verifier).digest("base64url");
|
||||
return { verifier, challenge };
|
||||
}
|
||||
|
||||
function makeAuraSsoCookie(payload) {
|
||||
const header = Buffer.from(JSON.stringify({ alg: "HS256", typ: "JWT" })).toString("base64url");
|
||||
const body = Buffer.from(
|
||||
JSON.stringify({
|
||||
...payload,
|
||||
iat: Math.floor(Date.now() / 1000),
|
||||
exp: Math.floor(Date.now() / 1000) + 900,
|
||||
})
|
||||
).toString("base64url");
|
||||
const sig = createHmac("sha256", Buffer.from(process.env.AURA_SSO_JWT_SECRET, "utf8"))
|
||||
.update(`${header}.${body}`)
|
||||
.digest("base64url");
|
||||
return `aura_access=${header}.${body}.${sig}`;
|
||||
}
|
||||
|
||||
function extractHiddenInput(html, name) {
|
||||
const re = new RegExp(`name="${name}"\\s+value="([^"]*)"`, "i");
|
||||
const m = html.match(re);
|
||||
return m ? m[1] : "";
|
||||
}
|
||||
|
||||
test.before(async () => {
|
||||
server = http.createServer(app);
|
||||
await new Promise((resolve) => server.listen(0, "127.0.0.1", resolve));
|
||||
const addr = server.address();
|
||||
baseUrl = `http://127.0.0.1:${addr.port}`;
|
||||
});
|
||||
|
||||
test.after(async () => {
|
||||
if (server) {
|
||||
await new Promise((resolve) => server.close(resolve));
|
||||
}
|
||||
});
|
||||
|
||||
test("OAuth 1: 401 on unauthenticated POST /mcp (initialize) and GET /mcp includes RFC 9728 WWW-Authenticate header", async () => {
|
||||
const initRes = await fetch(`${baseUrl}/mcp`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({
|
||||
jsonrpc: "2.0",
|
||||
id: 1,
|
||||
method: "initialize",
|
||||
params: { protocolVersion: "2025-03-26", capabilities: {}, clientInfo: { name: "Google Gemini", version: "1.0" } },
|
||||
}),
|
||||
});
|
||||
assert.equal(initRes.status, 401);
|
||||
const wwwAuthInit = initRes.headers.get("www-authenticate") || "";
|
||||
assert.ok(wwwAuthInit.includes("Bearer"));
|
||||
assert.ok(wwwAuthInit.includes(`resource_metadata="${baseUrl}/.well-known/oauth-protected-resource"`));
|
||||
assert.ok((initRes.headers.get("access-control-expose-headers") || "").includes("WWW-Authenticate"));
|
||||
|
||||
const getRes = await fetch(`${baseUrl}/mcp`, {
|
||||
method: "GET",
|
||||
headers: { Accept: "text/event-stream" },
|
||||
});
|
||||
assert.equal(getRes.status, 401);
|
||||
assert.ok((getRes.headers.get("www-authenticate") || "").includes(`resource_metadata="${baseUrl}/.well-known/oauth-protected-resource"`));
|
||||
});
|
||||
|
||||
test("OAuth 2: RFC 9728 Protected Resource Metadata & RFC 8414 Authorization Server Metadata endpoints return valid JSON", async () => {
|
||||
for (const p of ["/.well-known/oauth-protected-resource", "/.well-known/oauth-protected-resource/mcp"]) {
|
||||
const res = await fetch(`${baseUrl}${p}`);
|
||||
assert.equal(res.status, 200);
|
||||
const data = await res.json();
|
||||
assert.equal(data.resource, `${baseUrl}/mcp`);
|
||||
assert.deepEqual(data.authorization_servers, [baseUrl]);
|
||||
assert.ok(data.bearer_methods_supported.includes("header"));
|
||||
}
|
||||
|
||||
for (const p of ["/.well-known/oauth-authorization-server", "/.well-known/openid-configuration"]) {
|
||||
const res = await fetch(`${baseUrl}${p}`);
|
||||
assert.equal(res.status, 200);
|
||||
const data = await res.json();
|
||||
assert.equal(data.issuer, baseUrl);
|
||||
assert.equal(data.authorization_endpoint, `${baseUrl}/oauth/authorize`);
|
||||
assert.equal(data.token_endpoint, `${baseUrl}/oauth/token`);
|
||||
assert.equal(data.registration_endpoint, `${baseUrl}/oauth/register`);
|
||||
assert.ok(data.code_challenge_methods_supported.includes("S256"));
|
||||
assert.ok(data.grant_types_supported.includes("authorization_code"));
|
||||
assert.ok(data.grant_types_supported.includes("refresh_token"));
|
||||
}
|
||||
});
|
||||
|
||||
test("OAuth 3: RFC 7591 Dynamic Client Registration allows Google googleusercontent.com redirect URIs & blocks untrusted hosts", async () => {
|
||||
const goodRes = await fetch(`${baseUrl}/oauth/register`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({
|
||||
client_name: "Google Gemini",
|
||||
redirect_uris: ["https://oauth-redirect.googleusercontent.com/r/gemini-aura-test"],
|
||||
token_endpoint_auth_method: "none",
|
||||
}),
|
||||
});
|
||||
assert.equal(goodRes.status, 201);
|
||||
const client = await goodRes.json();
|
||||
assert.ok(client.client_id.startsWith("aura_dcr_"));
|
||||
assert.deepEqual(client.redirect_uris, ["https://oauth-redirect.googleusercontent.com/r/gemini-aura-test"]);
|
||||
|
||||
const badRes = await fetch(`${baseUrl}/oauth/register`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({
|
||||
client_name: "Untrusted Phish",
|
||||
redirect_uris: ["https://evil.example.com/steal-code"],
|
||||
}),
|
||||
});
|
||||
assert.equal(badRes.status, 400);
|
||||
const badBody = await badRes.json();
|
||||
assert.equal(badBody.error, "invalid_redirect_uri");
|
||||
});
|
||||
|
||||
test("OAuth 4: Consent UI is global Silicon Valley grade (inline SVG logo, Google SSO, zero internal Snehalata/test-key leaks)", async () => {
|
||||
const redirectUri = "https://oauth-redirect.googleusercontent.com/r/gemini-ui-audit";
|
||||
const { challenge } = makePkcePair();
|
||||
const authUrl = new URL(`${baseUrl}/oauth/authorize`);
|
||||
authUrl.searchParams.set("response_type", "code");
|
||||
authUrl.searchParams.set("client_id", "google-gemini");
|
||||
authUrl.searchParams.set("redirect_uri", redirectUri);
|
||||
authUrl.searchParams.set("scope", "read write");
|
||||
authUrl.searchParams.set("state", "st_ui");
|
||||
authUrl.searchParams.set("code_challenge", challenge);
|
||||
authUrl.searchParams.set("code_challenge_method", "S256");
|
||||
|
||||
const res = await fetch(authUrl.toString());
|
||||
assert.equal(res.status, 200);
|
||||
const html = await res.text();
|
||||
// Inline SVG logo (no external img tag that can break)
|
||||
assert.ok(html.includes("<svg") && html.includes('aria-label="Aura Courier MCP"'));
|
||||
assert.ok(!html.includes("/assets/courier-logo.jpg"));
|
||||
// Global SSO + Google Sign-In present
|
||||
assert.ok(html.includes("Continue with Google"));
|
||||
assert.ok(html.includes("https://auth.auraajenticai.cloud/login/google"));
|
||||
assert.ok(html.includes("Continue in Read-Only Sandbox"));
|
||||
// Zero internal brand or raw test-key leaks
|
||||
assert.ok(!/snehalata/i.test(html));
|
||||
assert.ok(!html.includes("snl_mcp_"));
|
||||
assert.ok(!html.includes("aura_ro_public_inspector_2026"));
|
||||
assert.ok(!html.includes("Master Key"));
|
||||
});
|
||||
|
||||
test("OAuth 5: 1-Click Aura SSO cookie (aura_access) authorizes owner with full master access & zero key typing", async () => {
|
||||
const redirectUri = "https://oauth-redirect.googleusercontent.com/r/gemini-sso-owner";
|
||||
const { verifier, challenge } = makePkcePair();
|
||||
const ssoCookie = makeAuraSsoCookie({
|
||||
sub: "11111111-2222-3333-4444-555555555555",
|
||||
email: "ceo@auraajenticai.cloud",
|
||||
role: "owner",
|
||||
});
|
||||
|
||||
const authUrl = new URL(`${baseUrl}/oauth/authorize`);
|
||||
authUrl.searchParams.set("response_type", "code");
|
||||
authUrl.searchParams.set("client_id", "google-gemini");
|
||||
authUrl.searchParams.set("redirect_uri", redirectUri);
|
||||
authUrl.searchParams.set("scope", "read write");
|
||||
authUrl.searchParams.set("state", "st_sso");
|
||||
authUrl.searchParams.set("code_challenge", challenge);
|
||||
authUrl.searchParams.set("code_challenge_method", "S256");
|
||||
|
||||
const consentRes = await fetch(authUrl.toString(), { headers: { Cookie: ssoCookie } });
|
||||
assert.equal(consentRes.status, 200);
|
||||
const consentHtml = await consentRes.text();
|
||||
assert.ok(consentHtml.includes("ceo@auraajenticai.cloud"));
|
||||
assert.ok(consentHtml.includes("Allow Access"));
|
||||
const csrfToken = extractHiddenInput(consentHtml, "csrf_token");
|
||||
|
||||
const approveRes = await fetch(`${baseUrl}/oauth/authorize`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
Cookie: ssoCookie,
|
||||
},
|
||||
body: new URLSearchParams({
|
||||
client_id: "google-gemini",
|
||||
redirect_uri: redirectUri,
|
||||
state: "st_sso",
|
||||
scope: "read write",
|
||||
code_challenge: challenge,
|
||||
code_challenge_method: "S256",
|
||||
csrf_token: csrfToken,
|
||||
auth_mode: "sso",
|
||||
decision: "approve",
|
||||
}).toString(),
|
||||
redirect: "manual",
|
||||
});
|
||||
assert.equal(approveRes.status, 302);
|
||||
const code = new URL(approveRes.headers.get("location")).searchParams.get("code");
|
||||
|
||||
const tokRes = await fetch(`${baseUrl}/oauth/token`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
||||
body: new URLSearchParams({
|
||||
grant_type: "authorization_code",
|
||||
code,
|
||||
client_id: "google-gemini",
|
||||
redirect_uri: redirectUri,
|
||||
code_verifier: verifier,
|
||||
}).toString(),
|
||||
});
|
||||
assert.equal(tokRes.status, 200);
|
||||
const tokens = await tokRes.json();
|
||||
assert.equal(tokens.scope, "read write");
|
||||
|
||||
const mcpCall = await fetch(`${baseUrl}/mcp`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Authorization: `Bearer ${tokens.access_token}`,
|
||||
},
|
||||
body: JSON.stringify({
|
||||
jsonrpc: "2.0",
|
||||
id: 50,
|
||||
method: "tools/call",
|
||||
params: { name: "get_balance", arguments: { courier: "steadfast" } },
|
||||
}),
|
||||
});
|
||||
assert.equal(mcpCall.status, 200);
|
||||
const body = await mcpCall.json();
|
||||
assert.equal(body.result.isError, false);
|
||||
assert.equal(JSON.parse(body.result.content[0].text).data.amount_bdt, 14250);
|
||||
});
|
||||
|
||||
test("OAuth 6: End-to-End API Key PKCE S256 flow -> Non-Rotating Refresh -> Static Dual-Auth -> Revocation", async () => {
|
||||
const redirectUri = "https://oauth-redirect.googleusercontent.com/r/gemini-live-flow";
|
||||
const regRes = await fetch(`${baseUrl}/oauth/register`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({
|
||||
client_name: "Google Gemini",
|
||||
redirect_uris: [redirectUri],
|
||||
token_endpoint_auth_method: "none",
|
||||
}),
|
||||
});
|
||||
assert.equal(regRes.status, 201);
|
||||
const { client_id: clientId } = await regRes.json();
|
||||
|
||||
const { verifier, challenge } = makePkcePair();
|
||||
const state = "gemini_state_xyz_991";
|
||||
|
||||
const authUrl = new URL(`${baseUrl}/oauth/authorize`);
|
||||
authUrl.searchParams.set("response_type", "code");
|
||||
authUrl.searchParams.set("client_id", clientId);
|
||||
authUrl.searchParams.set("redirect_uri", redirectUri);
|
||||
authUrl.searchParams.set("scope", "read write");
|
||||
authUrl.searchParams.set("state", state);
|
||||
authUrl.searchParams.set("code_challenge", challenge);
|
||||
authUrl.searchParams.set("code_challenge_method", "S256");
|
||||
|
||||
const consentHtml = await (await fetch(authUrl.toString())).text();
|
||||
const csrfToken = extractHiddenInput(consentHtml, "csrf_token");
|
||||
|
||||
// Deny -> error=access_denied
|
||||
const denyRes = await fetch(`${baseUrl}/oauth/authorize`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
||||
body: new URLSearchParams({
|
||||
client_id: clientId,
|
||||
redirect_uri: redirectUri,
|
||||
state,
|
||||
scope: "read write",
|
||||
code_challenge: challenge,
|
||||
code_challenge_method: "S256",
|
||||
csrf_token: csrfToken,
|
||||
auth_mode: "apikey",
|
||||
decision: "deny",
|
||||
}).toString(),
|
||||
redirect: "manual",
|
||||
});
|
||||
assert.equal(denyRes.status, 302);
|
||||
assert.equal(new URL(denyRes.headers.get("location")).searchParams.get("error"), "access_denied");
|
||||
|
||||
// Invalid API key stays on form with clean error
|
||||
const badKeyRes = await fetch(`${baseUrl}/oauth/authorize`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
||||
body: new URLSearchParams({
|
||||
client_id: clientId,
|
||||
redirect_uri: redirectUri,
|
||||
state,
|
||||
scope: "read write",
|
||||
code_challenge: challenge,
|
||||
code_challenge_method: "S256",
|
||||
csrf_token: csrfToken,
|
||||
auth_mode: "apikey",
|
||||
decision: "approve",
|
||||
api_key: "totally_wrong_key_123",
|
||||
}).toString(),
|
||||
redirect: "manual",
|
||||
});
|
||||
assert.equal(badKeyRes.status, 200);
|
||||
assert.ok((await badKeyRes.text()).includes("Invalid API key"));
|
||||
|
||||
// Valid API key -> 302 with code
|
||||
const approveRes = await fetch(`${baseUrl}/oauth/authorize`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
||||
body: new URLSearchParams({
|
||||
client_id: clientId,
|
||||
redirect_uri: redirectUri,
|
||||
state,
|
||||
scope: "read write",
|
||||
code_challenge: challenge,
|
||||
code_challenge_method: "S256",
|
||||
csrf_token: csrfToken,
|
||||
auth_mode: "apikey",
|
||||
decision: "approve",
|
||||
api_key: process.env.AURA_API_KEY,
|
||||
}).toString(),
|
||||
redirect: "manual",
|
||||
});
|
||||
assert.equal(approveRes.status, 302);
|
||||
const authCode = new URL(approveRes.headers.get("location")).searchParams.get("code");
|
||||
|
||||
// Wrong PKCE rejected
|
||||
const wrongPkce = await fetch(`${baseUrl}/oauth/token`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
||||
body: new URLSearchParams({
|
||||
grant_type: "authorization_code",
|
||||
code: authCode,
|
||||
client_id: clientId,
|
||||
redirect_uri: redirectUri,
|
||||
code_verifier: "wrong_verifier_abcdefghijklmnopqrstuvwxyz_0123456789",
|
||||
}).toString(),
|
||||
});
|
||||
assert.equal(wrongPkce.status, 400);
|
||||
|
||||
// Correct PKCE -> tokens
|
||||
const tokRes = await fetch(`${baseUrl}/oauth/token`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
||||
body: new URLSearchParams({
|
||||
grant_type: "authorization_code",
|
||||
code: authCode,
|
||||
client_id: clientId,
|
||||
redirect_uri: redirectUri,
|
||||
code_verifier: verifier,
|
||||
}).toString(),
|
||||
});
|
||||
assert.equal(tokRes.status, 200);
|
||||
const tokens = await tokRes.json();
|
||||
assert.equal(tokens.token_type, "Bearer");
|
||||
|
||||
// Replay rejected
|
||||
const replayRes = await fetch(`${baseUrl}/oauth/token`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
||||
body: new URLSearchParams({
|
||||
grant_type: "authorization_code",
|
||||
code: authCode,
|
||||
client_id: clientId,
|
||||
redirect_uri: redirectUri,
|
||||
code_verifier: verifier,
|
||||
}).toString(),
|
||||
});
|
||||
assert.equal(replayRes.status, 400);
|
||||
|
||||
// Non-rotating refresh token
|
||||
const refRes = await fetch(`${baseUrl}/oauth/token`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
||||
body: new URLSearchParams({
|
||||
grant_type: "refresh_token",
|
||||
refresh_token: tokens.refresh_token,
|
||||
client_id: clientId,
|
||||
}).toString(),
|
||||
});
|
||||
assert.equal(refRes.status, 200);
|
||||
const refreshed = await refRes.json();
|
||||
assert.equal(refreshed.refresh_token, tokens.refresh_token);
|
||||
assert.notEqual(refreshed.access_token, tokens.access_token);
|
||||
|
||||
// Static Dual-Auth still works
|
||||
const staticRes = await fetch(`${baseUrl}/mcp`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Authorization: `Bearer ${process.env.AURA_API_KEY}`,
|
||||
},
|
||||
body: JSON.stringify({
|
||||
jsonrpc: "2.0",
|
||||
id: 12,
|
||||
method: "tools/call",
|
||||
params: { name: "get_balance", arguments: { courier: "steadfast" } },
|
||||
}),
|
||||
});
|
||||
assert.equal(staticRes.status, 200);
|
||||
|
||||
// Revocation
|
||||
const revRes = await fetch(`${baseUrl}/oauth/revoke`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
||||
body: new URLSearchParams({ token: tokens.access_token }).toString(),
|
||||
});
|
||||
assert.equal(revRes.status, 200);
|
||||
|
||||
const afterRev = await fetch(`${baseUrl}/mcp`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Authorization: `Bearer ${tokens.access_token}`,
|
||||
},
|
||||
body: JSON.stringify({
|
||||
jsonrpc: "2.0",
|
||||
id: 13,
|
||||
method: "tools/call",
|
||||
params: { name: "get_balance", arguments: { courier: "steadfast" } },
|
||||
}),
|
||||
});
|
||||
assert.equal(afterRev.status, 401);
|
||||
assert.ok((afterRev.headers.get("www-authenticate") || "").includes('error="invalid_token"'));
|
||||
});
|
||||
|
||||
test("OAuth 7: 1-Click Read-Only Sandbox strictly limits scope to read without exposing any raw API key", async () => {
|
||||
const redirectUri = "https://oauth-redirect.googleusercontent.com/r/gemini-sandbox";
|
||||
const { verifier, challenge } = makePkcePair();
|
||||
|
||||
const authUrl = new URL(`${baseUrl}/oauth/authorize`);
|
||||
authUrl.searchParams.set("response_type", "code");
|
||||
authUrl.searchParams.set("client_id", "gemini-sandbox");
|
||||
authUrl.searchParams.set("redirect_uri", redirectUri);
|
||||
authUrl.searchParams.set("scope", "read write");
|
||||
authUrl.searchParams.set("state", "st_sbx");
|
||||
authUrl.searchParams.set("code_challenge", challenge);
|
||||
authUrl.searchParams.set("code_challenge_method", "S256");
|
||||
|
||||
const consentHtml = await (await fetch(authUrl.toString())).text();
|
||||
const csrfToken = extractHiddenInput(consentHtml, "csrf_token");
|
||||
|
||||
const approveRes = await fetch(`${baseUrl}/oauth/authorize`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
||||
body: new URLSearchParams({
|
||||
client_id: "gemini-sandbox",
|
||||
redirect_uri: redirectUri,
|
||||
state: "st_sbx",
|
||||
scope: "read write",
|
||||
code_challenge: challenge,
|
||||
code_challenge_method: "S256",
|
||||
csrf_token: csrfToken,
|
||||
auth_mode: "sandbox",
|
||||
decision: "sandbox",
|
||||
}).toString(),
|
||||
redirect: "manual",
|
||||
});
|
||||
assert.equal(approveRes.status, 302);
|
||||
const code = new URL(approveRes.headers.get("location")).searchParams.get("code");
|
||||
|
||||
const tokRes = await fetch(`${baseUrl}/oauth/token`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
||||
body: new URLSearchParams({
|
||||
grant_type: "authorization_code",
|
||||
code,
|
||||
client_id: "gemini-sandbox",
|
||||
redirect_uri: redirectUri,
|
||||
code_verifier: verifier,
|
||||
}).toString(),
|
||||
});
|
||||
assert.equal(tokRes.status, 200);
|
||||
const tokens = await tokRes.json();
|
||||
assert.equal(tokens.scope, "read");
|
||||
|
||||
const writeAttempt = await fetch(`${baseUrl}/mcp`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Authorization: `Bearer ${tokens.access_token}`,
|
||||
},
|
||||
body: JSON.stringify({
|
||||
jsonrpc: "2.0",
|
||||
id: 14,
|
||||
method: "tools/call",
|
||||
params: { name: "create_parcel", arguments: { courier: "steadfast" } },
|
||||
}),
|
||||
});
|
||||
assert.equal(writeAttempt.status, 200);
|
||||
const writeBody = await writeAttempt.json();
|
||||
assert.equal(writeBody.result.isError, true);
|
||||
assert.ok(writeBody.result.content[0].text.includes("Insufficient scope"));
|
||||
});
|
||||
+3
-3
@@ -439,7 +439,7 @@ test("11. GET /health unauthenticated returns only { ok, version }; with admin t
|
||||
const adminBody = await adminRes.json();
|
||||
assert.equal(adminBody.ok, true);
|
||||
assert.equal(adminBody.version, expectedVersion);
|
||||
assert.equal(adminBody.tools_count, 12);
|
||||
assert.equal(adminBody.tools_count, 13);
|
||||
assert.ok(adminBody.performance);
|
||||
});
|
||||
|
||||
@@ -811,7 +811,7 @@ test("24. Upstream Cancellation: Steadfast cancelParcel handles already-cancelle
|
||||
}
|
||||
});
|
||||
|
||||
test("25. AI Connector: Unauthenticated tools/list discovery succeeds and lists 12 tools", async () => {
|
||||
test("25. AI Connector: Unauthenticated tools/list discovery succeeds and lists 13 tools", async () => {
|
||||
const res = await fetch(`${baseUrl}/mcp`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
@@ -821,5 +821,5 @@ test("25. AI Connector: Unauthenticated tools/list discovery succeeds and lists
|
||||
const body = await res.json();
|
||||
assert.equal(body.jsonrpc, "2.0");
|
||||
assert.ok(Array.isArray(body.result.tools));
|
||||
assert.equal(body.result.tools.length, 12);
|
||||
assert.equal(body.result.tools.length, 13);
|
||||
});
|
||||
|
||||
+44
-6
@@ -112,28 +112,65 @@ async function validateSkillsAndRules() {
|
||||
}
|
||||
|
||||
async function validateRemoteMcpServer() {
|
||||
console.log('\n--- 5. Validating Live Remote MCP Handshake & Tools ---');
|
||||
const endpoint = 'https://courier.auraajenticai.cloud/mcp';
|
||||
console.log('\n--- 5. Validating Live Remote MCP OAuth 2.1 Discovery, Handshake & 13 Tools ---');
|
||||
const baseOrigin = 'https://courier.auraajenticai.cloud';
|
||||
const endpoint = `${baseOrigin}/mcp`;
|
||||
const authToken = process.env.AURA_API_KEY || 'aura_ro_public_inspector_2026';
|
||||
try {
|
||||
const initRes = await fetch(endpoint, {
|
||||
// 5a. RFC 9728 Protected Resource Metadata & RFC 8414 Authorization Server Metadata
|
||||
const prmRes = await fetch(`${baseOrigin}/.well-known/oauth-protected-resource`);
|
||||
assert(prmRes.status === 200, `RFC 9728 /.well-known/oauth-protected-resource returned HTTP 200 (got ${prmRes.status})`);
|
||||
const prmData = await prmRes.json();
|
||||
assert(prmData.resource === endpoint, `protected resource matches ${endpoint}`);
|
||||
|
||||
const asmRes = await fetch(`${baseOrigin}/.well-known/oauth-authorization-server`);
|
||||
assert(asmRes.status === 200, `RFC 8414 /.well-known/oauth-authorization-server returned HTTP 200 (got ${asmRes.status})`);
|
||||
const asmData = await asmRes.json();
|
||||
assert(Array.isArray(asmData.code_challenge_methods_supported) && asmData.code_challenge_methods_supported.includes('S256'), 'OAuth 2.1 PKCE S256 advertised');
|
||||
|
||||
// 5b. Unauthenticated initialize returns 401 + WWW-Authenticate challenge
|
||||
const unauthRes = await fetch(endpoint, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json, text/event-stream'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
jsonrpc: '2.0',
|
||||
id: 0,
|
||||
method: 'initialize',
|
||||
params: {
|
||||
protocolVersion: '2025-03-26',
|
||||
capabilities: {},
|
||||
clientInfo: { name: 'antigravity-validator', version: PKG_VERSION }
|
||||
}
|
||||
})
|
||||
});
|
||||
assert(unauthRes.status === 401, `unauthenticated initialize returns HTTP 401 OAuth challenge (got ${unauthRes.status})`);
|
||||
const wwwAuth = unauthRes.headers.get('www-authenticate') || '';
|
||||
assert(wwwAuth.includes('resource_metadata='), '401 includes RFC 9728 WWW-Authenticate resource_metadata header');
|
||||
|
||||
// 5c. Authenticated initialize handshake + 13 live tools
|
||||
const initRes = await fetch(endpoint, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json, text/event-stream',
|
||||
'Authorization': `Bearer ${authToken}`
|
||||
},
|
||||
body: JSON.stringify({
|
||||
jsonrpc: '2.0',
|
||||
id: 1,
|
||||
method: 'initialize',
|
||||
params: {
|
||||
protocolVersion: '2024-11-05',
|
||||
protocolVersion: '2025-03-26',
|
||||
capabilities: {},
|
||||
clientInfo: { name: 'antigravity-validator', version: PKG_VERSION }
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
assert(initRes.status === 200, `initialize endpoint returned HTTP 200 (got ${initRes.status})`);
|
||||
assert(initRes.status === 200, `authenticated initialize endpoint returned HTTP 200 (got ${initRes.status})`);
|
||||
const sessionId = initRes.headers.get('mcp-session-id');
|
||||
assert(!!sessionId, `mcp-session-id header received: ${sessionId}`);
|
||||
|
||||
@@ -145,6 +182,7 @@ async function validateRemoteMcpServer() {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json, text/event-stream',
|
||||
'Authorization': `Bearer ${authToken}`,
|
||||
'mcp-session-id': sessionId
|
||||
},
|
||||
body: JSON.stringify({
|
||||
@@ -158,7 +196,7 @@ async function validateRemoteMcpServer() {
|
||||
assert(toolsRes.status === 200, `tools/list returned HTTP 200`);
|
||||
const toolsData = await toolsRes.json();
|
||||
const liveTools = toolsData.result?.tools || [];
|
||||
assert(liveTools.length === 9, `exactly 9 tools returned by remote server (got ${liveTools.length})`);
|
||||
assert(liveTools.length === 13, `exactly 13 tools returned by remote server (got ${liveTools.length})`);
|
||||
|
||||
const liveToolNames = liveTools.map(t => t.name);
|
||||
console.log(` Live tools on server: [ ${liveToolNames.join(', ')} ]`);
|
||||
|
||||
Reference in New Issue
Block a user