fix(云智能体): 避免轻微时差导致连接失败
This commit is contained in:
@@ -608,13 +608,17 @@ export class CloudAgentsModule {
|
||||
if ((url.protocol !== 'https:' && !(url.protocol === 'http:' && ['127.0.0.1', 'localhost', '[::1]'].includes(url.hostname)))
|
||||
|| url.username || url.password || url.search || url.hash
|
||||
|| value.scope !== 'makelore-agents' || value.token_type !== 'bearer'
|
||||
|| typeof value.expires_at !== 'number' || value.expires_at * 1000 <= Date.now()
|
||||
|| value.expires_at * 1000 > Date.now() + 300000) {
|
||||
|| typeof value.expires_at !== 'number' || !Number.isSafeInteger(value.expires_at)
|
||||
|| value.expires_at * 1000 <= Date.now()) {
|
||||
throw new CloudAgentsError(502, 'cloud_service_unavailable');
|
||||
}
|
||||
this.cached = {
|
||||
binding, accessToken: textField(value.access_token, 8192),
|
||||
apiBaseUrl: url.toString().replace(/\/+$/, ''), expiresAt: value.expires_at * 1000,
|
||||
apiBaseUrl: url.toString().replace(/\/+$/, ''),
|
||||
// The issuer and this computer have independent clocks. Cap local reuse
|
||||
// instead of rejecting a valid five-minute credential for slight skew.
|
||||
// Yuxi remains responsible for enforcing the credential's actual expiry.
|
||||
expiresAt: Math.min(value.expires_at * 1000, Date.now() + 300000),
|
||||
};
|
||||
return this.cached;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user