opencode-pollinations-plugin 5.5.3 → 5.5.4
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.
- package/dist/server/commands.js +24 -27
- package/dist/server/quota.js +5 -6
- package/package.json +1 -1
package/dist/server/commands.js
CHANGED
|
@@ -5,37 +5,34 @@ import { getDetailedUsage } from './pollinations-api.js';
|
|
|
5
5
|
import { generatePollinationsConfig } from './generate-config.js';
|
|
6
6
|
import * as https from 'https';
|
|
7
7
|
// --- HELPER: STRICT PERMISSION CHECK ---
|
|
8
|
-
function
|
|
8
|
+
function checkEndpoint(ep, key) {
|
|
9
9
|
return new Promise((resolve) => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
headers: { 'Authorization': `Bearer ${key}` }
|
|
21
|
-
}, (res) => {
|
|
22
|
-
completed++;
|
|
23
|
-
if (res.statusCode === 200)
|
|
24
|
-
successCount++;
|
|
25
|
-
if (completed === endpoints.length) {
|
|
26
|
-
resolve(successCount === endpoints.length);
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
req.on('error', () => {
|
|
30
|
-
completed++;
|
|
31
|
-
if (completed === endpoints.length)
|
|
32
|
-
resolve(successCount === endpoints.length);
|
|
33
|
-
});
|
|
34
|
-
req.setTimeout(5000, () => req.destroy());
|
|
35
|
-
req.end();
|
|
10
|
+
const req = https.request({
|
|
11
|
+
hostname: 'gen.pollinations.ai',
|
|
12
|
+
path: ep,
|
|
13
|
+
method: 'GET',
|
|
14
|
+
headers: { 'Authorization': `Bearer ${key}` }
|
|
15
|
+
}, (res) => {
|
|
16
|
+
if (res.statusCode === 200)
|
|
17
|
+
resolve(true);
|
|
18
|
+
else
|
|
19
|
+
resolve(false);
|
|
36
20
|
});
|
|
21
|
+
req.on('error', () => resolve(false));
|
|
22
|
+
req.setTimeout(5000, () => req.destroy());
|
|
23
|
+
req.end();
|
|
37
24
|
});
|
|
38
25
|
}
|
|
26
|
+
async function checkKeyPermissions(key) {
|
|
27
|
+
// SEQUENTIAL CHECK (Avoid Rate Limits on Key Verification)
|
|
28
|
+
const endpoints = ['/account/profile', '/account/balance', '/account/usage'];
|
|
29
|
+
for (const ep of endpoints) {
|
|
30
|
+
const ok = await checkEndpoint(ep, key);
|
|
31
|
+
if (!ok)
|
|
32
|
+
return false; // Fail fast
|
|
33
|
+
}
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
39
36
|
// === CONSTANTS & PRICING ===
|
|
40
37
|
const TIER_LIMITS = {
|
|
41
38
|
spore: { pollen: 1, emoji: '🦠' },
|
package/dist/server/quota.js
CHANGED
|
@@ -63,12 +63,11 @@ export async function getQuotaStatus(forceRefresh = false) {
|
|
|
63
63
|
}
|
|
64
64
|
try {
|
|
65
65
|
logQuota("Fetching Quota Data...");
|
|
66
|
-
//
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
]);
|
|
66
|
+
// SEQUENTIAL FETCH (Avoid Rate Limits)
|
|
67
|
+
// We fetch one by one. If one fails, we catch and return fallback.
|
|
68
|
+
const profileRes = await fetchAPI('/account/profile', config.apiKey);
|
|
69
|
+
const balanceRes = await fetchAPI('/account/balance', config.apiKey);
|
|
70
|
+
const usageRes = await fetchAPI('/account/usage', config.apiKey);
|
|
72
71
|
logQuota(`Fetch Success. Tier: ${profileRes.tier}, Balance: ${balanceRes.balance}`);
|
|
73
72
|
const profile = profileRes;
|
|
74
73
|
const balance = balanceRes.balance;
|
package/package.json
CHANGED