INNER CODE UNIT · TypeScript

renew

synthetic-sciences/openscience · backend/cli/src/auth/index.ts:164

  export async function renew(key: string, previous: Oauth, info: Oauth): Promise<boolean> {
    const next = Oauth.parse(info)
    if (
      (previous.accountId !== undefined && previous.accountId !== next.accountId) ||
      previous.enterpriseUrl !== next.enterpriseUrl
    ) {
      throw new Error("OAuth refresh changed the connected account; reconnect the provider.")
    }
    const result = await CredentialLifecycle.update(async () => {
      const current = Oauth.safeParse((await JsonStore.read(filepath))[key])
      if (
        !current.success ||
        current.data.refresh !== previous.refresh ||
        current.data.access !== previous.access ||
        current.data.expires !== previous.expires ||
        current.data.accountId !== previous.accountId ||
        current.data.enterpriseUrl !== previous.enterpriseUrl
      )

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…