fix(core): honor OAuth attempt expiration (#37557)
This commit is contained in:
parent
fafb04ed59
commit
987242b3e8
4 changed files with 53 additions and 8 deletions
|
|
@ -133,12 +133,20 @@ const device = {
|
|||
},
|
||||
Device,
|
||||
).pipe(
|
||||
Effect.map((value) => ({
|
||||
mode: "auto" as const,
|
||||
url: value.verification_uri_complete ?? value.verification_uri,
|
||||
instructions: `Open ${value.verification_uri} on any device and enter code: ${value.user_code}`,
|
||||
callback: poll(value).pipe(Effect.flatMap((tokens) => credential(deviceMethodID, tokens))),
|
||||
})),
|
||||
Effect.flatMap((value) =>
|
||||
Clock.currentTimeMillis.pipe(
|
||||
Effect.map((created) => {
|
||||
const lifetime = positiveSeconds(value.expires_in, 0)
|
||||
return {
|
||||
mode: "auto" as const,
|
||||
url: value.verification_uri_complete ?? value.verification_uri,
|
||||
instructions: `Open ${value.verification_uri} on any device and enter code: ${value.user_code}`,
|
||||
...(lifetime ? { expiresAt: created + lifetime * 1000 } : {}),
|
||||
callback: poll(value).pipe(Effect.flatMap((tokens) => credential(deviceMethodID, tokens))),
|
||||
}
|
||||
}),
|
||||
),
|
||||
),
|
||||
),
|
||||
refresh: (value) => refresh(deviceMethodID, Credential.OAuth.make({ ...value, methodID: deviceMethodID })),
|
||||
} satisfies IntegrationOAuthMethodRegistration
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue