mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-18 21:22:28 +03:00
fix(oauth): treat Kiro social poll status as alias of error for pending states (#10620)
Kiro's device poll endpoint reports progress in a `status` field (e.g. `authorization_pending`), but `classifyKiroSocialPoll()` only inspected `data.error`. This caused every pre-authorization poll to fall through to the terminal `invalid_token_response` error, making social login impossible for Kiro AI and Amazon Q via Google/GitHub. Changes: - Add `status` field to `KiroSocialPollData` type - Update `classifyKiroSocialPoll()` to check `data.status` as fallback for `data.error` when detecting pending states - Add tests covering `status`-based pending detection and precedence Closes #10618
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
export type KiroSocialPollData = {
|
||||
error?: unknown;
|
||||
/** Kiro reports poll progress here (e.g. "authorization_pending"), not in `error`. */
|
||||
status?: unknown;
|
||||
accessToken?: unknown;
|
||||
refreshToken?: unknown;
|
||||
};
|
||||
@@ -26,8 +28,9 @@ export function classifyKiroSocialPoll(
|
||||
responseStatus: number,
|
||||
data: KiroSocialPollData
|
||||
): KiroSocialPollOutcome {
|
||||
if (data.error === "authorization_pending" || data.error === "slow_down") {
|
||||
return { kind: "pending", error: data.error };
|
||||
const progress = data.error ?? data.status;
|
||||
if (progress === "authorization_pending" || progress === "slow_down") {
|
||||
return { kind: "pending", error: progress as "authorization_pending" | "slow_down" };
|
||||
}
|
||||
|
||||
if (!responseOk || data.error) {
|
||||
|
||||
@@ -21,6 +21,26 @@ test("classifyKiroSocialPoll keeps only documented pending states retryable", ()
|
||||
});
|
||||
});
|
||||
|
||||
test("classifyKiroSocialPoll treats status as alias of error for pending states", () => {
|
||||
// Kiro upstream returns progress in `status`, not `error`
|
||||
assert.deepEqual(classifyKiroSocialPoll(true, 200, { status: "authorization_pending" }), {
|
||||
kind: "pending",
|
||||
error: "authorization_pending",
|
||||
});
|
||||
assert.deepEqual(classifyKiroSocialPoll(true, 200, { status: "slow_down" }), {
|
||||
kind: "pending",
|
||||
error: "slow_down",
|
||||
});
|
||||
// error takes precedence over status if both present
|
||||
assert.deepEqual(
|
||||
classifyKiroSocialPoll(true, 200, { error: "slow_down", status: "authorization_pending" }),
|
||||
{
|
||||
kind: "pending",
|
||||
error: "slow_down",
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
test("classifyKiroSocialPoll stops on denied, expired and malformed responses", () => {
|
||||
assert.deepEqual(classifyKiroSocialPoll(false, 403, { error: "access_denied" }), {
|
||||
kind: "error",
|
||||
|
||||
Reference in New Issue
Block a user