MCPcopy Index your code
hub / github.com/coder/mux / parseCodexOauthAuth

Function parseCodexOauthAuth

src/node/utils/codexOauthAuth.ts:28–49  ·  view source on GitHub ↗
(value: unknown)

Source from the content-addressed store, hash-verified

26}
27
28export 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
51export function isCodexOauthAuthExpired(
52 auth: CodexOauthAuth,

Callers 6

hasAnyConfiguredProviderFunction · 0.90
readStoredAuthMethod · 0.90
_createModelCoreMethod · 0.90
getConfigMethod · 0.90

Calls 1

isPlainObjectFunction · 0.70

Tested by

no test coverage detected