twikoo-func 1.7.6 → 1.7.7
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/index.js +7 -0
- package/package.json +1 -1
- package/utils/index.js +12 -8
package/index.js
CHANGED
|
@@ -736,11 +736,18 @@ async function checkCaptcha (comment) {
|
|
|
736
736
|
geeTestGenTime: comment.geeTestGenTime
|
|
737
737
|
})
|
|
738
738
|
} else if (provider === 'Cap' && config.CAP_API_ENDPOINT && config.CAP_SECRET_KEY) {
|
|
739
|
+
if (!comment.capToken) {
|
|
740
|
+
throw new Error('验证码 token 缺失,请刷新页面重试')
|
|
741
|
+
}
|
|
739
742
|
await checkCapCaptcha({
|
|
740
743
|
capToken: comment.capToken,
|
|
741
744
|
capSecretKey: config.CAP_SECRET_KEY,
|
|
742
745
|
capApiEndpoint: config.CAP_API_ENDPOINT
|
|
743
746
|
})
|
|
747
|
+
} else if (provider === 'Cap') {
|
|
748
|
+
throw new Error('Cap 验证码配置不完整,请联系管理员')
|
|
749
|
+
} else if (provider) {
|
|
750
|
+
throw new Error(`不支持的验证码类型: ${provider}`)
|
|
744
751
|
}
|
|
745
752
|
}
|
|
746
753
|
|
package/package.json
CHANGED
package/utils/index.js
CHANGED
|
@@ -356,12 +356,17 @@ const fn = {
|
|
|
356
356
|
},
|
|
357
357
|
async checkCapCaptcha ({ capToken, capSecretKey, capApiEndpoint }) {
|
|
358
358
|
try {
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
const url = `${
|
|
363
|
-
|
|
364
|
-
|
|
359
|
+
// 移除末尾的斜杠,避免双斜杠
|
|
360
|
+
const endpoint = capApiEndpoint.replace(/\/$/, '')
|
|
361
|
+
// Cap 的 siteverify 端点
|
|
362
|
+
const url = `${endpoint}/siteverify`
|
|
363
|
+
logger.log('Cap验证码验证URL:', url)
|
|
364
|
+
logger.log('Cap验证码验证参数:', { secret: capSecretKey ? '***' : undefined, response: capToken.substring(0, 20) + '...' })
|
|
365
|
+
const { data } = await axios.post(url, {
|
|
366
|
+
secret: capSecretKey,
|
|
367
|
+
response: capToken
|
|
368
|
+
}, {
|
|
369
|
+
headers: { 'Content-Type': 'application/json' }
|
|
365
370
|
})
|
|
366
371
|
logger.log('Cap验证码检测结果', data)
|
|
367
372
|
if (!data.success) throw new Error(data.error || '验证码错误')
|
|
@@ -409,10 +414,9 @@ const fn = {
|
|
|
409
414
|
baseConfig.GEETEST_CAPTCHA_ID = config.GEETEST_CAPTCHA_ID
|
|
410
415
|
}
|
|
411
416
|
|
|
412
|
-
// 仅在明确指定使用 Cap 时下发 Cap 的 api endpoint
|
|
417
|
+
// 仅在明确指定使用 Cap 时下发 Cap 的 api endpoint
|
|
413
418
|
if (config.CAPTCHA_PROVIDER === 'Cap') {
|
|
414
419
|
baseConfig.CAP_API_ENDPOINT = config.CAP_API_ENDPOINT
|
|
415
|
-
baseConfig.CAP_SITE_KEY = config.CAP_SITE_KEY
|
|
416
420
|
}
|
|
417
421
|
|
|
418
422
|
return {
|