From 67a9b5844e5d210eed2ff8045c2d0aaab58f2ace Mon Sep 17 00:00:00 2001 From: chitcommit <208086304+chitcommit@users.noreply.github.com> Date: Wed, 27 May 2026 17:12:02 +0000 Subject: [PATCH] feat(mint): canonical POST /mint + 308-redirect deprecated aliases (E1) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Per user decision: id.chitty.cc/mint is the canonical external mint route — short, logical, identity-service-as-mint-front-door. Backend stays the same (handleDirectChittyIdGeneration proxying to mint.chitty.cc/api/mint). Frontend simplifies to /mint. Deprecated aliases with 308 redirect + reminder headers: - POST /v1/mint - GET /api/get-chittyid - GET /generate All three redirect to https://id.chitty.cc/mint with: - Status 308 (preserves method + body) - Deprecation: true - Sunset: 2027-05-27 - Link to successor-version + SOP-012 reference - Warning 299 (deprecation reason) - JSON body with _deprecation reminder for clients that ignore redirects Refs: - mint-discovery.md G3 (multiple competing mint endpoints) - SOP-012 v0.3.0 (canonical format) - User decision 2026-05-27: id.chitty.cc/mint as base Co-Authored-By: Claude Opus 4.7 (1M context) --- worker.js | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/worker.js b/worker.js index 4abb7ad..915c581 100644 --- a/worker.js +++ b/worker.js @@ -464,19 +464,37 @@ export default { }); } - // Generate endpoint - delegates to ChittyMint - if (url.pathname === "/generate" && request.method === "GET") { + // E1 canonical mint endpoint: POST /mint (short, logical, id.chitty.cc as primary) + if (url.pathname === "/mint" && request.method === "POST") { return await handleDirectChittyIdGeneration(url, env, request); } - // VRF mint endpoint - delegates to ChittyMint + // E1 deprecated aliases — 308 to canonical /mint with deprecation headers. + // 308 preserves method+body. Includes Deprecation, Sunset, Link, Warning headers + // so clients see migration hint regardless of how they handle redirects. + const deprecationHeaders = { + "Location": "https://id.chitty.cc/mint", + "Deprecation": "true", + "Sunset": "2027-05-27", + "Link": "; rel=\"successor-version\", ; rel=\"deprecation\"", + "Warning": "299 - \"Deprecated endpoint. POST https://id.chitty.cc/mint is the canonical mint route. Sunset 2027-05-27.\"", + "Access-Control-Allow-Origin": "*" + }; + if (url.pathname === "/v1/mint" && request.method === "POST") { - return await handleDirectChittyIdGeneration(url, env, request); + return new Response(JSON.stringify({ + _deprecation: { canonical: "https://id.chitty.cc/mint", sunset: "2027-05-27", note: "POST /v1/mint is deprecated. Use POST /mint." } + }), { status: 308, headers: deprecationHeaders }); } - - // Direct API handlers (bypassing Pages Functions import issues) if (url.pathname === "/api/get-chittyid" && request.method === "GET") { - return await handleDirectChittyIdGeneration(url, env, request); + return new Response(JSON.stringify({ + _deprecation: { canonical: "https://id.chitty.cc/mint", sunset: "2027-05-27", note: "GET /api/get-chittyid is deprecated. POST https://id.chitty.cc/mint with {entityType:\"P\"} body." } + }), { status: 308, headers: deprecationHeaders }); + } + if (url.pathname === "/generate" && request.method === "GET") { + return new Response(JSON.stringify({ + _deprecation: { canonical: "https://id.chitty.cc/mint", sunset: "2027-05-27", note: "GET /generate is deprecated. POST https://id.chitty.cc/mint with {entityType:\"P\"} body." } + }), { status: 308, headers: deprecationHeaders }); } if (url.pathname === "/api/health" && request.method === "GET") {