(exchangeData)
| 238 | } |
| 239 | |
| 240 | function buildOpenAiCredentials(exchangeData) { |
| 241 | const credentials = {}; |
| 242 | const allowedKeys = [ |
| 243 | 'access_token', |
| 244 | 'refresh_token', |
| 245 | 'id_token', |
| 246 | 'expires_at', |
| 247 | 'email', |
| 248 | 'chatgpt_account_id', |
| 249 | 'chatgpt_user_id', |
| 250 | 'organization_id', |
| 251 | 'plan_type', |
| 252 | 'client_id', |
| 253 | ]; |
| 254 | |
| 255 | for (const key of allowedKeys) { |
| 256 | if (exchangeData?.[key] !== undefined && exchangeData?.[key] !== null && exchangeData?.[key] !== '') { |
| 257 | credentials[key] = exchangeData[key]; |
| 258 | } |
| 259 | } |
| 260 | |
| 261 | if (!credentials.access_token) { |
| 262 | throw new Error('SUB2API 交换授权码后未返回 access_token。'); |
| 263 | } |
| 264 | |
| 265 | return credentials; |
| 266 | } |
| 267 | |
| 268 | function buildOpenAiExtra(exchangeData) { |
| 269 | const extra = {}; |
no outgoing calls
no test coverage detected