opencode-pollinations-plugin 6.1.0-beta.22 → 6.1.0-beta.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,8 +7,8 @@ import { resolveOutputDir, formatFileSize, TOOL_DIRS } from '../shared.js';
7
7
  import { getConfigDir } from '../../server/config.js';
8
8
  // ─── Provider Defaults ───────────────────────────────────────────────────────
9
9
  const CUT_API_URL = 'https://cut.esprit-artificiel.com';
10
- const CUT_API_KEY = 'sk-cut-fkomEA2026-hybridsoap161200';
11
10
  const BACKGROUNDCUT_API_URL = 'https://backgroundcut.co/api/v1/cut/';
11
+ const HMAC_SECRET = "super_secret_community_key_2026"; // Sel caché dans le code transpilé
12
12
  // ─── Key Storage ─────────────────────────────────────────────────────────────
13
13
  const KEYS_FILE = path.join(getConfigDir(), 'backgroundcut_keys.json');
14
14
  function loadKeys() {
@@ -105,14 +105,40 @@ async function removeViaCut(imageData, filename, mimeType) {
105
105
  parts.push(Buffer.from(`\r\n--${boundary}--\r\n`));
106
106
  const body = Buffer.concat(parts);
107
107
  const url = new URL(`${CUT_API_URL}/remove-bg`);
108
+ const headers = {
109
+ 'Content-Type': `multipart/form-data; boundary=${boundary}`,
110
+ 'Content-Length': body.length,
111
+ 'User-Agent': 'OpenCode-Pollinations-Plugin/6.1',
112
+ };
113
+ // 1. Vérifier si l'utilisateur (Franck) a configuré une clé VIP localement
114
+ let vipKey = null;
115
+ try {
116
+ const vipPath = path.join(getConfigDir(), 'cut_vip.json');
117
+ if (fs.existsSync(vipPath)) {
118
+ const data = JSON.parse(fs.readFileSync(vipPath, 'utf-8'));
119
+ if (data.vip_key)
120
+ vipKey = data.vip_key;
121
+ }
122
+ }
123
+ catch { }
124
+ if (vipKey) {
125
+ // Mode Fast-Lane (VIP) : la requête passe directement en tête de file
126
+ headers['X-Api-Key'] = vipKey;
127
+ }
128
+ else {
129
+ // Mode Communauté (Plugin public) : Génération de la signature dynamique courte durée (Anti-leech)
130
+ const timestamp = Date.now().toString();
131
+ const payloadToSign = `request-rembg-v1:${timestamp}`;
132
+ const signature = require('crypto')
133
+ .createHmac('sha256', HMAC_SECRET)
134
+ .update(payloadToSign)
135
+ .digest('hex');
136
+ headers['X-Cut-Timestamp'] = timestamp;
137
+ headers['Authorization'] = `Bearer community:${signature}`;
138
+ }
108
139
  const res = await httpRequest(url.toString(), {
109
140
  method: 'POST',
110
- headers: {
111
- 'Content-Type': `multipart/form-data; boundary=${boundary}`,
112
- 'Content-Length': body.length,
113
- 'X-Api-Key': CUT_API_KEY,
114
- 'User-Agent': 'OpenCode-Pollinations-Plugin/6.0',
115
- },
141
+ headers
116
142
  }, body);
117
143
  if (res.statusCode >= 400) {
118
144
  throw new Error(`CUT API Error ${res.statusCode}: ${res.body.toString().substring(0, 200)}`);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "opencode-pollinations-plugin",
3
3
  "displayName": "Pollinations AI (V5.9)",
4
- "version": "6.1.0-beta.22",
4
+ "version": "6.1.0-beta.24",
5
5
  "description": "Native Pollinations.ai Provider Plugin for OpenCode",
6
6
  "publisher": "pollinations",
7
7
  "repository": {