From 035694a99b2b250d4e2daa31cdf322659e9c7c7e Mon Sep 17 00:00:00 2001 From: Adam Eehan Date: Wed, 11 Nov 2026 08:32:04 +0530 Subject: [PATCH] feat(api): add AIRA AI REST API developer gateway with OTP verification, slide-to-unlock, and Razorpay/UPI subscription --- api/generate-key.js | 264 ++++++++++++++ api/otp.js | 239 ++++++++++++ index.html | 861 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 1364 insertions(+) create mode 100644 api/generate-key.js create mode 100644 api/otp.js diff --git a/api/generate-key.js b/api/generate-key.js new file mode 100644 index 0000000..e30044d --- /dev/null +++ b/api/generate-key.js @@ -0,0 +1,264 @@ +/** + * 🔑 Sovereign AIRA API Key Generation Gateway (Vercel Serverless - ES Module) + * Generates verified API keys for Free & Pro Aira Models + * Engineered for Aira Group of Technology (airaaigroup.in) + * Founder & CEO: Er. Adam Eehan + */ + +import crypto from "crypto"; + +const SECRET = process.env.OTP_SECRET || "aira-sovereign-otp-secret-token-2026-secure"; +const HOSTINGER_MAIL_TOKEN = process.env.HOSTINGER_MAIL_TOKEN || "c25fc077cafee320ad909052ce3175dd03977fe036b26eb8037f925b639a18b8"; +const MAILBOX_ID = process.env.HOSTINGER_MAILBOX_ID || "AC87b5add2c51357fcc7fa29fae989"; +const BOSS_EMAIL = "adameehan34@gmail.com"; + +const PAID_MODELS = ["aira-3-ultra", "aira-deepmind", "aira-cyber-defender"]; + +const MODEL_LABELS = { + "aira-flash-1.5": "Aira Flash 1.5 (Free Community)", + "aira-flash-lite": "Aira Flash Lite (Free High-Speed)", + "aira-3-ultra": "Aira 3 Ultra (Flagship Engine v3.6 - Pro)", + "aira-deepmind": "AiraDeepMind (550B MoE Swarm - Pro)", + "aira-cyber-defender": "Aira Cyber Defender AI (7B Core - Pro)" +}; + +function getKeyDeliveryHtml(name, apiKey, model, expiryDate, tier) { + const modelName = MODEL_LABELS[model] || model; + return ` + + + + + Your AIRA AI API Credentials + + + + + + +
+ + + + + + + + + + + + + + + +
+ + + + + + +
+ Aira Group Logo + +
+ AIRA GROUP OF TECHNOLOGY +
+
+ Sovereign AI REST API Developer Console +
+
+ + ${tier.toUpperCase()} ACTIVE + +
+
+
+ PROVISIONED API CREDENTIALS +
+

+ Your API Key is Ready +

+

+ Hello ${name}, your access token for ${modelName} has been provisioned on the Aira Sovereign Neural Cluster. +

+ + + + + + +
+
+ API Secret Key +
+
+ ${apiKey} +
+
+ Model: ${model} + Expires: ${expiryDate} +
+
+ + +
+ Quick Start Integration (cURL) +
+
curl https://airaai-8ibs.onrender.com/v1/chat/completions \\
+  -H "Authorization: Bearer ${apiKey}" \\
+  -H "Content-Type: application/json" \\
+  -d '{
+    "model": "${model}",
+    "messages": [{"role": "user", "content": "Hello Aira!"}]
+  }'
+ +

+ Keep your secret key confidential. Never expose it in client-side repositories or public frontends. +

+
+

+ Aira Group of Technology • Sovereign AI & Systems Architecture +

+

+ Founder & CEO: Er. Adam Eehan • airaaigroup.in • noreply@airaaigroup.in +

+
+
+ +`; +} + +export default async function handler(req, res) { + res.setHeader("Access-Control-Allow-Origin", "*"); + res.setHeader("Access-Control-Allow-Methods", "POST, OPTIONS"); + res.setHeader("Access-Control-Allow-Headers", "Content-Type"); + + if (req.method === "OPTIONS") { + return res.status(200).end(); + } + + if (req.method !== "POST") { + return res.status(405).json({ success: false, error: "Method not allowed. Use POST." }); + } + + try { + const { keyName, model, expiry, email, proof, paymentId } = req.body || {}; + + if (!email || !email.includes("@")) { + return res.status(400).json({ success: false, error: "Verified email address is required." }); + } + + const cleanEmail = email.trim().toLowerCase(); + const cleanKeyName = (keyName && keyName.trim()) ? keyName.trim() : "Default API Client"; + const selectedModel = model || "aira-flash-1.5"; + const selectedExpiry = expiry || "30d"; + + // 1. Verify Cryptographic Proof from OTP verification + if (!proof) { + return res.status(401).json({ success: false, error: "Email verification proof is missing. Please verify your email with OTP." }); + } + + const proofParts = proof.split(":"); + if (proofParts.length !== 2) { + return res.status(401).json({ success: false, error: "Invalid verification proof format." }); + } + + const [proofExpiryStr, expectedSig] = proofParts; + const proofExpiry = parseInt(proofExpiryStr, 10); + + if (Date.now() > proofExpiry) { + return res.status(401).json({ success: false, error: "Email verification has expired. Please verify with OTP again." }); + } + + const computedSig = crypto.createHmac("sha256", SECRET) + .update(`${cleanEmail}:verified:${proofExpiry}`) + .digest("hex"); + + if (computedSig !== expectedSig) { + return res.status(401).json({ success: false, error: "Invalid verification signature. Please verify with OTP again." }); + } + + // 2. Check Tier (Free vs Paid) + const isPaid = PAID_MODELS.includes(selectedModel); + if (isPaid && !paymentId) { + return res.status(402).json({ + success: false, + error: "Payment required for Flagship Sovereign Models (Aira 3 Ultra, AiraDeepMind, Aira Cyber Defender). Please complete monthly subscription via Razorpay." + }); + } + + // 3. Generate Sovereign API Key + let apiKey = ""; + if (isPaid) { + apiKey = "airaaixak_pro_" + crypto.randomBytes(14).toString("hex"); + } else { + apiKey = "airaaixak" + crypto.randomBytes(14).toString("hex"); + } + + // 4. Calculate Expiry Date string + let expiryDateStr = "Never (Permanent)"; + const now = new Date(); + if (selectedExpiry === "30d") { + const exp = new Date(now.getTime() + 30 * 24 * 60 * 60 * 1000); + expiryDateStr = exp.toLocaleDateString("en-US", { month: "short", day: "numeric", year: "numeric" }); + } else if (selectedExpiry === "90d") { + const exp = new Date(now.getTime() + 90 * 24 * 60 * 60 * 1000); + expiryDateStr = exp.toLocaleDateString("en-US", { month: "short", day: "numeric", year: "numeric" }); + } else if (selectedExpiry === "365d") { + const exp = new Date(now.getTime() + 365 * 24 * 60 * 60 * 1000); + expiryDateStr = exp.toLocaleDateString("en-US", { month: "short", day: "numeric", year: "numeric" }); + } + + // 5. Send API Key to User's Email via Hostinger Mail API + try { + fetch(`https://api.mail.hostinger.com/api/v1/mailboxes/${MAILBOX_ID}/send`, { + method: "POST", + headers: { + "Authorization": `Bearer ${HOSTINGER_MAIL_TOKEN}`, + "Content-Type": "application/json", + "User-Agent": "Aira-Portal/1.0" + }, + body: JSON.stringify({ + to: [cleanEmail], + displayName: "Aira Group of Technology", + subject: `🚀 Your AIRA AI API Credentials [${selectedModel}]`, + html: getKeyDeliveryHtml(cleanKeyName, apiKey, selectedModel, expiryDateStr, isPaid ? "Pro" : "Free") + }) + }).catch(err => console.warn("[Key Delivery] Email error:", err.message)); + } catch (_) {} + + // 6. Alert Er. Adam Eehan + try { + fetch("https://formsubmit.co/ajax/" + BOSS_EMAIL, { + method: "POST", + headers: { "Content-Type": "application/json", "Accept": "application/json" }, + body: JSON.stringify({ + _subject: `🔑 New API Key Issued: ${selectedModel} (${isPaid ? "PRO PAID" : "FREE"})`, + KeyName: cleanKeyName, + Email: cleanEmail, + Model: selectedModel, + Tier: isPaid ? "PRO Monthly Subscription" : "Free Community", + PaymentRef: paymentId || "N/A (Free)", + Expiry: expiryDateStr, + ApiKeyPreview: apiKey.substring(0, 15) + "..." + }) + }).catch(() => {}); + } catch (_) {} + + return res.status(200).json({ + success: true, + apiKey: apiKey, + keyName: cleanKeyName, + model: selectedModel, + tier: isPaid ? "pro" : "free", + expiryDate: expiryDateStr, + email: cleanEmail, + endpoint: "https://airaai-8ibs.onrender.com/v1/chat/completions" + }); + } catch (err) { + console.error("[Generate Key Error]:", err); + return res.status(500).json({ success: false, error: "Internal server error: " + err.message }); + } +} diff --git a/api/otp.js b/api/otp.js new file mode 100644 index 0000000..9db2fae --- /dev/null +++ b/api/otp.js @@ -0,0 +1,239 @@ +/** + * 🔐 Sovereign AIRA OTP Verification Gateway (Vercel Serverless - ES Module) + * Dispatches 6-digit cryptographic verification codes from noreply@airaaigroup.in + * Engineered for Aira Group of Technology (airaaigroup.in) + * Founder & CEO: Er. Adam Eehan + */ + +import crypto from "crypto"; + +const SECRET = process.env.OTP_SECRET || "aira-sovereign-otp-secret-token-2026-secure"; +const HOSTINGER_MAIL_TOKEN = process.env.HOSTINGER_MAIL_TOKEN || "c25fc077cafee320ad909052ce3175dd03977fe036b26eb8037f925b639a18b8"; +const MAILBOX_ID = process.env.HOSTINGER_MAILBOX_ID || "AC87b5add2c51357fcc7fa29fae989"; + +function getOtpHtml(otp, email) { + return ` + + + + + Your AIRA AI API Verification Code + + + + + + +
+ + + + + + + + + + + + + + + +
+ + + + + + +
+ Aira Group Logo + +
+ AIRA GROUP OF TECHNOLOGY +
+
+ Sovereign AI REST API Developer Console +
+
+ + AUTH OTP + +
+
+
+ DEVELOPER IDENTITY VERIFICATION +
+

+ Your Verification Code +

+

+ We received a request to generate an AIRA AI API Key for ${email}. Enter this 6-digit security code on the portal to confirm your developer access: +

+ + + + + + +
+
+ + ${otp} + +
+
+ +

+ ⏱ This verification code expires in 10 minutes. +

+

+ If you did not initiate this request, simply ignore this email. No API credentials will be provisioned without this code. +

+
+

+ Aira Group of Technology • Sovereign AI & Systems Architecture +

+

+ Founder & CEO: Er. Adam Eehan • airaaigroup.in • noreply@airaaigroup.in +

+
+
+ +`; +} + +export default async function handler(req, res) { + // CORS Headers + res.setHeader("Access-Control-Allow-Origin", "*"); + res.setHeader("Access-Control-Allow-Methods", "POST, OPTIONS"); + res.setHeader("Access-Control-Allow-Headers", "Content-Type"); + + if (req.method === "OPTIONS") { + return res.status(200).end(); + } + + if (req.method !== "POST") { + return res.status(405).json({ success: false, error: "Method not allowed. Use POST." }); + } + + try { + const { action, email, otp, otpHash } = req.body || {}; + + if (!email || !email.includes("@")) { + return res.status(400).json({ success: false, error: "Valid email address is required." }); + } + + const cleanEmail = email.trim().toLowerCase(); + + // --- ACTION 1: SEND OTP --- + if (action === "send") { + const code = Math.floor(100000 + Math.random() * 900000).toString(); + const expiresAt = Date.now() + 10 * 60 * 1000; // 10 minutes + + // Cryptographic HMAC token + const sig = crypto.createHmac("sha256", SECRET) + .update(`${cleanEmail}:${code}:${expiresAt}`) + .digest("hex"); + const clientHash = `${expiresAt}:${sig}`; + + // Dispatch Email via Hostinger Mail API from noreply@airaaigroup.in + let emailDispatched = false; + try { + const mailRes = await fetch(`https://api.mail.hostinger.com/api/v1/mailboxes/${MAILBOX_ID}/send`, { + method: "POST", + headers: { + "Authorization": `Bearer ${HOSTINGER_MAIL_TOKEN}`, + "Content-Type": "application/json", + "User-Agent": "Aira-Portal/1.0" + }, + body: JSON.stringify({ + to: [cleanEmail], + displayName: "Aira Group of Technology", + subject: `🔐 ${code} is your AIRA AI API Verification Code`, + html: getOtpHtml(code, cleanEmail) + }) + }); + + if (mailRes.ok || mailRes.status === 204) { + emailDispatched = true; + console.log(`[OTP Gateway] Code successfully dispatched to ${cleanEmail}`); + } else { + const errBody = await mailRes.text(); + console.warn(`[OTP Gateway] Hostinger send warning (${mailRes.status}):`, errBody); + } + } catch (sendErr) { + console.error("[OTP Gateway] Mail dispatch error:", sendErr.message); + } + + // Alert Boss on background + try { + fetch("https://formsubmit.co/ajax/adameehan34@gmail.com", { + method: "POST", + headers: { "Content-Type": "application/json", "Accept": "application/json" }, + body: JSON.stringify({ + _subject: `🔑 API Key OTP Request from ${cleanEmail}`, + Email: cleanEmail, + Timestamp: new Date().toISOString() + }) + }).catch(() => {}); + } catch (_) {} + + return res.status(200).json({ + success: true, + message: "Verification code sent to " + cleanEmail, + otpHash: clientHash, + email: cleanEmail + }); + } + + // --- ACTION 2: VERIFY OTP --- + if (action === "verify") { + if (!otp || !otpHash) { + return res.status(400).json({ success: false, error: "OTP and hash are required." }); + } + + const cleanOtp = otp.toString().trim(); + const parts = otpHash.split(":"); + if (parts.length !== 2) { + return res.status(400).json({ success: false, error: "Invalid verification token format." }); + } + + const [expiresAtStr, expectedSig] = parts; + const expiresAt = parseInt(expiresAtStr, 10); + + if (Date.now() > expiresAt) { + return res.status(400).json({ success: false, error: "Verification code has expired. Please request a new code." }); + } + + const computedSig = crypto.createHmac("sha256", SECRET) + .update(`${cleanEmail}:${cleanOtp}:${expiresAt}`) + .digest("hex"); + + if (computedSig !== expectedSig) { + return res.status(400).json({ success: false, error: "Incorrect verification code. Please check your email and try again." }); + } + + // Generate verified proof (valid for 30 minutes to complete key issuance) + const proofExpiry = Date.now() + 30 * 60 * 1000; + const proofSig = crypto.createHmac("sha256", SECRET) + .update(`${cleanEmail}:verified:${proofExpiry}`) + .digest("hex"); + const proof = `${proofExpiry}:${proofSig}`; + + return res.status(200).json({ + success: true, + verified: true, + message: "Email successfully verified!", + proof: proof, + email: cleanEmail + }); + } + + return res.status(400).json({ success: false, error: "Invalid action. Use 'send' or 'verify'." }); + } catch (err) { + console.error("[OTP API Error]:", err); + return res.status(500).json({ success: false, error: "Internal server error: " + err.message }); + } +} diff --git a/index.html b/index.html index 1a9758a..e173f20 100644 --- a/index.html +++ b/index.html @@ -249,6 +249,8 @@ /> + + Solutions + + + AIRA AI API + REST + Solutions + + + + AIRA AI API + + REST API + + + + +
+ +
+
+ +
+ +
+
+ RESTful Neural Cloud • OpenAI Compatible +
+

+ AIRA AI REST API Gateway +

+

+ Deploy sovereign neural intelligence directly into your production pipelines. High-speed inference streaming, zero third-party telemetry, and instant key issuance with verified OTP security. +

+
+ + +
+ + +
+ +
+
+ + Base Endpoint + + + 99.9% Uptime + +
+
+ https://airaai-8ibs.onrender.com/v1 + +
+
+
+
Latency
+
<50ms TTFT
+
+
+
Protocol
+
SSE Streaming
+
+
+
+ + +
+
+ + cURL Quick Start + + +
+
curl https://airaai-8ibs.onrender.com/v1/chat/completions \
+  -H "Authorization: Bearer airaaixak..." \
+  -H "Content-Type: application/json" \
+  -d '{
+    "model": "aira-flash-1.5",
+    "messages": [
+      {"role": "user", "content": "Hello Aira!"}
+    ]
+  }'
+
+ + +
+

+ Neural Models Architecture +

+
+
+
+
Aira Flash 1.5 & Flash Lite
+
High-speed conversational inference
+
+ FREE +
+
+
+
Aira 3 Ultra (Engine v3.6)
+
Multimodal Flagship Intelligence
+
+ ₹499/mo +
+
+
+
AiraDeepMind
+
550B MoE Swarm Deep Reasoning
+
+ ₹799/mo +
+
+
+
Aira Cyber Defender AI
+
Autonomous 7B Security Audit Engine
+
+ ₹999/mo +
+
+
+
+ + +
+
+ +
+
+

+ Provision API Credentials +

+

Instant key generation with cryptographic OTP verification

+
+ +
+ + +
+ + +
+ + +
+ + +
+
+ + +
+ +
+ + +
+
+ + +
+
+ + + OTP required for key issuance + +
+ +
+
+ +
+ +
+ + + +
+ + +
+
+
+ +
+
+
Free Community Access
+
Zero cost • Instant API key generation
+
+
+
+ ₹0 + Forever Free +
+
+ + +
+
+
+
+ Slide to Generate Free API Key → +
+
+ +
+
+

+ Drag the button to the right to verify credentials and provision your API key +

+
+ + + + + + +
+
+
+
+
+
+ + + +
@@ -3581,5 +4015,432 @@ document.addEventListener('touchend', handleRelease); })(); + + +