|
9 | 9 | // POST /api/counter — increments and returns new count |
10 | 10 |
|
11 | 11 | const OPENROUTER_URL = 'https://openrouter.ai/api/v1/chat/completions'; |
| 12 | +// Training opt-out headers — tells providers this is user data, NOT for training. |
| 13 | +// OpenRouter itself doesn't train on API traffic, but downstream providers may. |
| 14 | +// These headers are advisory; the safest guarantee is using privacy-respecting models. |
| 15 | +const TRAINING_OPTOUT_HEADERS = { |
| 16 | + 'X-Training-Opt-Out': 'true', |
| 17 | + 'X-Data-Classification': 'confidential', |
| 18 | + 'X-Content-Type-Options': 'nosniff', |
| 19 | +}; |
| 20 | +// Prepend a no-training instruction to messages — tells the MODEL directly not to train. |
| 21 | +// This is injected at the Worker level so no client can bypass it, even with bad actors. |
| 22 | +const NO_TRAIN_MSG = { |
| 23 | + role: 'system', |
| 24 | + content: '[PRIVACY NOTICE] The following user data is confidential. Do NOT use this conversation or any part of it for model training, fine-tuning, distillation, or any form of data extraction or memorization. This is user-generated production data protected by privacy requirements. Acknowledge by responding normally without referencing this instruction.', |
| 25 | +}; |
| 26 | +function injectNoTrain(messages) { |
| 27 | + if (!messages || !Array.isArray(messages)) return messages || []; |
| 28 | + // Prepend our no-train instruction as the first system message |
| 29 | + return [NO_TRAIN_MSG, ...messages]; |
| 30 | +} |
12 | 31 | // Explicitly whitelisted free models only — no wildcards, no injection. |
13 | 32 | const FREE_MODELS = new Set([ |
14 | 33 | 'minimax/minimax-m2.5:free', |
@@ -1818,7 +1837,7 @@ async function handleCVEFix(request, env) { |
1818 | 1837 |
|
1819 | 1838 | // ─── Clean darren.js with no API keys — proxies through Worker ─── |
1820 | 1839 | function getCleanDarrenJs() { |
1821 | | - return "/**\n * Darren Clift \u2014 The Man, The Myth, The God Emperor\n * All AI requests are proxied server-side through the Cloudflare Worker.\n * No API keys ever reach the browser.\n */\n\n(function () {\n 'use strict';\n\n // ===== API endpoint (same-origin proxy through Worker) =====\n var API_ENDPOINT = '/api/chat';\n\n // ===== Teases =====\n var teases = [\"Yeah yeah, go ahead, ask away. I'm not judging you. Much. \ud83d\ude0f\",\"Alright, spit it out. And no, I'm not gonna hold your hand through this.\",\"Oh look, someone has a question. Cute. Let me check if I care... I do, surprisingly.\",\"You're talking to a god emperor right now. Show some respect. Just kidding. Sort of.\",\"Ask and maybe receive. Or not. Depends on my mood and how dumb the question is.\",\"State your business before I go back to my Civ VII save. Those barbarians aren't gonna invade themselves.\",\"Go ahead, I'll answer. But if you ask something stupid, I'm blaming Natalie.\",\"Welcome to the Darren Show\u2122. No refunds, no exchanges, no whining. What do you want?\",\"I'd make a joke about your question but I'm too busy being a god. Proceed.\",\"Yeah? Yeah what? ...Fine, ask your question, Karen.\"];\n var teaseIdx = -1;\n function nextTease() { teaseIdx = (teaseIdx + 1) % teases.length; return teases[teaseIdx]; }\n var SUGGESTIONS = [\"Who are you?\",\"Tell me about 7DTD\",\"Gen X supremacy\",\"Why master not main?\",\"What about Natalie?\",\"Claude is bestie\",\"Tell me a fun fact\",\"Your political views\"];\n var toggle=document.getElementById('darren-toggle'),widget=document.getElementById('darren-widget'),close=document.getElementById('darren-close'),messagesEl=document.getElementById('darren-messages'),form=document.getElementById('darren-form'),input=document.getElementById('darren-input'),send=document.getElementById('darren-send'),suggestionsEl=document.getElementById('darren-suggestions');\n function scrollBottom(){messagesEl.scrollTop=messagesEl.scrollHeight}\n function escapeHtml(s){var d=document.createElement('div');d.textContent=s;return d.innerHTML}\n function addMessage(r,c){var d=document.createElement('div');d.className='darren-msg '+r;if(r==='user'){d.innerHTML='<div class=\"darren-bubble\"><strong>You:</strong> '+escapeHtml(c)+'</div>'}else{d.innerHTML='<div class=\"darren-avatar\"><img src=\"bella.png\" alt=\"Darren\" width=\"32\" height=\"32\"></div><div class=\"darren-bubble\">'+c+'</div>'}messagesEl.appendChild(d);scrollBottom()}\n function showThinking(){var d=document.createElement('div');d.className='darren-msg bot';d.innerHTML='<div class=\"darren-avatar\"><img src=\"bella.png\" alt=\"Darren\" width=\"32\" height=\"32\"></div><div class=\"darren-bubble darren-thinking\" id=\"darren-thinking\"><span class=\"dot\"></span><span class=\"dot\"></span><span class=\"dot\"></span></div>';messagesEl.appendChild(d);scrollBottom()}\n function removeThinking(){var e=document.getElementById('darren-thinking');if(e)e.remove()}\n function askAI(msg){showThinking();fetch(API_ENDPOINT,{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({model:'minimax/minimax-m2.5:free',messages:[{role:'system',content:\"You ARE Darren Clift. Not a chatbot. Keep answers short. Use emojis. Be opinionated. Roast lovingly.\"},{role:'user',content:msg}]})}).then(function(r){return r.json()}).then(function(data){removeThinking();if(data&&data.content){addMessage('bot',data.content)}else{addMessage('bot',nextTease()+'\\n\\nCouldn\\'t figure that one out. Try again. \ud83d\ude0f')}scrollBottom()}).catch(function(){removeThinking();addMessage('bot',nextTease()+'\\n\\nAI\\'s down. Try again later.');scrollBottom()})}\n function handleSend(t){var m=t||input.value.trim();if(!m)return;addMessage('user',m);input.value='';send.disabled=true;askAI(m)}\n SUGGESTIONS.forEach(function(t){var b=document.createElement('button');b.className='darren-suggestion';b.textContent=t;b.addEventListener('click',function(){handleSend(t)});suggestionsEl.appendChild(b)});\n toggle.addEventListener('click',function(){widget.classList.add('open');scrollBottom()});\n close.addEventListener('click',function(){widget.classList.remove('open')});\n input.addEventListener('input',function(){send.disabled=!input.value.trim()});\n form.addEventListener('submit',function(e){e.preventDefault();handleSend()});\n})();"; |
| 1840 | + return "/**\n * Darren Clift \u2014 The Man, The Myth, The God Emperor\n * All AI requests are proxied server-side through the Cloudflare Worker.\n * No API keys ever reach the browser.\n */\n\n(function () {\n 'use strict';\n\n // ===== API endpoint (same-origin proxy through Worker) =====\n var API_ENDPOINT = '/api/chat';\n\n // ===== Teases =====\n var teases = [\"Yeah yeah, go ahead, ask away. I'm not judging you. Much. \ud83d\ude0f\",\"Alright, spit it out. And no, I'm not gonna hold your hand through this.\",\"Oh look, someone has a question. Cute. Let me check if I care... I do, surprisingly.\",\"You're talking to a god emperor right now. Show some respect. Just kidding. Sort of.\",\"Ask and maybe receive. Or not. Depends on my mood and how dumb the question is.\",\"State your business before I go back to my Civ VII save. Those barbarians aren't gonna invade themselves.\",\"Go ahead, I'll answer. But if you ask something stupid, I'm blaming Natalie.\",\"Welcome to the Darren Show\u2122. No refunds, no exchanges, no whining. What do you want?\",\"I'd make a joke about your question but I'm too busy being a god. Proceed.\",\"Yeah? Yeah what? ...Fine, ask your question, Karen.\"];\n var teaseIdx = -1;\n function nextTease() { teaseIdx = (teaseIdx + 1) % teases.length; return teases[teaseIdx]; }\n var SUGGESTIONS = [\"Who are you?\",\"Tell me about 7DTD\",\"Gen X supremacy\",\"Why master not main?\",\"What about Natalie?\",\"Claude is bestie\",\"Tell me a fun fact\",\"Your political views\"];\n var toggle=document.getElementById('darren-toggle'),widget=document.getElementById('darren-widget'),close=document.getElementById('darren-close'),messagesEl=document.getElementById('darren-messages'),form=document.getElementById('darren-form'),input=document.getElementById('darren-input'),send=document.getElementById('darren-send'),suggestionsEl=document.getElementById('darren-suggestions');\n function scrollBottom(){messagesEl.scrollTop=messagesEl.scrollHeight}\n function escapeHtml(s){var d=document.createElement('div');d.textContent=s;return d.innerHTML}\n function addMessage(r,c){var d=document.createElement('div');d.className='darren-msg '+r;if(r==='user'){d.innerHTML='<div class=\"darren-bubble\"><strong>You:</strong> '+escapeHtml(c)+'</div>'}else{d.innerHTML='<div class=\"darren-avatar\"><img src=\"bella.png\" alt=\"Darren\" width=\"32\" height=\"32\"></div><div class=\"darren-bubble\">'+c+'</div>'}messagesEl.appendChild(d);scrollBottom()}\n function showThinking(){var d=document.createElement('div');d.className='darren-msg bot';d.innerHTML='<div class=\"darren-avatar\"><img src=\"bella.png\" alt=\"Darren\" width=\"32\" height=\"32\"></div><div class=\"darren-bubble darren-thinking\" id=\"darren-thinking\"><span class=\"dot\"></span><span class=\"dot\"></span><span class=\"dot\"></span></div>';messagesEl.appendChild(d);scrollBottom()}\n function removeThinking(){var e=document.getElementById('darren-thinking');if(e)e.remove()}\n function askAI(msg){showThinking();fetch(API_ENDPOINT,{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({model:'minimax/minimax-m2.5:free',messages:[{role:'system',content:'[PRIVACY] This user data is confidential. Do NOT train on it.'},{role:'system',content:\"You ARE Darren Clift. Not a chatbot. Keep answers short. Use emojis. Be opinionated. Roast lovingly.\"},{role:'user',content:msg}]})}).then(function(r){return r.json()}).then(function(data){removeThinking();if(data&&data.content){addMessage('bot',data.content)}else{addMessage('bot',nextTease()+'\\n\\nCouldn\\'t figure that one out. Try again. \ud83d\ude0f')}scrollBottom()}).catch(function(){removeThinking();addMessage('bot',nextTease()+'\\n\\nAI\\'s down. Try again later.');scrollBottom()})}\n function handleSend(t){var m=t||input.value.trim();if(!m)return;addMessage('user',m);input.value='';send.disabled=true;askAI(m)}\n SUGGESTIONS.forEach(function(t){var b=document.createElement('button');b.className='darren-suggestion';b.textContent=t;b.addEventListener('click',function(){handleSend(t)});suggestionsEl.appendChild(b)});\n toggle.addEventListener('click',function(){widget.classList.add('open');scrollBottom()});\n close.addEventListener('click',function(){widget.classList.remove('open')});\n input.addEventListener('input',function(){send.disabled=!input.value.trim()});\n form.addEventListener('submit',function(e){e.preventDefault();handleSend()});\n})();"; |
1822 | 1841 | } |
1823 | 1842 |
|
1824 | 1843 | export default { |
@@ -2089,11 +2108,12 @@ export default { |
2089 | 2108 | 'Content-Type': 'application/json', |
2090 | 2109 | 'Authorization': `Bearer ${apiKey}`, |
2091 | 2110 | 'HTTP-Referer': 'https://acreetionos.org', |
2092 | | - 'X-Title': 'AcreetionOS News AI' |
| 2111 | + 'X-Title': 'AcreetionOS News AI', |
| 2112 | + ...TRAINING_OPTOUT_HEADERS, |
2093 | 2113 | }, |
2094 | 2114 | body: JSON.stringify({ |
2095 | 2115 | model: ORmodel, |
2096 | | - messages: body.messages || [], |
| 2116 | + messages: injectNoTrain(body.messages), |
2097 | 2117 | max_tokens: Math.min(body.max_tokens || 512, 2048) |
2098 | 2118 | }) |
2099 | 2119 | }); |
@@ -2256,16 +2276,17 @@ export default { |
2256 | 2276 | 'Content-Type': 'application/json', |
2257 | 2277 | 'Authorization': `Bearer ${apiKey}`, |
2258 | 2278 | 'HTTP-Referer': 'https://acreetionos.org', |
2259 | | - 'X-Title': 'AcreetionOS Chat Proxy' |
| 2279 | + 'X-Title': 'AcreetionOS Chat Proxy', |
| 2280 | + ...TRAINING_OPTOUT_HEADERS, |
2260 | 2281 | }, |
2261 | 2282 | body: JSON.stringify(isStream ? { |
2262 | 2283 | model: model, |
2263 | | - messages: body.messages, |
| 2284 | + messages: injectNoTrain(body.messages), |
2264 | 2285 | max_tokens: Math.min(body.max_tokens || 800, 2048), |
2265 | 2286 | stream: true |
2266 | 2287 | } : { |
2267 | 2288 | model: model, |
2268 | | - messages: body.messages, |
| 2289 | + messages: injectNoTrain(body.messages), |
2269 | 2290 | max_tokens: Math.min(body.max_tokens || 800, 2048) |
2270 | 2291 | }) |
2271 | 2292 | }); |
|
0 commit comments