Compare commits
6 Commits
fix/telegr
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
09be5d45d5 | ||
|
|
3fbf99d725 | ||
|
|
37e295fc02 | ||
|
|
da71eaebd2 | ||
|
|
8e5a684445 | ||
|
|
b05d57964b |
@ -4,6 +4,7 @@ import {
|
||||
LineConfigSchema,
|
||||
processLineMessage,
|
||||
type ChannelPlugin,
|
||||
type ChannelStatusIssue,
|
||||
type OpenClawConfig,
|
||||
type LineConfig,
|
||||
type LineChannelData,
|
||||
@ -560,19 +561,26 @@ export const linePlugin: ChannelPlugin<ResolvedLineAccount> = {
|
||||
lastStopAt: null,
|
||||
lastError: null,
|
||||
},
|
||||
collectStatusIssues: ({ account }) => {
|
||||
const issues: Array<{ level: "error" | "warning"; message: string }> = [];
|
||||
if (!account.channelAccessToken?.trim()) {
|
||||
issues.push({
|
||||
level: "error",
|
||||
message: "LINE channel access token not configured",
|
||||
});
|
||||
}
|
||||
if (!account.channelSecret?.trim()) {
|
||||
issues.push({
|
||||
level: "error",
|
||||
message: "LINE channel secret not configured",
|
||||
});
|
||||
collectStatusIssues: (accounts) => {
|
||||
const issues: ChannelStatusIssue[] = [];
|
||||
for (const account of accounts) {
|
||||
const accountId = account.accountId ?? DEFAULT_ACCOUNT_ID;
|
||||
if (!account.channelAccessToken?.trim()) {
|
||||
issues.push({
|
||||
channel: "line",
|
||||
accountId,
|
||||
kind: "config",
|
||||
message: "LINE channel access token not configured",
|
||||
});
|
||||
}
|
||||
if (!account.channelSecret?.trim()) {
|
||||
issues.push({
|
||||
channel: "line",
|
||||
accountId,
|
||||
kind: "config",
|
||||
message: "LINE channel secret not configured",
|
||||
});
|
||||
}
|
||||
}
|
||||
return issues;
|
||||
},
|
||||
|
||||
@ -52,11 +52,39 @@ describe("buildAuthHealthSummary", () => {
|
||||
);
|
||||
|
||||
expect(statuses["anthropic:ok"]).toBe("ok");
|
||||
expect(statuses["anthropic:expiring"]).toBe("expiring");
|
||||
expect(statuses["anthropic:expired"]).toBe("expired");
|
||||
// OAuth credentials with refresh tokens are auto-renewable, so they report "ok"
|
||||
expect(statuses["anthropic:expiring"]).toBe("ok");
|
||||
expect(statuses["anthropic:expired"]).toBe("ok");
|
||||
expect(statuses["anthropic:api"]).toBe("static");
|
||||
|
||||
const provider = summary.providers.find((entry) => entry.provider === "anthropic");
|
||||
expect(provider?.status).toBe("expired");
|
||||
expect(provider?.status).toBe("ok");
|
||||
});
|
||||
|
||||
it("reports expired for OAuth without a refresh token", () => {
|
||||
vi.spyOn(Date, "now").mockReturnValue(now);
|
||||
const store = {
|
||||
version: 1,
|
||||
profiles: {
|
||||
"google:no-refresh": {
|
||||
type: "oauth" as const,
|
||||
provider: "google-antigravity",
|
||||
access: "access",
|
||||
refresh: "",
|
||||
expires: now - 10_000,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const summary = buildAuthHealthSummary({
|
||||
store,
|
||||
warnAfterMs: DEFAULT_OAUTH_WARN_MS,
|
||||
});
|
||||
|
||||
const statuses = Object.fromEntries(
|
||||
summary.profiles.map((profile) => [profile.profileId, profile.status]),
|
||||
);
|
||||
|
||||
expect(statuses["google:no-refresh"]).toBe("expired");
|
||||
});
|
||||
});
|
||||
|
||||
@ -123,7 +123,16 @@ function buildProfileHealth(params: {
|
||||
};
|
||||
}
|
||||
|
||||
const { status, remainingMs } = resolveOAuthStatus(credential.expires, now, warnAfterMs);
|
||||
const hasRefreshToken = typeof credential.refresh === "string" && credential.refresh.length > 0;
|
||||
const { status: rawStatus, remainingMs } = resolveOAuthStatus(
|
||||
credential.expires,
|
||||
now,
|
||||
warnAfterMs,
|
||||
);
|
||||
// OAuth credentials with a valid refresh token auto-renew on first API call,
|
||||
// so don't warn about access token expiration.
|
||||
const status =
|
||||
hasRefreshToken && (rawStatus === "expired" || rawStatus === "expiring") ? "ok" : rawStatus;
|
||||
return {
|
||||
profileId,
|
||||
provider: credential.provider,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user