(value: unknown)
| 26 | } |
| 27 | |
| 28 | export function parseCodexOauthAuth(value: unknown): CodexOauthAuth | null { |
| 29 | if (!isPlainObject(value)) { |
| 30 | return null; |
| 31 | } |
| 32 | |
| 33 | const type = value.type; |
| 34 | const access = value.access; |
| 35 | const refresh = value.refresh; |
| 36 | const expires = value.expires; |
| 37 | const accountId = value.accountId; |
| 38 | |
| 39 | if (type !== "oauth") return null; |
| 40 | if (typeof access !== "string" || !access) return null; |
| 41 | if (typeof refresh !== "string" || !refresh) return null; |
| 42 | if (typeof expires !== "number" || !Number.isFinite(expires)) return null; |
| 43 | |
| 44 | if (typeof accountId !== "undefined") { |
| 45 | if (typeof accountId !== "string" || !accountId) return null; |
| 46 | } |
| 47 | |
| 48 | return { type: "oauth", access, refresh, expires, accountId }; |
| 49 | } |
| 50 | |
| 51 | export function isCodexOauthAuthExpired( |
| 52 | auth: CodexOauthAuth, |
no test coverage detected