现在有的接口对接测试完成
This commit is contained in:
@@ -9,7 +9,6 @@
|
||||
})(typeof globalThis !== 'undefined' ? globalThis : window, function (root) {
|
||||
'use strict';
|
||||
|
||||
var DEFAULT_SCENE_CODE = 'PC_SMS_LOGIN';
|
||||
var CAPTCHA_LAYER_AREA = ['318px', '318px'];
|
||||
var captchaLayerSeed = 0;
|
||||
|
||||
@@ -31,13 +30,11 @@
|
||||
}
|
||||
|
||||
function buildChallengeBody(options, api) {
|
||||
// 请求体字段严格对应 PC YAML 的 VerificationChallengeBody。
|
||||
// operationCode 属于路径,PC 验证请求体只提交租户和验证主体。
|
||||
var settings = options || {};
|
||||
|
||||
return {
|
||||
tenantId: settings.tenantId || api.tenantId,
|
||||
clientId: settings.clientId || api.clientId,
|
||||
sceneCode: settings.sceneCode || DEFAULT_SCENE_CODE,
|
||||
subject: settings.subject || ''
|
||||
};
|
||||
}
|
||||
@@ -74,8 +71,6 @@
|
||||
|
||||
return {
|
||||
tenantId: settings.tenantId || api.tenantId,
|
||||
clientId: settings.clientId || api.clientId,
|
||||
sceneCode: settings.sceneCode || DEFAULT_SCENE_CODE,
|
||||
subject: settings.subject || '',
|
||||
challengeId: settings.challengeId || source.challengeId || source.id,
|
||||
providerCode: settings.providerCode || 'tianai',
|
||||
@@ -87,7 +82,7 @@
|
||||
}
|
||||
|
||||
function normalizeVerifyTrack(data) {
|
||||
// 后端 /captcha/verify 要求轨迹统一放在 payload.track,并显式携带 left/top。
|
||||
// PC 验证接口要求轨迹统一放在 payload.track,并显式携带 left/top。
|
||||
var track = Object.assign({}, data || {});
|
||||
var trackList = Array.isArray(track.trackList) ? track.trackList : [];
|
||||
var first = trackList[0] || {};
|
||||
@@ -184,7 +179,7 @@
|
||||
}
|
||||
|
||||
function shouldRequireCaptcha(result) {
|
||||
// /captcha/require 返回 required=false 时允许直接继续业务请求。
|
||||
// PC require 返回 required=false 时允许直接继续业务请求。
|
||||
if (!result) return true;
|
||||
return result.required !== false;
|
||||
}
|
||||
@@ -213,8 +208,8 @@
|
||||
|
||||
config = new root.CaptchaConfig({
|
||||
bindEl: box,
|
||||
requestCaptchaDataUrl: api.buildApiUrl('/captcha/challenge'),
|
||||
validCaptchaUrl: api.buildApiUrl('/captcha/verify'),
|
||||
requestCaptchaDataUrl: api.captchaChallengeUrl(settings.operationCode),
|
||||
validCaptchaUrl: api.captchaVerifyUrl(settings.operationCode),
|
||||
requestHeaders: {
|
||||
clientid: api.clientId
|
||||
},
|
||||
@@ -301,10 +296,10 @@
|
||||
|
||||
if (!api) return '';
|
||||
if (field && field.value) return field.value;
|
||||
if (!settings.sceneCode) return '';
|
||||
if (!settings.operationCode) return '';
|
||||
|
||||
try {
|
||||
requirement = await api.captchaRequirement(buildChallengeBody(settings, api));
|
||||
requirement = await api.captchaRequirement(settings.operationCode, buildChallengeBody(settings, api));
|
||||
if (!shouldRequireCaptcha(requirement)) return 'CAPTCHA_NOT_REQUIRED';
|
||||
} catch (error) {
|
||||
// 查询策略失败时仍尝试直接拉起验证,避免认证接口缺少 validToken。
|
||||
|
||||
Reference in New Issue
Block a user