Skip to content

Commit eaafe0f

Browse files
committed
fix(core): use xAI device expiration
1 parent f791e52 commit eaafe0f

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

  • packages/core/src/plugin/provider

packages/core/src/plugin/provider/xai.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -135,13 +135,16 @@ const device = {
135135
).pipe(
136136
Effect.flatMap((value) =>
137137
Clock.currentTimeMillis.pipe(
138-
Effect.map((created) => ({
139-
mode: "auto" as const,
140-
url: value.verification_uri_complete ?? value.verification_uri,
141-
instructions: `Open ${value.verification_uri} on any device and enter code: ${value.user_code}`,
142-
expiresAt: created + positiveSeconds(value.expires_in, 300) * 1000,
143-
callback: poll(value).pipe(Effect.flatMap((tokens) => credential(deviceMethodID, tokens))),
144-
})),
138+
Effect.map((created) => {
139+
const lifetime = positiveSeconds(value.expires_in, 0)
140+
return {
141+
mode: "auto" as const,
142+
url: value.verification_uri_complete ?? value.verification_uri,
143+
instructions: `Open ${value.verification_uri} on any device and enter code: ${value.user_code}`,
144+
...(lifetime ? { expiresAt: created + lifetime * 1000 } : {}),
145+
callback: poll(value).pipe(Effect.flatMap((tokens) => credential(deviceMethodID, tokens))),
146+
}
147+
}),
145148
),
146149
),
147150
),

0 commit comments

Comments
 (0)