mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 22:44:36 +00:00
follow-up: align ingress, atomic paths, and channel tests with credential semantics (#33733)
Merged via squash.
Prepared head SHA: c290c2ab6a
Co-authored-by: joshavant <830519+joshavant@users.noreply.github.com>
Co-authored-by: joshavant <830519+joshavant@users.noreply.github.com>
Reviewed-by: @joshavant
This commit is contained in:
@@ -1,9 +1,14 @@
|
||||
import type { OpenClawConfig } from "../config/config.js";
|
||||
import {
|
||||
type AuthCredentialReasonCode,
|
||||
type AuthProfileCredential,
|
||||
type AuthProfileStore,
|
||||
resolveAuthProfileDisplayLabel,
|
||||
} from "./auth-profiles.js";
|
||||
import {
|
||||
evaluateStoredCredentialEligibility,
|
||||
resolveTokenExpiryState,
|
||||
} from "./auth-profiles/credential-state.js";
|
||||
|
||||
export type AuthProfileSource = "store";
|
||||
|
||||
@@ -14,6 +19,7 @@ export type AuthProfileHealth = {
|
||||
provider: string;
|
||||
type: "oauth" | "token" | "api_key";
|
||||
status: AuthProfileHealthStatus;
|
||||
reasonCode?: AuthCredentialReasonCode;
|
||||
expiresAt?: number;
|
||||
remainingMs?: number;
|
||||
source: AuthProfileSource;
|
||||
@@ -113,11 +119,26 @@ function buildProfileHealth(params: {
|
||||
}
|
||||
|
||||
if (credential.type === "token") {
|
||||
const expiresAt =
|
||||
typeof credential.expires === "number" && Number.isFinite(credential.expires)
|
||||
? credential.expires
|
||||
: undefined;
|
||||
if (!expiresAt || expiresAt <= 0) {
|
||||
const eligibility = evaluateStoredCredentialEligibility({
|
||||
credential,
|
||||
now,
|
||||
});
|
||||
if (!eligibility.eligible) {
|
||||
const status: AuthProfileHealthStatus =
|
||||
eligibility.reasonCode === "expired" ? "expired" : "missing";
|
||||
return {
|
||||
profileId,
|
||||
provider: credential.provider,
|
||||
type: "token",
|
||||
status,
|
||||
reasonCode: eligibility.reasonCode,
|
||||
source,
|
||||
label,
|
||||
};
|
||||
}
|
||||
const expiryState = resolveTokenExpiryState(credential.expires, now);
|
||||
const expiresAt = expiryState === "valid" ? credential.expires : undefined;
|
||||
if (!expiresAt) {
|
||||
return {
|
||||
profileId,
|
||||
provider: credential.provider,
|
||||
@@ -133,6 +154,7 @@ function buildProfileHealth(params: {
|
||||
provider: credential.provider,
|
||||
type: "token",
|
||||
status,
|
||||
reasonCode: status === "expired" ? "expired" : undefined,
|
||||
expiresAt,
|
||||
remainingMs,
|
||||
source,
|
||||
|
||||
Reference in New Issue
Block a user