qwen-opencode-provider 3.2.0 → 3.2.1

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.
Files changed (2) hide show
  1. package/index.js +20 -19
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -85,25 +85,27 @@ async function validateToken(apiKey) {
85
85
  hostname: 'qwen.aikit.club',
86
86
  port: 443,
87
87
  path: '/v1/validate',
88
- method: 'POST',
88
+ method: 'GET',
89
89
  headers: {
90
90
  'Host': 'qwen.aikit.club',
91
- 'Content-Type': 'application/json'
91
+ 'Authorization': `Bearer ${apiKey}`
92
92
  }
93
93
  };
94
94
 
95
- if (apiKey) {
96
- options.headers['Authorization'] = `Bearer ${apiKey}`;
97
- }
98
-
99
95
  const req = https.request(options, (res) => {
100
96
  let data = '';
101
97
  res.on('data', chunk => data += chunk);
102
98
  res.on('end', () => {
103
99
  try {
104
100
  const json = JSON.parse(data);
105
- log(`[Validate] Response: ${JSON.stringify(json)}`);
106
- resolve(json);
101
+ log(`[Validate] Status: ${res.statusCode}, Response: ${JSON.stringify(json).substring(0, 100)}`);
102
+
103
+ // Valid token returns user info, invalid returns error
104
+ if (res.statusCode === 200 && json.id) {
105
+ resolve({ valid: true, data: json });
106
+ } else {
107
+ resolve({ valid: false, error: json.error || 'Unknown error' });
108
+ }
107
109
  } catch (e) {
108
110
  log(`[Validate] Parse error: ${e.message}`);
109
111
  resolve({ valid: false, error: e.message });
@@ -116,7 +118,7 @@ async function validateToken(apiKey) {
116
118
  resolve({ valid: false, error: e.message });
117
119
  });
118
120
 
119
- req.end(JSON.stringify({ token: apiKey }));
121
+ req.end();
120
122
  });
121
123
  }
122
124
 
@@ -132,28 +134,27 @@ async function refreshToken() {
132
134
  hostname: 'qwen.aikit.club',
133
135
  port: 443,
134
136
  path: '/v1/refresh',
135
- method: 'POST',
137
+ method: 'GET',
136
138
  headers: {
137
139
  'Host': 'qwen.aikit.club',
138
- 'Content-Type': 'application/json'
140
+ 'Authorization': `Bearer ${currentKey}`
139
141
  }
140
142
  };
141
143
 
142
- if (currentKey) {
143
- options.headers['Authorization'] = `Bearer ${currentKey}`;
144
- }
145
-
146
144
  const req = https.request(options, (res) => {
147
145
  let data = '';
148
146
  res.on('data', chunk => data += chunk);
149
147
  res.on('end', () => {
150
148
  try {
151
149
  const json = JSON.parse(data);
152
- log(`[Refresh] Response: ${JSON.stringify(json)}`);
150
+ log(`[Refresh] Status: ${res.statusCode}, Response: ${JSON.stringify(json).substring(0, 200)}`);
153
151
 
154
- if (json.token) {
155
- saveApiKeyToAuth(json.token);
156
- resolve(json.token);
152
+ if (res.statusCode === 200 && json.access_token) {
153
+ saveApiKeyToAuth(json.access_token);
154
+ resolve(json.access_token);
155
+ } else if (res.statusCode === 200 && json.id) {
156
+ // Token is still valid, no refresh needed
157
+ resolve(currentKey);
157
158
  } else {
158
159
  resolve(null);
159
160
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qwen-opencode-provider",
3
- "version": "3.2.0",
3
+ "version": "3.2.1",
4
4
  "description": "OpenCode plugin for Qwen API - auto adds provider with 28+ models",
5
5
  "main": "index.js",
6
6
  "type": "module",