{
  "id": "task_libraries:oauth/javascript",
  "path": "/exapedia/javascript-oauth-libraries",
  "template": {
    "id": "task_libraries",
    "version": 4
  },
  "title": "JavaScript OAuth clients libraries",
  "answer": [
    {
      "t": "text",
      "text": "JavaScript OAuth libraries run the OAuth and OpenID Connect flows that let an app act for a user at another service. A client sends the user to the provider's authorization page and exchanges the returned code for tokens. These libraries let apps offer sign-in with an identity provider and let agents call APIs with a user's delegated permission."
    }
  ],
  "breadcrumb": [
    {
      "label": "Tools"
    },
    {
      "label": "JavaScript OAuth clients libraries"
    }
  ],
  "sections": [
    {
      "id": "libraries_popularity",
      "anchor": "popularity",
      "heading": "Popularity",
      "blocks": [
        {
          "b": "table",
          "columns": [
            "Library",
            "Monthly downloads",
            "Stars",
            "Last release",
            "License"
          ],
          "rows": [
            [
              [
                {
                  "t": "link",
                  "href": "#oauth-webapi",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F127"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F128"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F134"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F131"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F129"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#openid-client",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F142"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F143"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F149"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F146"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F144"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#oauth",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F157"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F158"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F166"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F161"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F159"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#oidc-client-ts",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F174"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F175"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F183"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F178"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F176"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#passport-oauthtwo",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F191"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F192"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F200"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F195"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F193"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#arctic",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F208"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F209"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F217"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F212"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F210"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#react-oidc-context",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F225"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F226"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F234"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F229"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F227"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#simple-oauth",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F238"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F239"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F245"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F242"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F240"
                }
              ]
            ]
          ],
          "variant": "pop",
          "caption": [
            {
              "t": "text",
              "text": "Downloads: "
            },
            {
              "t": "text",
              "text": "npm"
            },
            {
              "t": "text",
              "text": ", last thirty days. Stars and releases: GitHub. Amber: no release in over a year."
            }
          ]
        }
      ],
      "note": [
        {
          "t": "link",
          "href": "#oauth-webapi",
          "label": [
            {
              "t": "fact",
              "fact": "F1"
            }
          ]
        },
        {
          "t": "text",
          "text": " has the most monthly downloads in this comparison, at "
        },
        {
          "t": "fact",
          "fact": "F2"
        },
        {
          "t": "text",
          "text": "."
        }
      ]
    },
    {
      "id": "libraries_capabilities",
      "anchor": "capabilities",
      "heading": "Capabilities",
      "blocks": [
        {
          "b": "table",
          "columns": [
            "Library",
            "Metadata discovery",
            "PKCE generation"
          ],
          "rows": [
            [
              [
                {
                  "t": "link",
                  "href": "#oauth-webapi",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F127"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F135"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F136"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#openid-client",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F142"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F150"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F151"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#oauth",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F157"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F167"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F168"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#oidc-client-ts",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F174"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F184"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F185"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#passport-oauthtwo",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F191"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F201"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F202"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#arctic",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F208"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F218"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F219"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#react-oidc-context",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F225"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F235"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F236"
                }
              ]
            ],
            [
              [
                {
                  "t": "link",
                  "href": "#simple-oauth",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F238"
                    }
                  ]
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F246"
                }
              ],
              [
                {
                  "t": "fact",
                  "fact": "F247"
                }
              ]
            ]
          ],
          "variant": "cap"
        }
      ]
    },
    {
      "id": "libraries_entries",
      "anchor": "libraries",
      "heading": "Libraries",
      "blocks": [
        {
          "b": "entry",
          "anchor": "oauth-webapi",
          "name": [
            {
              "t": "fact",
              "fact": "F127"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/panva/oauth4webapi"
            },
            {
              "label": "npm",
              "href": "https://www.npmjs.com/package/oauth4webapi"
            },
            {
              "label": "Docs",
              "href": "https://api.github.com/repos/panva/oauth4webapi/readme"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F12"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F128"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F134"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F130"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F129"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://api.github.com/repos/panva/oauth4webapi/readme",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F127"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F13"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F14"
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F15"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F16"
                }
              ]
            }
          ],
          "cons": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F17"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F18"
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F19"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F20"
                }
              ]
            }
          ],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F140"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F141"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/akuity/kargo",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F140"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "javascript",
              "code": "const login = async () => {\n    if (!as?.authorization_endpoint) {\n      return;\n    }\n\n    const code_verifier = generateRandomCodeVerifier();\n    sessionStorage.setItem(codeVerifierKey, code_verifier);\n    const state = generateRandomState();\n    sessionStorage.setItem(stateKey, state);\n    sessionStorage.setItem(platformRedirectKey, window.location.search);\n\n    const code_challenge = await calculatePKCECodeChallenge(code_verifier);\n    const url = new URL(as.authorization_endpoint);\n    url.searchParams.set('client_id', client.client_id);\n    url.searchParams.set('code_challenge', code_challenge);\n    url.searchParams.set('code_challenge_method', 'S256');\n    url.searchParams.set('redirect_uri', redirectURI);\n    url.searchParams.set('response_type', 'code');\n    url.searchParams.set('scope', getOIDCScopes(oidcConfig, as).join(' '));\n    url.searchParams.set('state', state);\n\n    window.location.replace(url.toString());\n  };\n",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/akuity/kargo/blob/a307deca88fd3efe39a0be89e3c45e82fe5f862f/ui/src/features/auth/oidc-login.tsx",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F139"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=Projects%20using%20oauth4webapi%20for%20OAuth%20client%20flows&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F127"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "javascript",
              "code": "import * as oauth from \"oauth4webapi\";\nconst issuer = new URL(process.env.OAUTH_ISSUER);\nconst response = await oauth.discoveryRequest(issuer);\nconst metadata = await oauth.processDiscoveryResponse(issuer, response);\nconsole.log(metadata.authorization_endpoint);\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://api.github.com/repos/panva/oauth4webapi/contents/src/index.ts",
                  "label": [
                    {
                      "t": "text",
                      "text": "client_credentials.ts"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F132"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "openid-client",
          "name": [
            {
              "t": "fact",
              "fact": "F142"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/panva/openid-client"
            },
            {
              "label": "npm",
              "href": "https://www.npmjs.com/package/openid-client"
            },
            {
              "label": "Docs",
              "href": "https://api.github.com/repos/panva/openid-client/readme"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F38"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F143"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F149"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F145"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F144"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://api.github.com/repos/panva/openid-client/readme",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F142"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F39"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F40"
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F41"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F42"
                }
              ]
            }
          ],
          "cons": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F43"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F44"
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F45"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F46"
                }
              ]
            }
          ],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F155"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F156"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/immich-app/immich",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F155"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "javascript",
              "code": "async authorize(config: OAuthConfig, redirectUrl: string, state?: string, codeChallenge?: string) {\n    const client = await this.getClient(config);\n    state ??= randomState();\n\n    let codeVerifier: string | null;\n    if (codeChallenge) {\n      codeVerifier = null;\n    } else {\n      codeVerifier = randomPKCECodeVerifier();\n      codeChallenge = await calculatePKCECodeChallenge(codeVerifier);\n    }\n\n    const params: Record<string, string> = {\n      redirect_uri: redirectUrl,\n      scope: config.scope,\n      state,\n    };\n\n    if (config.prompt) {\n      params.prompt = config.prompt;\n    }\n\n    if (client.serverMetadata().supportsPKCE()) {\n      params.code_challenge = codeChallenge;\n      params.code_challenge_method = 'S256';\n    }\n\n    const url = buildAuthorizationUrl(client, params).href;\n\n    return { url, state, codeVerifier };\n  }\n",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/immich-app/immich/blob/ff445d5fda8bf396e769df8977c316726dc25c9c/server/src/repositories/oauth.repository.ts",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F154"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=Projects%20using%20openid-client%20for%20OAuth%20client%20flows&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F142"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "javascript",
              "code": "import * as client from \"openid-client\";\nconst config = await client.discovery(new URL(process.env.OAUTH_ISSUER), process.env.OAUTH_CLIENT_ID);\nconsole.log(config.serverMetadata().issuer);\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://api.github.com/repos/panva/openid-client/readme",
                  "label": [
                    {
                      "t": "text",
                      "text": "oauth.ts"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F147"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "oauth",
          "name": [
            {
              "t": "fact",
              "fact": "F157"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/ciaranj/node-oauth"
            },
            {
              "label": "npm",
              "href": "https://www.npmjs.com/package/oauth"
            },
            {
              "label": "Docs",
              "href": "https://api.github.com/repos/ciaranj/node-oauth/readme"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F164"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F158"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F166"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F160"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F159"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://api.github.com/repos/ciaranj/node-oauth/readme",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F157"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [],
          "cons": [],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F172"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F173"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/gitpod-io/gitpod",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F172"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "javascript",
              "code": "protected patch_getOAuthAccessToken() {\n    const oauth2 = this._oauth2;\n    const _oauth2_getOAuthAccessToken = oauth2.getOAuthAccessToken as (\n        code: string,\n        params: any,\n        callback: oauth2tokenCallback,\n    ) => void;\n    (oauth2 as any).getOAuthAccessToken = (code: string, params: any, callback: oauth2tokenCallback) => {\n        const patchedCallback: oauth2tokenCallback = (err, accessToken, refreshToken, params) => {\n            if (err) {\n                return callback(err, null as any, null as any, null as any);\n            }\n            if (!accessToken) {\n                return callback(\n                    {\n                        statusCode: 400,\n                        data: JSON.stringify(params),\n                    },\n                    null as any,\n                    null as any,\n                    null as any,\n                );\n            }\n            callback(null as any, accessToken, refreshToken, params);\n        };\n        _oauth2_getOAuthAccessToken.call(oauth2, code, params, patchedCallback);\n    };\n}\n",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/gitpod-io/gitpod/blob/beb925e048afccd5ebaddf367dec18b48d661790/components/server/src/auth/generic-auth-provider.ts",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F171"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=oauth%20GitHub%20projects",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F157"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "javascript",
              "code": "const { OAuth2 } = require(\"oauth\");\nconst client = new OAuth2(process.env.OAUTH_CLIENT_ID, null, process.env.OAUTH_BASE_URL, \"/authorize\", \"/token\");\nconst state = require(\"node:crypto\").randomBytes(32).toString(\"hex\");\nconsole.log(client.getAuthorizeUrl({ redirect_uri: process.env.OAUTH_REDIRECT_URI, response_type: \"code\", state }));\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://api.github.com/repos/ciaranj/node-oauth/contents/lib/oauth2.js",
                  "label": [
                    {
                      "t": "text",
                      "text": "README.md"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F162"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "oidc-client-ts",
          "name": [
            {
              "t": "fact",
              "fact": "F174"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/authts/oidc-client-ts"
            },
            {
              "label": "npm",
              "href": "https://www.npmjs.com/package/oidc-client-ts"
            },
            {
              "label": "Docs",
              "href": "https://api.github.com/repos/authts/oidc-client-ts/readme"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F181"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F175"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F183"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F177"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F176"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://api.github.com/repos/authts/oidc-client-ts/readme",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F174"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [],
          "cons": [],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F189"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F190"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/authts/react-oidc-context",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F189"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "javascript",
              "code": "export const AuthProvider = (props: AuthProviderProps): React.JSX.Element => {\n    const {\n        children,\n\n        onSigninCallback,\n        skipSigninCallback,\n\n        matchSignoutCallback,\n        onSignoutCallback,\n\n        onRemoveUser,\n\n        userManager: userManagerProp = null,\n        ...userManagerSettings\n    } = props;\n\n    const [userManager] = React.useState(() => {\n        return userManagerProp ??\n            (UserManagerImpl\n                ? new UserManagerImpl(userManagerSettings as UserManagerSettings)\n                : ({ settings: userManagerSettings } as UserManager));\n    });\n\n    const [state, dispatch] = React.useReducer(reducer, initialAuthState);\n    const userManagerContext = React.useMemo(\n        () =>\n            Object.assign(\n                {\n                    settings: userManager.settings,\n                    events: userManager.events,\n                },\n                Object.fromEntries(\n                    userManagerContextKeys.map((key) => [\n                        key,\n                        userManager[key]?.bind(userManager) ??\n                        unsupportedEnvironment(key),\n                    ]),\n                ) as Pick<UserManager, typeof userManagerContextKeys[number]>,\n                Object.fromEntries(\n                    navigatorKeys.map((key) => [\n                        key,\n                        userManager[key]\n                            ? async (args: ProcessResourceOwnerPasswordCredentialsArgs & never[]) => {\n                                dispatch({\n                                    type: \"NAVIGATOR_INIT\",\n                                    method: key,\n                                });\n                                try {\n                                    return await userManager[key](args);\n                                } catch (error) {\n                                    dispatch({\n                                        type: \"ERROR\",\n                                        error: {\n                                            ...normalizeError(error, `Unknown error while executing ${key}(...).`),\n                                            source: key,\n                                            args: args,\n                                        } as ErrorContext,\n                                    });\n                                    return null;\n                                } finally {\n                                    dispatch({ type: \"NAVIGATOR_CLOSE\" });\n                                }\n                            }\n                            : unsupportedEnvironment(key),\n                    ]),\n                ) as Pick<UserManager, typeof navigatorKeys[number]>,\n            ),\n        [userManager],\n    );\n    const didInitialize = React.useRef(false);\n\n    React.useEffect(() => {\n        if (!userManager || didInitialize.current) {\n            return;\n        }\n        didInitialize.current = true;\n\n        void (async (): Promise<void> => {\n            // sign-in\n            try {\n                let user: User | undefined | null = null;\n\n                // check if returning back from authority server\n                if (hasAuthParams() && !skipSigninCallback) {\n                    user = await userManager.signinCallback();\n                    if (onSigninCallback) await onSigninCallback(user);\n                }\n                user = !user ? await userManager.getUser() : user;\n                dispatch({ type: \"INITIALISED\", user });\n            } catch (error) {\n                dispatch({\n                    type: \"ERROR\",\n                    error: signinError(error),\n                });\n            }\n\n            // sign-out\n            try {\n                if (matchSignoutCallback && matchSignoutCallback(userManager.settings)) {\n                    const resp = await userManager.signoutCallback();\n                    if (onSignoutCallback) await onSignoutCallback(resp);\n                }\n            } catch (error) {\n                dispatch({\n                    type: \"ERROR\",\n                    error: signoutError(error),\n                });\n            }\n        })();\n    }, [userManager, skipSigninCallback, onSigninCallback, onSignoutCallback, matchSignoutCallback]);\n\n    // register to userManager events\n    React.useEffect(() => {\n        if (!userManager) return undefined;\n        // event UserLoaded (e.g. initial load, silent renew success)\n        const handleUserLoaded = (user: User) => {\n            dispatch({ type: \"USER_LOADED\", user });\n        };\n        userManager.events.addUserLoaded(handleUserLoaded);\n\n        // event UserUnloaded (e.g. userManager.removeUser)\n        const handleUserUnloaded = () => {\n            dispatch({ type: \"USER_UNLOADED\" });\n        };\n        userManager.events.addUserUnloaded(handleUserUnloaded);\n\n        // event UserSignedOut (e.g. user was signed out in background (checkSessionIFrame option))\n        const handleUserSignedOut = () => {\n            dispatch({ type: \"USER_SIGNED_OUT\" });\n        };\n        userManager.events.addUserSignedOut(handleUserSignedOut);\n\n        // event SilentRenewError (silent renew error)\n        const handleSilentRenewError = (error: Error) => {\n            dispatch({\n                type: \"ERROR\",\n                error: renewSilentError(error),\n            });\n        };\n        userManager.events.addSilentRenewError(handleSilentRenewError);\n\n        return () => {\n            userManager.events.removeUserLoaded(handleUserLoaded);\n            userManager.events.removeUserUnloaded(handleUserUnloaded);\n            userManager.events.removeUserSignedOut(handleUserSignedOut);\n            userManager.events.removeSilentRenewError(handleSilentRenewError);\n        };\n    }, [userManager]);\n\n    const removeUser = React.useCallback(async () => {\n        if (!userManager) unsupportedEnvironment(\"removeUser\");\n        await userManager.removeUser();\n        if (onRemoveUser) await onRemoveUser();\n    }, [userManager, onRemoveUser]);\n\n    const contextValue = React.useMemo(() => {\n        return {\n            ...state,\n            ...userManagerContext,\n            removeUser,\n        };\n    }, [state, userManagerContext, removeUser]);\n\n    return (\n        <AuthContext.Provider value={contextValue}>\n            {children}\n        </AuthContext.Provider>\n    );\n};\n",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/authts/react-oidc-context/blob/80e60ae0b538afdb6e0be7016ec3430104b1bf42/src/AuthProvider.tsx",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F188"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=oidc-client-ts%20GitHub%20projects",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F174"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "javascript",
              "code": "import { UserManager } from \"oidc-client-ts\";\nconst manager = new UserManager({ authority: \"https://issuer.example.com\", client_id: \"registered-client\", redirect_uri: window.location.origin + \"/callback\", response_type: \"code\", scope: \"openid profile\" });\nawait manager.signinRedirect();\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://authts.github.io/oidc-client-ts/classes/UserManager.html",
                  "label": [
                    {
                      "t": "text",
                      "text": "README.md"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F179"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "passport-oauthtwo",
          "name": [
            {
              "t": "fact",
              "fact": "F191"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/jaredhanson/passport-oauth2"
            },
            {
              "label": "npm",
              "href": "https://www.npmjs.com/package/passport-oauth2"
            },
            {
              "label": "Docs",
              "href": "https://api.github.com/repos/jaredhanson/passport-oauth2/readme"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F198"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F192"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F200"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F194"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F193"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://api.github.com/repos/jaredhanson/passport-oauth2/readme",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F191"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [],
          "cons": [],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F206"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F207"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/jaredhanson/passport-google-oauth2",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F206"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "javascript",
              "code": "function Strategy(options, verify) {\n  options = options || {};\n  options.authorizationURL = options.authorizationURL || 'https://accounts.google.com/o/oauth2/v2/auth';\n  options.tokenURL = options.tokenURL || 'https://www.googleapis.com/oauth2/v4/token';\n\n  OAuth2Strategy.call(this, options, verify);\n  this.name = 'google';\n  this._userProfileURL = options.userProfileURL || 'https://www.googleapis.com/oauth2/v3/userinfo';\n  \n  var url = uri.parse(this._userProfileURL);\n  if (url.pathname.indexOf('/userinfo') == (url.pathname.length - '/userinfo'.length)) {\n    this._userProfileFormat = 'openid';\n  } else {\n    this._userProfileFormat = 'google+'; // Google Sign-In\n  }\n}\n",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/jaredhanson/passport-google-oauth2/blob/79f9ed6878f1d11150243a1429acb7ba3211e239/lib/strategy.js",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F205"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=passport-oauth2%20GitHub%20projects",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F191"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "javascript",
              "code": "const { Strategy } = require(\"passport-oauth2\");\nconst strategy = new Strategy({ authorizationURL: process.env.OAUTH_AUTHORIZATION_URL, tokenURL: process.env.OAUTH_TOKEN_URL, clientID: process.env.OAUTH_CLIENT_ID, clientSecret: process.env.OAUTH_CLIENT_SECRET, callbackURL: process.env.OAUTH_REDIRECT_URI, state: true }, (_accessToken, _refreshToken, _profile, done) => done(null, false));\nconsole.log(strategy.name);\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://api.github.com/repos/jaredhanson/passport-oauth2/contents/lib/strategy.js",
                  "label": [
                    {
                      "t": "text",
                      "text": "strategy.js"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F196"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "arctic",
          "name": [
            {
              "t": "fact",
              "fact": "F208"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/pilcrowonpaper/arctic"
            },
            {
              "label": "npm",
              "href": "https://www.npmjs.com/package/arctic"
            },
            {
              "label": "Docs",
              "href": "https://api.github.com/repos/pilcrowonpaper/arctic/readme"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F215"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F209"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F217"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F211"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F210"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://api.github.com/repos/pilcrowonpaper/arctic/readme",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F208"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [],
          "cons": [],
          "tabs": [
            {
              "label": [
                {
                  "t": "fact",
                  "fact": "F223"
                }
              ],
              "stars": [
                {
                  "t": "fact",
                  "fact": "F224"
                }
              ],
              "usedBy": [
                {
                  "t": "link",
                  "href": "https://github.com/documenso/documenso",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F223"
                    }
                  ]
                },
                {
                  "t": "text",
                  "text": " "
                }
              ],
              "language": "javascript",
              "code": "export const handleOAuthAuthorizeUrl = async (options: HandleOAuthAuthorizeUrlOptions) => {\n  const { c, clientOptions, redirectPath } = options;\n\n  let prompt = options.prompt ?? 'login';\n\n  if (!clientOptions.clientId || !clientOptions.clientSecret) {\n    throw new AppError(AppErrorCode.NOT_SETUP);\n  }\n\n  const { authorization_endpoint } = await getOpenIdConfiguration(clientOptions.wellKnownUrl, {\n    requiredScopes: clientOptions.scope,\n  });\n\n  const oAuthClient = new OAuth2Client(clientOptions.clientId, clientOptions.clientSecret, clientOptions.redirectUrl);\n\n  const scopes = clientOptions.scope;\n  const state = options.state ?? generateState();\n\n  const codeVerifier = generateCodeVerifier();\n\n  const url = oAuthClient.createAuthorizationURLWithPKCE(\n    authorization_endpoint,\n    state,\n    CodeChallengeMethod.S256,\n    codeVerifier,\n    scopes,\n  );\n\n  // Pass the prompt to the authorization endpoint.\n  if (process.env.NEXT_PRIVATE_OIDC_PROMPT && isOidcPrompt(process.env.NEXT_PRIVATE_OIDC_PROMPT)) {\n    prompt = process.env.NEXT_PRIVATE_OIDC_PROMPT;\n  }\n\n  url.searchParams.set('prompt', prompt);\n\n  setCookie(c, `${clientOptions.id}_oauth_state`, state, {\n    ...sessionCookieOptions,\n    sameSite: 'lax',\n    maxAge: oauthCookieMaxAge,\n  });\n\n  setCookie(c, `${clientOptions.id}_code_verifier`, codeVerifier, {\n    ...sessionCookieOptions,\n    sameSite: 'lax',\n    maxAge: oauthCookieMaxAge,\n  });\n\n  if (redirectPath) {\n    setCookie(c, `${clientOptions.id}_redirect_path`, `${state} ${redirectPath}`, {\n      ...sessionCookieOptions,\n      sameSite: 'lax',\n      maxAge: oauthCookieMaxAge,\n    });\n  }\n\n  return c.json({\n    redirectUrl: url.toString(),\n  });\n};\n",
              "prov": [
                {
                  "t": "link",
                  "href": "https://github.com/documenso/documenso/blob/125ff95097fb10704520cf03ec511a3df188cb4a/packages/auth/server/lib/utils/handle-oauth-authorize-url.ts#L41-L99",
                  "label": [
                    {
                      "t": "fact",
                      "fact": "F222"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=arctic%20GitHub%20projects",
                  "label": [
                    {
                      "t": "text",
                      "text": "More projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F208"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            },
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "javascript",
              "code": "import { OAuth2Client, CodeChallengeMethod, generateCodeVerifier, generateState } from \"arctic\";\nconst client = new OAuth2Client(process.env.OAUTH_CLIENT_ID, null, process.env.OAUTH_REDIRECT_URI);\nconst verifier = generateCodeVerifier();\nconst state = generateState();\nconst url = client.createAuthorizationURLWithPKCE(process.env.OAUTH_AUTHORIZATION_URL, state, CodeChallengeMethod.S256, verifier, [\"openid\"]);\nconsole.log(url.href);\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://api.github.com/repos/pilcrowonpaper/arctic/git/blobs/11e455e699111bbc49355c51604d8edbc4fc97e6",
                  "label": [
                    {
                      "t": "text",
                      "text": "README.md"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F213"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "react-oidc-context",
          "name": [
            {
              "t": "fact",
              "fact": "F225"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/authts/react-oidc-context"
            },
            {
              "label": "npm",
              "href": "https://www.npmjs.com/package/react-oidc-context"
            },
            {
              "label": "Docs",
              "href": "https://api.github.com/repos/authts/react-oidc-context/readme"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F232"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F226"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F234"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F228"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F227"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://api.github.com/repos/authts/react-oidc-context/readme",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F225"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [],
          "cons": [],
          "tabs": [
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "javascript",
              "code": "import React from \"react\";\nimport { createRoot } from \"react-dom/client\";\nimport { AuthProvider, useAuth } from \"react-oidc-context\";\nconst host = document.createElement(\"div\");\ndocument.body.append(host);\nfunction Login() { const auth = useAuth(); return <button onClick={() => void auth.signinRedirect()}>Sign in</button>; }\ncreateRoot(host).render(<AuthProvider authority=\"https://issuer.example.com\" client_id=\"registered-client\" redirect_uri={window.location.origin + \"/callback\"} onSigninCallback={() => window.history.replaceState({}, document.title, window.location.pathname)}><Login /></AuthProvider>);\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://api.github.com/repos/authts/react-oidc-context/contents/example/index.tsx",
                  "label": [
                    {
                      "t": "text",
                      "text": "README.md"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=react-oidc-context%20GitHub%20projects",
                  "label": [
                    {
                      "t": "text",
                      "text": "Find projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F225"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F230"
            }
          ]
        },
        {
          "b": "entry",
          "anchor": "simple-oauth",
          "name": [
            {
              "t": "fact",
              "fact": "F238"
            }
          ],
          "links": [
            {
              "label": "GitHub",
              "href": "https://github.com/lelylan/simple-oauth2"
            },
            {
              "label": "npm",
              "href": "https://www.npmjs.com/package/simple-oauth2"
            },
            {
              "label": "Docs",
              "href": "https://api.github.com/repos/lelylan/simple-oauth2/readme"
            }
          ],
          "what": [
            {
              "t": "fact",
              "fact": "F63"
            }
          ],
          "facts": [
            {
              "label": "Downloads / mo",
              "value": [
                {
                  "t": "fact",
                  "fact": "F239"
                }
              ]
            },
            {
              "label": "Stars",
              "value": [
                {
                  "t": "fact",
                  "fact": "F245"
                }
              ]
            },
            {
              "label": "Last release",
              "value": [
                {
                  "t": "fact",
                  "fact": "F241"
                }
              ]
            },
            {
              "label": "License",
              "value": [
                {
                  "t": "fact",
                  "fact": "F240"
                }
              ]
            },
            {
              "label": "Capabilities",
              "value": [
                {
                  "t": "link",
                  "href": "https://api.github.com/repos/lelylan/simple-oauth2/readme",
                  "label": [
                    {
                      "t": "text",
                      "text": "From the "
                    },
                    {
                      "t": "fact",
                      "fact": "F238"
                    },
                    {
                      "t": "text",
                      "text": " docs"
                    }
                  ]
                }
              ]
            }
          ],
          "pros": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F64"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F65"
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F66"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F67"
                }
              ]
            }
          ],
          "cons": [
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F68"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F69"
                }
              ]
            },
            {
              "lead": [
                {
                  "t": "fact",
                  "fact": "F70"
                }
              ],
              "body": [
                {
                  "t": "fact",
                  "fact": "F71"
                }
              ]
            }
          ],
          "tabs": [
            {
              "label": [
                {
                  "t": "text",
                  "text": "Quickstart"
                }
              ],
              "language": "javascript",
              "code": "const { ClientCredentials } = require(\"simple-oauth2\");\nconst client = new ClientCredentials({ client: { id: process.env.OAUTH_CLIENT_ID, secret: process.env.OAUTH_CLIENT_SECRET }, auth: { tokenHost: process.env.OAUTH_TOKEN_HOST, tokenPath: process.env.OAUTH_TOKEN_PATH } });\nclient.getToken({}).then((token) => console.log(token.expired())).catch(console.error);\n",
              "prov": [
                {
                  "t": "text",
                  "text": "From "
                },
                {
                  "t": "link",
                  "href": "https://api.github.com/repos/lelylan/simple-oauth2/contents/API.md",
                  "label": [
                    {
                      "t": "text",
                      "text": "README.md"
                    }
                  ]
                }
              ],
              "more": [
                {
                  "t": "link",
                  "href": "https://dashboard.exa.ai/playground/search?q=Projects%20using%20simple-oauth2%20for%20OAuth%20client%20flows&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D",
                  "label": [
                    {
                      "t": "text",
                      "text": "Find projects using "
                    },
                    {
                      "t": "fact",
                      "fact": "F238"
                    },
                    {
                      "t": "text",
                      "text": " →"
                    }
                  ]
                }
              ]
            }
          ],
          "install": [
            {
              "t": "fact",
              "fact": "F243"
            }
          ]
        }
      ]
    }
  ],
  "questions": [
    {
      "q": "Which JavaScript OAuth library should I use?",
      "a": [
        {
          "t": "link",
          "href": "#openid-client",
          "label": [
            {
              "t": "text",
              "text": "openid-client"
            }
          ]
        },
        {
          "t": "text",
          "text": " suits server code that runs full OAuth and OpenID Connect flows. "
        },
        {
          "t": "link",
          "href": "#oidc-client-ts",
          "label": [
            {
              "t": "text",
              "text": "oidc-client-ts"
            }
          ]
        },
        {
          "t": "text",
          "text": " suits browser apps that manage sign-in and token renewal. "
        },
        {
          "t": "link",
          "href": "#passport-oauthtwo",
          "label": [
            {
              "t": "fact",
              "fact": "F191"
            }
          ]
        },
        {
          "t": "text",
          "text": " suits Express apps that already authenticate through Passport."
        }
      ]
    },
    {
      "q": "What is PKCE?",
      "a": [
        {
          "t": "text",
          "text": "PKCE, or Proof Key for Code Exchange, binds an authorization code to the client that requested it. The client sends a hashed secret with the authorization request and the original secret with the token request. "
        },
        {
          "t": "link",
          "href": "#openid-client",
          "label": [
            {
              "t": "text",
              "text": "openid-client"
            }
          ]
        },
        {
          "t": "text",
          "text": " and "
        },
        {
          "t": "link",
          "href": "#oauth-webapi",
          "label": [
            {
              "t": "fact",
              "fact": "F1"
            }
          ]
        },
        {
          "t": "text",
          "text": " generate PKCE values."
        }
      ]
    },
    {
      "q": "What is openid-client?",
      "a": [
        {
          "t": "link",
          "href": "#openid-client",
          "label": [
            {
              "t": "text",
              "text": "openid-client"
            }
          ]
        },
        {
          "t": "text",
          "text": " is an OAuth and OpenID Connect client for JavaScript runtimes. It handles issuer discovery, authorization URLs, several grant types, and PKCE."
        }
      ]
    },
    {
      "q": "What is react-oidc-context?",
      "a": [
        {
          "t": "link",
          "href": "#react-oidc-context",
          "label": [
            {
              "t": "text",
              "text": "react-oidc-context"
            }
          ]
        },
        {
          "t": "text",
          "text": " wraps oidc-client-ts in a React provider and hooks. It intercepts the sign-in callback and exposes the authentication state to components."
        }
      ]
    },
    {
      "q": "OAuth vs OpenID Connect: what is the difference?",
      "a": [
        {
          "t": "text",
          "text": "OAuth grants an app access to a user's resources at another service. OpenID Connect adds an identity layer on top of OAuth with an ID token that says who the user is."
        }
      ]
    }
  ],
  "facts": {
    "F1": {
      "label": "Library name, oauth4webapi",
      "display": "oauth4webapi",
      "asOf": "2026-11-17"
    },
    "F2": {
      "label": "Monthly downloads, oauth4webapi",
      "display": "94.0M",
      "asOf": "2026-11-15"
    },
    "F3": {
      "label": "License, oauth4webapi",
      "display": "MIT",
      "asOf": "2026-11-17"
    },
    "F4": {
      "label": "Package release, oauth4webapi",
      "display": "3.8.8",
      "asOf": "2026-11-17"
    },
    "F5": {
      "label": "Undated package release, oauth4webapi",
      "display": "v3.8.8",
      "asOf": "2026-11-17"
    },
    "F6": {
      "label": "Repository stars, oauth4webapi",
      "display": "806",
      "asOf": "2026-11-17"
    },
    "F7": {
      "label": "Authorization code, oauth4webapi",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F8": {
      "label": "PKCE helpers, oauth4webapi",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F9": {
      "label": "Token refresh, oauth4webapi",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F10": {
      "label": "Token revocation, oauth4webapi",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F11": {
      "label": "Install, oauth4webapi",
      "display": "npm install oauth4webapi",
      "asOf": "2026-11-17"
    },
    "F12": {
      "label": "What it does, oauth4webapi",
      "display": "Provides low-level OAuth and OpenID Connect request and response routines.",
      "asOf": "2026-11-17"
    },
    "F13": {
      "label": "strengths lead, oauth4webapi",
      "display": "Exposes individual protocol steps",
      "asOf": "2026-11-17"
    },
    "F14": {
      "label": "strengths, oauth4webapi",
      "display": "Build custom clients from separate request and response routines.",
      "asOf": "2026-11-17"
    },
    "F15": {
      "label": "strengths lead, oauth4webapi",
      "display": "Includes token inspection and revocation",
      "asOf": "2026-11-17"
    },
    "F16": {
      "label": "strengths, oauth4webapi",
      "display": "Inspect token status or request revocation through native protocol routines.",
      "asOf": "2026-11-17"
    },
    "F17": {
      "label": "limitations lead, oauth4webapi",
      "display": "Responses need explicit processing",
      "asOf": "2026-11-17"
    },
    "F18": {
      "label": "limitations, oauth4webapi",
      "display": "Pass the grant response to processAuthorizationCodeResponse before consuming its result.",
      "asOf": "2026-11-17"
    },
    "F19": {
      "label": "limitations lead, oauth4webapi",
      "display": "Uses ES modules",
      "asOf": "2026-11-17"
    },
    "F20": {
      "label": "limitations, oauth4webapi",
      "display": "CommonJS loading depends on runtime support for requiring ES modules.",
      "asOf": "2026-11-17"
    },
    "F21": {
      "label": "Quickstart, oauth4webapi",
      "display": "import * as oauth from 'oauth4webapi'\n\n// Prerequisites\n\nlet issuer!: URL // Authorization server's Issuer Identifier URL\nlet algorithm!:\n  | 'oauth2' /* For .well-known/oauth-authorization-server discovery */\n  | 'oidc' /* For .well-known/openid-configuration discovery */\n  | undefined /* Defaults to 'oidc' */\nlet client_id!: string\nlet client_secret!: string\n\n// End of prerequisites\n\nconst as = await oauth\n  .discoveryRequest(issuer, { algorithm })\n  .then((response) => oauth.processDiscoveryResponse(issuer, response))\n\nconst client: oauth.Client = { client_id }\nconst clientAuth = oauth.ClientSecretPost(client_secret)\n\n// Client Credentials Grant Request & Response\nlet access_token: string\n{\n  const parameters = new URLSearchParams()\n  parameters.set('scope', 'api:read')\n\n  const response = await oauth.clientCredentialsGrantRequest(as, client, clientAuth, parameters)\n\n  const result = await oauth.processClientCredentialsResponse(as, client, response)\n\n  console.log('Access Token Response', result)\n  ;({ access_token } = result)\n}\n\n// Protected Resource Request\n{\n  const response = await oauth.protectedResourceRequest(\n    access_token,\n    'GET',\n    new URL('https://rs.example.com/api'),\n  )\n\n  console.log('Protected Resource Response', await response.json())\n}\n",
      "asOf": "2026-11-17"
    },
    "F22": {
      "label": "Project function, oauth4webapi",
      "display": "const login = async () => {\n    if (!as?.authorization_endpoint) {\n      return;\n    }\n\n    const code_verifier = generateRandomCodeVerifier();\n    sessionStorage.setItem(codeVerifierKey, code_verifier);\n    const state = generateRandomState();\n    sessionStorage.setItem(stateKey, state);\n    sessionStorage.setItem(platformRedirectKey, window.location.search);\n\n    const code_challenge = await calculatePKCECodeChallenge(code_verifier);\n    const url = new URL(as.authorization_endpoint);\n    url.searchParams.set('client_id', client.client_id);\n    url.searchParams.set('code_challenge', code_challenge);\n    url.searchParams.set('code_challenge_method', 'S256');\n    url.searchParams.set('redirect_uri', redirectURI);\n    url.searchParams.set('response_type', 'code');\n    url.searchParams.set('scope', getOIDCScopes(oidcConfig, as).join(' '));\n    url.searchParams.set('state', state);\n\n    window.location.replace(url.toString());\n  };\n",
      "asOf": "2026-11-17"
    },
    "F23": {
      "label": "Project function reference, oauth4webapi",
      "display": "oidc-login.tsx · login()",
      "asOf": "2026-11-17"
    },
    "F24": {
      "label": "Project repository, oauth4webapi",
      "display": "akuity/kargo",
      "asOf": "2026-11-17"
    },
    "F25": {
      "label": "Project stars, akuity/kargo",
      "display": "3.8K",
      "asOf": "2026-11-17"
    },
    "F26": {
      "label": "Project push date, akuity/kargo",
      "display": "Nov 2026",
      "asOf": "2026-11-16"
    },
    "F27": {
      "label": "Library name, openid-client",
      "display": "openid-client",
      "asOf": "2026-11-17"
    },
    "F28": {
      "label": "Monthly downloads, openid-client",
      "display": "88.4M",
      "asOf": "2026-11-15"
    },
    "F29": {
      "label": "License, openid-client",
      "display": "MIT",
      "asOf": "2026-11-17"
    },
    "F30": {
      "label": "Package release, openid-client",
      "display": "6.9.0",
      "asOf": "2026-11-17"
    },
    "F31": {
      "label": "Undated package release, openid-client",
      "display": "v6.9.0",
      "asOf": "2026-11-17"
    },
    "F32": {
      "label": "Repository stars, openid-client",
      "display": "2.5K",
      "asOf": "2026-11-17"
    },
    "F33": {
      "label": "Authorization code, openid-client",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F34": {
      "label": "PKCE helpers, openid-client",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F35": {
      "label": "Token refresh, openid-client",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F36": {
      "label": "Token revocation, openid-client",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F37": {
      "label": "Install, openid-client",
      "display": "npm install openid-client",
      "asOf": "2026-11-17"
    },
    "F38": {
      "label": "What it does, openid-client",
      "display": "Provides OAuth and OpenID Connect client flows across JavaScript runtimes.",
      "asOf": "2026-11-17"
    },
    "F39": {
      "label": "strengths lead, openid-client",
      "display": "Discovers authorization server settings",
      "asOf": "2026-11-17"
    },
    "F40": {
      "label": "strengths, openid-client",
      "display": "Use discovery to load server metadata and configure the client.",
      "asOf": "2026-11-17"
    },
    "F41": {
      "label": "strengths lead, openid-client",
      "display": "Includes device authorization",
      "asOf": "2026-11-17"
    },
    "F42": {
      "label": "strengths, openid-client",
      "display": "Display the verification instructions, then poll for tokens after user approval.",
      "asOf": "2026-11-17"
    },
    "F43": {
      "label": "limitations lead, openid-client",
      "display": "Redirect state needs session storage",
      "asOf": "2026-11-17"
    },
    "F44": {
      "label": "limitations, openid-client",
      "display": "Retain the verifier and state until the user returns.",
      "asOf": "2026-11-17"
    },
    "F45": {
      "label": "limitations lead, openid-client",
      "display": "Requires Web Crypto and Fetch",
      "asOf": "2026-11-17"
    },
    "F46": {
      "label": "limitations, openid-client",
      "display": "Choose a runtime that supplies both Web APIs.",
      "asOf": "2026-11-17"
    },
    "F47": {
      "label": "Quickstart, openid-client",
      "display": "import * as client from 'openid-client'\n\n// Prerequisites\n\nlet getCurrentUrl!: (...args: any) => URL\nlet server!: URL // Authorization server's Issuer Identifier URL\nlet clientId!: string\nlet clientSecret!: string\n/**\n * Value used in the authorization request as redirect_uri pre-registered at the\n * Authorization Server.\n */\nlet redirect_uri!: string\n\n// End of prerequisites\n\nlet config = await client.discovery(server, clientId, clientSecret)\n\nlet code_challenge_method = 'S256'\n/**\n * The following (code_verifier and potentially state) MUST be generated for\n * every redirect to the authorization_endpoint. You must store the\n * code_verifier and state in the end-user session such that it can be recovered\n * as the user gets redirected from the authorization server back to your\n * application.\n */\nlet code_verifier = client.randomPKCECodeVerifier()\nlet code_challenge = await client.calculatePKCECodeChallenge(code_verifier)\nlet state!: string\n\n{\n  // redirect user to as.authorization_endpoint\n  let parameters: Record<string, string> = {\n    redirect_uri,\n    scope: 'api:read',\n    code_challenge,\n    code_challenge_method,\n  }\n\n  /**\n   * We cannot be sure the AS supports PKCE so we're going to use state too. Use\n   * of PKCE is backwards compatible even if the AS doesn't support it which is\n   * why we're using it regardless.\n   */\n  if (!config.serverMetadata().supportsPKCE()) {\n    state = client.randomState()\n    parameters.state = state\n  }\n\n  let redirectTo = client.buildAuthorizationUrl(config, parameters)\n\n  console.log('redirecting to', redirectTo.href)\n  // now redirect the user to redirectTo.href\n}\n\n// one eternity later, the user lands back on the redirect_uri\n// Authorization Code Grant\nlet access_token: string\n{\n  let currentUrl: URL = getCurrentUrl()\n  let tokens = await client.authorizationCodeGrant(config, currentUrl, {\n    pkceCodeVerifier: code_verifier,\n    expectedState: state,\n  })\n\n  console.log('Token Endpoint Response', tokens)\n  ;({ access_token } = tokens)\n}\n\n// Protected Resource Request\n{\n  let protectedResource = await client.fetchProtectedResource(\n    config,\n    access_token,\n    new URL('https://rs.example.com/api'),\n    'GET',\n  )\n\n  console.log('Protected Resource Response', await protectedResource.json())\n}\n",
      "asOf": "2026-11-17"
    },
    "F48": {
      "label": "Project function, openid-client",
      "display": "async authorize(config: OAuthConfig, redirectUrl: string, state?: string, codeChallenge?: string) {\n    const client = await this.getClient(config);\n    state ??= randomState();\n\n    let codeVerifier: string | null;\n    if (codeChallenge) {\n      codeVerifier = null;\n    } else {\n      codeVerifier = randomPKCECodeVerifier();\n      codeChallenge = await calculatePKCECodeChallenge(codeVerifier);\n    }\n\n    const params: Record<string, string> = {\n      redirect_uri: redirectUrl,\n      scope: config.scope,\n      state,\n    };\n\n    if (config.prompt) {\n      params.prompt = config.prompt;\n    }\n\n    if (client.serverMetadata().supportsPKCE()) {\n      params.code_challenge = codeChallenge;\n      params.code_challenge_method = 'S256';\n    }\n\n    const url = buildAuthorizationUrl(client, params).href;\n\n    return { url, state, codeVerifier };\n  }\n",
      "asOf": "2026-11-17"
    },
    "F49": {
      "label": "Project function reference, openid-client",
      "display": "oauth.repository.ts · authorize()",
      "asOf": "2026-11-17"
    },
    "F50": {
      "label": "Project repository, openid-client",
      "display": "immich-app/immich",
      "asOf": "2026-11-17"
    },
    "F51": {
      "label": "Project stars, immich-app/immich",
      "display": "112.9K",
      "asOf": "2026-11-17"
    },
    "F52": {
      "label": "Project push date, immich-app/immich",
      "display": "Aug 2026",
      "asOf": "2026-08-28"
    },
    "F53": {
      "label": "Library name, simple-oauth2",
      "display": "Simple OAuth2",
      "asOf": "2026-11-17"
    },
    "F54": {
      "label": "Monthly downloads, simple-oauth2",
      "display": "3.2M",
      "asOf": "2026-11-15"
    },
    "F55": {
      "label": "License, simple-oauth2",
      "display": "Apache-2.0",
      "asOf": "2026-11-17"
    },
    "F56": {
      "label": "Package release, simple-oauth2",
      "display": "5.1.0",
      "asOf": "2026-11-17"
    },
    "F57": {
      "label": "Undated package release, simple-oauth2",
      "display": "v5.1.0",
      "asOf": "2026-11-17"
    },
    "F58": {
      "label": "Repository stars, simple-oauth2",
      "display": "1.6K",
      "asOf": "2026-11-17"
    },
    "F59": {
      "label": "Authorization code, simple-oauth2",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F60": {
      "label": "Token refresh, simple-oauth2",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F61": {
      "label": "Token revocation, simple-oauth2",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F62": {
      "label": "Install, simple-oauth2",
      "display": "npm install simple-oauth2",
      "asOf": "2026-11-17"
    },
    "F63": {
      "label": "What it does, simple-oauth2",
      "display": "Provides Node.js OAuth clients for authorization-code and application token grants.",
      "asOf": "2026-11-17"
    },
    "F64": {
      "label": "strengths lead, simple-oauth2",
      "display": "Recreates persisted token objects",
      "asOf": "2026-11-17"
    },
    "F65": {
      "label": "strengths, simple-oauth2",
      "display": "Use createToken to restore an AccessToken instance from stored token data.",
      "asOf": "2026-11-17"
    },
    "F66": {
      "label": "strengths lead, simple-oauth2",
      "display": "Supports early token renewal",
      "asOf": "2026-11-17"
    },
    "F67": {
      "label": "strengths, simple-oauth2",
      "display": "Pass an expiration window to expired before requesting a replacement.",
      "asOf": "2026-11-17"
    },
    "F68": {
      "label": "limitations lead, simple-oauth2",
      "display": "Application tokens need replacement",
      "asOf": "2026-11-17"
    },
    "F69": {
      "label": "limitations, simple-oauth2",
      "display": "Fetch a new client-credentials token after expiry instead of using refresh.",
      "asOf": "2026-11-17"
    },
    "F70": {
      "label": "limitations lead, simple-oauth2",
      "display": "Refresh decisions belong to callers",
      "asOf": "2026-11-17"
    },
    "F71": {
      "label": "limitations, simple-oauth2",
      "display": "Check expired and call refresh when the token needs renewal.",
      "asOf": "2026-11-17"
    },
    "F72": {
      "label": "Quickstart, simple-oauth2",
      "display": "const config = {\n  client: {\n    id: '<client-id>',\n    secret: '<client-secret>'\n  },\n  auth: {\n    tokenHost: 'https://api.oauth.com'\n  }\n};\n\nconst { ClientCredentials, ResourceOwnerPassword, AuthorizationCode } = require('simple-oauth2');\n\nasync function run() {\n  const client = new ClientCredentials(config);\n\n  const tokenParams = {\n    scope: '<scope>',\n  };\n\n  try {\n    const accessToken = await client.getToken(tokenParams);\n  } catch (error) {\n    console.log('Access Token error', error.message);\n  }\n}\n\nrun();\n",
      "asOf": "2026-11-17"
    },
    "F73": {
      "label": "Project function, simple-oauth2",
      "display": "export const oauthBearerProvider = (options: OauthBearerProviderOptions) => {\n  const logger = _logger('oauthBearerProvider');\n  if (!options.clientId || !options.clientSecret || !options.endpointUrl) {\n    throw new Error('Kafka OAUTHBEARER requires kafka.confluent.oauth.client_id, client_secret and endpoint_url to be set');\n  }\n  if (!/^https:\\/\\//i.test(options.endpointUrl)) {\n    logger.warn('Kafka OAuth token endpoint URL is not HTTPS (%s); client credentials will be sent unencrypted', options.endpointUrl);\n  }\n  const refreshThresholdMs = Number(options.refreshThresholdMs);\n  if (!Number.isFinite(refreshThresholdMs) || refreshThresholdMs < 0) {\n    throw new Error(`Kafka OAuth refresh_threshold must be a non-negative number, got: ${options.refreshThresholdMs}`);\n  }\n  const scope = options.scope && options.scope.trim().length > 0 ? options.scope.trim() : undefined;\n  let tokenUrl: URL;\n  try {\n    tokenUrl = new URL(options.endpointUrl);\n  } catch {\n    throw new Error(`Kafka OAuth endpoint_url is not a valid URL: ${options.endpointUrl}`);\n  }\n  const client = new ClientCredentials({\n    client: {\n      id: options.clientId,\n      secret: options.clientSecret\n    },\n    auth: {\n      // endpoint_url is the full token endpoint URL. Split it into host + path so\n      // simple-oauth2 does not append its default tokenPath (/oauth/token) and\n      // discard the real path (breaks Keycloak, Azure AD, Okta, etc.).\n      tokenHost: tokenUrl.origin,\n      tokenPath: tokenUrl.pathname + tokenUrl.search\n    }\n  });\n\n  // Last successfully fetched token. Kept across refreshes so a failed background refresh\n  // does not drop a still-valid token out from under KafkaJS (which calls this provider on\n  // each reauthentication). It is only swapped in after a successful refresh.\n  let cachedToken: string | undefined;\n  // Epoch ms at which cachedToken hard-expires (access_token lifetime from the IdP). 0 until the\n  // first successful fetch. Used to decide at serve time whether the cached token is still safe.\n  let cachedTokenExpiresAt = 0;\n  // In-flight token fetch, shared so a serve-triggered refresh and the scheduled timer (and\n  // concurrent KafkaJS callbacks) coalesce onto one request instead of stampeding the IdP.\n  let refreshInFlight: Promise<string> | undefined;\n  let refreshTimer: NodeJS.Timeout | undefined;\n  let warnedShortLivedToken = false;\n\n  function scheduleRefresh(delayMs: number): void {\n    if (refreshTimer) {\n      clearTimeout(refreshTimer);\n    }\n    const delay = Math.max(delayMs, MIN_REFRESH_DELAY_MS);\n    logger.info('Next Kafka OAuth token refresh in %dms', delay);\n    refreshTimer = setTimeout(() => {\n      // refreshTokenOnce() updates cachedToken on success and reschedules its own retry on failure;\n      // swallow here so a failed background refresh is not an unhandled rejection.\n      refreshTokenOnce().catch((err) => {\n        logger.error('Scheduled Kafka OAuth token refresh failed: %s', err?.message ?? err);\n      });\n    }, delay);\n    refreshTimer.unref();\n  }\n\n  // Coalesce concurrent refreshes (scheduled timer, serve-time fallback, parallel KafkaJS callbacks)\n  // onto a single in-flight request so a near-expiry burst cannot stampede the token endpoint.\n  function refreshTokenOnce(): Promise<string> {\n    if (!refreshInFlight) {\n      refreshInFlight = refreshToken().finally(() => {\n        refreshInFlight = undefined;\n      });\n    }\n    return refreshInFlight;\n  }\n\n  async function refreshToken(): Promise<string> {\n    logger.info('Requesting Kafka OAuth bearer token');\n    try {\n      // Client-credentials grant issues no refresh_token, so always request a fresh token.\n      const accessToken: AccessToken = await client.getToken(scope ? { scope } : {});\n\n      // Some IdPs return expires_in as a numeric string (\"3600\"); coerce before validating.\n      const rawExpiresIn = accessToken.token.expires_in;\n      const expiresIn = Number(rawExpiresIn);\n      if (!Number.isFinite(expiresIn) || expiresIn <= 0) {\n        throw new Error(`OAuth token response has invalid \"expires_in\": ${rawExpiresIn}`);\n      }\n      const accessTokenValue = accessToken.token.access_token;\n      if (typeof accessTokenValue !== 'string' || accessTokenValue.length === 0) {\n        throw new Error('OAuth token response has no \"access_token\"');\n      }\n\n      const lifetimeMs = expiresIn * 1000;\n      cachedToken = accessTokenValue;\n      cachedTokenExpiresAt = Date.now() + lifetimeMs;\n\n      // If the token lifetime is shorter than the refresh threshold, refreshing \"threshold\n      // before expiry\" would fire immediately and clamp to MIN_REFRESH_DELAY_MS, hammering the\n      // token endpoint every second. Cap the effective threshold to half the lifetime instead.\n      let effectiveThresholdMs = refreshThresholdMs;\n      if (refreshThresholdMs >= lifetimeMs) {\n        effectiveThresholdMs = lifetimeMs / 2;\n        if (!warnedShortLivedToken) {\n          logger.warn('Kafka OAuth token lifetime (%dms) is <= refresh threshold (%dms); capping threshold to %dms to avoid hammering the token endpoint',\n            lifetimeMs, refreshThresholdMs, effectiveThresholdMs);\n          warnedShortLivedToken = true;\n        }\n      }\n\n      const nextRefresh = lifetimeMs - effectiveThresholdMs;\n      scheduleRefresh(nextRefresh);\n      return accessTokenValue;\n    } catch (err) {\n      logger.error('Failed to obtain Kafka OAuth bearer token, retrying in %dms', RETRY_DELAY_MS);\n      scheduleRefresh(RETRY_DELAY_MS);\n      throw err;\n    }\n  }\n\n  // Kick off the initial fetch eagerly so the first authentication is fast.\n  // The first fetch is retried internally; swallow here, so a startup failure is not an unhandled rejection.\n  refreshTokenOnce().catch(() => { /* retry already scheduled in refreshToken() */ });\n\n  return async function () {\n    // Serve the cached token while it is comfortably valid; the background timer rotates it\n    // proactively. If there is no token yet, or the cached one is within EXPIRY_SAFETY_MS of its\n    // hard expiry (a scheduled refresh slipped), fetch synchronously so KafkaJS never reauthenticates\n    // with an expired token. Concurrent callers coalesce onto the same request via refreshTokenOnce().\n    if (!cachedToken || Date.now() >= cachedTokenExpiresAt - EXPIRY_SAFETY_MS) {\n      return {\n        value: await refreshTokenOnce()\n      };\n    }\n    return {\n      value: cachedToken\n    };\n  };\n};\n",
      "asOf": "2026-11-17"
    },
    "F74": {
      "label": "Project function reference, simple-oauth2",
      "display": "oAuthBearerProvider.ts · oauthBearerProvider()",
      "asOf": "2026-11-17"
    },
    "F75": {
      "label": "Project repository, simple-oauth2",
      "display": "thingsboard/thingsboard",
      "asOf": "2026-11-17"
    },
    "F76": {
      "label": "Project stars, thingsboard/thingsboard",
      "display": "22.7K",
      "asOf": "2026-11-17"
    },
    "F77": {
      "label": "Project push date, thingsboard/thingsboard",
      "display": "Nov 2026",
      "asOf": "2026-11-16"
    },
    "F78": {
      "label": "Library name, @badgateway/oauth2-client",
      "display": "@badgateway/oauth2-client",
      "asOf": "2026-11-17"
    },
    "F79": {
      "label": "Monthly downloads, @badgateway/oauth2-client",
      "display": "623.3K",
      "asOf": "2026-11-15"
    },
    "F80": {
      "label": "License, @badgateway/oauth2-client",
      "display": "MIT",
      "asOf": "2026-11-17"
    },
    "F81": {
      "label": "Package release, @badgateway/oauth2-client",
      "display": "3.3.1",
      "asOf": "2026-11-17"
    },
    "F82": {
      "label": "Undated package release, @badgateway/oauth2-client",
      "display": "v3.3.1",
      "asOf": "2026-11-17"
    },
    "F83": {
      "label": "Repository stars, @badgateway/oauth2-client",
      "display": "336",
      "asOf": "2026-11-17"
    },
    "F84": {
      "label": "Authorization code, @badgateway/oauth2-client",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F85": {
      "label": "PKCE helpers, @badgateway/oauth2-client",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F86": {
      "label": "Token refresh, @badgateway/oauth2-client",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F87": {
      "label": "Token revocation, @badgateway/oauth2-client",
      "display": "Built-in",
      "asOf": "2026-11-17"
    },
    "F88": {
      "label": "Install, @badgateway/oauth2-client",
      "display": "npm install @badgateway/oauth2-client",
      "asOf": "2026-11-17"
    },
    "F89": {
      "label": "What it does, @badgateway/oauth2-client",
      "display": "Provides OAuth clients and a token-aware fetch wrapper for browsers and Node.",
      "asOf": "2026-11-17"
    },
    "F90": {
      "label": "strengths lead, @badgateway/oauth2-client",
      "display": "Refreshes tokens while fetching",
      "asOf": "2026-11-17"
    },
    "F91": {
      "label": "strengths, @badgateway/oauth2-client",
      "display": "Use OAuth2Fetch to attach bearer headers and renew tokens when needed.",
      "asOf": "2026-11-17"
    },
    "F92": {
      "label": "strengths lead, @badgateway/oauth2-client",
      "display": "Discovers OAuth server endpoints",
      "asOf": "2026-11-17"
    },
    "F93": {
      "label": "strengths, @badgateway/oauth2-client",
      "display": "Use server metadata discovery when endpoint URLs are not supplied.",
      "asOf": "2026-11-17"
    },
    "F94": {
      "label": "limitations lead, @badgateway/oauth2-client",
      "display": "Default encoding favors interoperability",
      "asOf": "2026-11-17"
    },
    "F95": {
      "label": "limitations, @badgateway/oauth2-client",
      "display": "Set authenticationMethod when the server requires strict Basic credential encoding.",
      "asOf": "2026-11-17"
    },
    "F96": {
      "label": "limitations lead, @badgateway/oauth2-client",
      "display": "Token persistence belongs to applications",
      "asOf": "2026-11-17"
    },
    "F97": {
      "label": "limitations, @badgateway/oauth2-client",
      "display": "Implement storage callbacks to retain tokens between sessions.",
      "asOf": "2026-11-17"
    },
    "F98": {
      "label": "Quickstart, @badgateway/oauth2-client",
      "display": "import { OAuth2Client } from '@badgateway/oauth2-client';\n\nconst client = new OAuth2Client({\n\n  // The base URI of your OAuth2 server\n  server: 'https://my-auth-server/',\n\n  // OAuth2 client id\n  clientId: '...',\n\n  // OAuth2 client secret. Only required for 'client_credentials', 'password'\n  // flows. Don't specify this in insecure contexts, such as a browser using\n  // the authorization_code flow.\n  clientSecret: '...',\n\n\n  // The following URIs are all optional. If they are not specified, we will\n  // attempt to discover them using the oauth2 discovery document.\n  // If your server doesn't have support this, you may need to specify these.\n  // you may use relative URIs for any of these.\n\n\n  // Token endpoint. Most flows need this.\n  // If not specified we'll use the information for the discovery document\n  // first, and otherwise default to /token\n  tokenEndpoint: '/token',\n\n  // Authorization endpoint.\n  //\n  // You only need this to generate URLs for authorization_code flows.\n  // If not specified we'll use the information for the discovery document\n  // first, and otherwise default to /authorize\n  authorizationEndpoint: '/authorize',\n\n  // OAuth2 Metadata discovery endpoint.\n  //\n  // This document is used to determine various server features.\n  // If not specified, we assume it's on /.well-known/oauth2-authorization-server\n  discoveryEndpoint: '/.well-known/oauth2-authorization-server',\n\n});\n\nconst token = await client.clientCredentials();\n",
      "asOf": "2026-11-17"
    },
    "F99": {
      "label": "Developer need",
      "display": "Integrating common OAuth and OpenID flows",
      "asOf": "2026-11-17"
    },
    "F100": {
      "label": "Why choose openid-client",
      "display": "server discovery and client configuration",
      "asOf": "2026-11-17"
    },
    "F101": {
      "label": "Developer need in introduction",
      "display": "integrating common OAuth and OpenID flows",
      "asOf": "2026-11-17"
    },
    "F102": {
      "label": "When to consider oauth4webapi",
      "display": "explicit protocol request and response steps matter",
      "asOf": "2026-11-17"
    },
    "F103": {
      "label": "Developer need",
      "display": "Implementing protocol steps explicitly",
      "asOf": "2026-11-17"
    },
    "F104": {
      "label": "Why choose oauth4webapi",
      "display": "separate request and response routines",
      "asOf": "2026-11-17"
    },
    "F105": {
      "label": "Developer need in introduction",
      "display": "implementing protocol steps explicitly",
      "asOf": "2026-11-17"
    },
    "F106": {
      "label": "Developer need",
      "display": "Restoring persisted Node token objects",
      "asOf": "2026-11-17"
    },
    "F107": {
      "label": "Why choose simple-oauth2",
      "display": "the createToken restoration API",
      "asOf": "2026-11-17"
    },
    "F108": {
      "label": "Developer need in introduction",
      "display": "restoring persisted Node token objects",
      "asOf": "2026-11-17"
    },
    "F109": {
      "label": "When to consider @badgateway/oauth2-client",
      "display": "the fetch wrapper should renew tokens",
      "asOf": "2026-11-17"
    },
    "F110": {
      "label": "Developer need",
      "display": "Calling APIs with token renewal",
      "asOf": "2026-11-17"
    },
    "F111": {
      "label": "Why choose @badgateway/oauth2-client",
      "display": "the token-aware fetch wrapper",
      "asOf": "2026-11-17"
    },
    "F112": {
      "label": "Developer need in introduction",
      "display": "calling APIs with token renewal",
      "asOf": "2026-11-17"
    },
    "F113": {
      "label": "Page introduction",
      "display": "JavaScript OAuth clients libraries let application developers implement OAuth authorization and token flows.",
      "asOf": "2026-11-17"
    },
    "F114": {
      "label": "FAQ: Which client combines discovery and code exchange?",
      "display": "openid-client provides server discovery and authorization-code client flows.",
      "asOf": "2026-11-17"
    },
    "F115": {
      "label": "FAQ: Which library exposes lower-level protocol routines?",
      "display": "oauth4webapi provides routines for constructing an OAuth or OpenID Connect client.",
      "asOf": "2026-11-17"
    },
    "F116": {
      "label": "FAQ: Does a grant request finish response processing?",
      "display": "oauth4webapi returns a Response that must be passed to processAuthorizationCodeResponse.",
      "asOf": "2026-11-17"
    },
    "F117": {
      "label": "FAQ: What must survive an authorization redirect?",
      "display": "Retain the per-request verifier and state in the end-user session until the callback.",
      "asOf": "2026-11-17"
    },
    "F118": {
      "label": "FAQ: Does token-refresh support imply automatic renewal?",
      "display": "Simple OAuth2 expects the caller to check expired and invoke refresh.",
      "asOf": "2026-11-17"
    },
    "F119": {
      "label": "FAQ: Does token-refresh support imply automatic renewal?",
      "display": "The badgateway fetch wrapper automatically attaches bearer headers and refreshes tokens when needed.",
      "asOf": "2026-11-17"
    },
    "F120": {
      "label": "FAQ: Can client-credentials tokens be refreshed?",
      "display": "Simple OAuth2 instructs callers to fetch a new token after expiry instead.",
      "asOf": "2026-11-17"
    },
    "F121": {
      "label": "FAQ: How can renewal start before the token expires?",
      "display": "Simple OAuth2 accepts an expiration window to avoid waiting until definitive expiry.",
      "asOf": "2026-11-17"
    },
    "F122": {
      "label": "FAQ: How are persisted token objects restored?",
      "display": "Simple OAuth2 createToken rebuilds an AccessToken instance from persisted token data.",
      "asOf": "2026-11-17"
    },
    "F123": {
      "label": "FAQ: Does the fetch wrapper persist tokens itself?",
      "display": "Applications implement the optional token storage callbacks for reuse between sessions.",
      "asOf": "2026-11-17"
    },
    "F124": {
      "label": "FAQ: Can strict client-secret encoding be selected?",
      "display": "The badgateway client supports strict Basic encoding, an interoperability variant, and POST-body authentication.",
      "asOf": "2026-11-17"
    },
    "F125": {
      "label": "FAQ: Can OAuth server endpoints be discovered?",
      "display": "The badgateway client can discover OAuth endpoints from server metadata.",
      "asOf": "2026-11-17"
    },
    "F126": {
      "label": "FAQ: Does device authorization require immediate browser callback handling?",
      "display": "openid-client can display the verification instructions and poll until the user authenticates.",
      "asOf": "2026-11-17"
    },
    "F127": {
      "label": "Library name, oauth4webapi",
      "display": "oauth4webapi",
      "asOf": "2026-11-20"
    },
    "F128": {
      "label": "Monthly downloads, oauth4webapi",
      "display": "97.0M",
      "asOf": "2026-11-20"
    },
    "F129": {
      "label": "License, oauth4webapi",
      "display": "MIT",
      "asOf": "2026-11-20"
    },
    "F130": {
      "label": "Package release, oauth4webapi",
      "display": "3.8.8",
      "asOf": "2026-11-20"
    },
    "F131": {
      "label": "Package release date, oauth4webapi",
      "display": "Sep 2026",
      "asOf": "2026-11-20"
    },
    "F132": {
      "label": "Install, oauth4webapi",
      "display": "npm install oauth4webapi@3.8.8",
      "asOf": "2026-11-20"
    },
    "F133": {
      "label": "Quickstart, oauth4webapi",
      "display": "import * as oauth from \"oauth4webapi\";\nconst issuer = new URL(process.env.OAUTH_ISSUER);\nconst response = await oauth.discoveryRequest(issuer);\nconst metadata = await oauth.processDiscoveryResponse(issuer, response);\nconsole.log(metadata.authorization_endpoint);\n",
      "asOf": "2026-11-20"
    },
    "F134": {
      "label": "Repository stars, oauth4webapi",
      "display": "806",
      "asOf": "2026-11-20"
    },
    "F135": {
      "label": "Metadata discovery, oauth4webapi",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F136": {
      "label": "PKCE generation, oauth4webapi",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F137": {
      "label": "Client integration role, oauth4webapi",
      "display": "Low-level protocol request, response, and cryptographic routines across browser and non-browser Web API runtimes. The host composes discovery, redirects, callback validation, and storage rather than receiving an application session framework.",
      "asOf": "2026-11-20"
    },
    "F138": {
      "label": "Project function, oauth4webapi",
      "display": "const login = async () => {\n    if (!as?.authorization_endpoint) {\n      return;\n    }\n\n    const code_verifier = generateRandomCodeVerifier();\n    sessionStorage.setItem(codeVerifierKey, code_verifier);\n    const state = generateRandomState();\n    sessionStorage.setItem(stateKey, state);\n    sessionStorage.setItem(platformRedirectKey, window.location.search);\n\n    const code_challenge = await calculatePKCECodeChallenge(code_verifier);\n    const url = new URL(as.authorization_endpoint);\n    url.searchParams.set('client_id', client.client_id);\n    url.searchParams.set('code_challenge', code_challenge);\n    url.searchParams.set('code_challenge_method', 'S256');\n    url.searchParams.set('redirect_uri', redirectURI);\n    url.searchParams.set('response_type', 'code');\n    url.searchParams.set('scope', getOIDCScopes(oidcConfig, as).join(' '));\n    url.searchParams.set('state', state);\n\n    window.location.replace(url.toString());\n  };\n",
      "asOf": "2026-11-20"
    },
    "F139": {
      "label": "Project source file, oauth4webapi",
      "display": "ui/src/features/auth/oidc-login.tsx",
      "asOf": "2026-11-20"
    },
    "F140": {
      "label": "Project full_name, oauth4webapi",
      "display": "akuity/kargo",
      "asOf": "2026-11-20"
    },
    "F141": {
      "label": "Project stargazers_count, oauth4webapi",
      "display": "3.8K",
      "asOf": "2026-11-20"
    },
    "F142": {
      "label": "Library name, openid-client",
      "display": "openid-client",
      "asOf": "2026-11-20"
    },
    "F143": {
      "label": "Monthly downloads, openid-client",
      "display": "91.2M",
      "asOf": "2026-11-20"
    },
    "F144": {
      "label": "License, openid-client",
      "display": "MIT",
      "asOf": "2026-11-20"
    },
    "F145": {
      "label": "Package release, openid-client",
      "display": "6.9.0",
      "asOf": "2026-11-20"
    },
    "F146": {
      "label": "Package release date, openid-client",
      "display": "Nov 2026",
      "asOf": "2026-11-20"
    },
    "F147": {
      "label": "Install, openid-client",
      "display": "npm install openid-client@6.9.0",
      "asOf": "2026-11-20"
    },
    "F148": {
      "label": "Quickstart, openid-client",
      "display": "import * as client from \"openid-client\";\nconst config = await client.discovery(new URL(process.env.OAUTH_ISSUER), process.env.OAUTH_CLIENT_ID);\nconsole.log(config.serverMetadata().issuer);\n",
      "asOf": "2026-11-20"
    },
    "F149": {
      "label": "Repository stars, openid-client",
      "display": "2.5K",
      "asOf": "2026-11-20"
    },
    "F150": {
      "label": "Metadata discovery, openid-client",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F151": {
      "label": "PKCE generation, openid-client",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F152": {
      "label": "Client integration role, openid-client",
      "display": "Higher-level OAuth/OIDC client interface with issuer discovery, authorization URL construction, multiple grants, and PKCE utilities across documented Web API runtimes. Package counts overlap the oauth4webapi dependency family; they are not summed.",
      "asOf": "2026-11-20"
    },
    "F153": {
      "label": "Project function, openid-client",
      "display": "async authorize(config: OAuthConfig, redirectUrl: string, state?: string, codeChallenge?: string) {\n    const client = await this.getClient(config);\n    state ??= randomState();\n\n    let codeVerifier: string | null;\n    if (codeChallenge) {\n      codeVerifier = null;\n    } else {\n      codeVerifier = randomPKCECodeVerifier();\n      codeChallenge = await calculatePKCECodeChallenge(codeVerifier);\n    }\n\n    const params: Record<string, string> = {\n      redirect_uri: redirectUrl,\n      scope: config.scope,\n      state,\n    };\n\n    if (config.prompt) {\n      params.prompt = config.prompt;\n    }\n\n    if (client.serverMetadata().supportsPKCE()) {\n      params.code_challenge = codeChallenge;\n      params.code_challenge_method = 'S256';\n    }\n\n    const url = buildAuthorizationUrl(client, params).href;\n\n    return { url, state, codeVerifier };\n  }\n",
      "asOf": "2026-11-20"
    },
    "F154": {
      "label": "Project source file, openid-client",
      "display": "server/src/repositories/oauth.repository.ts",
      "asOf": "2026-11-20"
    },
    "F155": {
      "label": "Project full_name, openid-client",
      "display": "immich-app/immich",
      "asOf": "2026-11-20"
    },
    "F156": {
      "label": "Project stargazers_count, openid-client",
      "display": "112.9K",
      "asOf": "2026-11-20"
    },
    "F157": {
      "label": "Library name, oauth",
      "display": "oauth",
      "asOf": "2026-11-20"
    },
    "F158": {
      "label": "Monthly downloads, oauth",
      "display": "32.6M",
      "asOf": "2026-11-20"
    },
    "F159": {
      "label": "License, oauth",
      "display": "MIT",
      "asOf": "2026-11-20"
    },
    "F160": {
      "label": "Package release, oauth",
      "display": "0.10.2",
      "asOf": "2026-11-20"
    },
    "F161": {
      "label": "Package release date, oauth",
      "display": "Mar 2025",
      "asOf": "2026-11-20"
    },
    "F162": {
      "label": "Install, oauth",
      "display": "npm install oauth@0.10.2",
      "asOf": "2026-11-20"
    },
    "F163": {
      "label": "Quickstart, oauth",
      "display": "const { OAuth2 } = require(\"oauth\");\nconst client = new OAuth2(process.env.OAUTH_CLIENT_ID, null, process.env.OAUTH_BASE_URL, \"/authorize\", \"/token\");\nconst state = require(\"node:crypto\").randomBytes(32).toString(\"hex\");\nconsole.log(client.getAuthorizeUrl({ redirect_uri: process.env.OAUTH_REDIRECT_URI, response_type: \"code\", state }));\n",
      "asOf": "2026-11-20"
    },
    "F164": {
      "label": "Official description, oauth",
      "display": "Interacts with OAuth 1.0, 1.0A, 2, and Echo providers.",
      "asOf": "2026-11-20"
    },
    "F165": {
      "label": "Quickstart source file, oauth",
      "display": "lib/oauth2.js",
      "asOf": "2026-11-20"
    },
    "F166": {
      "label": "Repository stars, oauth",
      "display": "2.4K",
      "asOf": "2026-11-20"
    },
    "F167": {
      "label": "Metadata discovery, oauth",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F168": {
      "label": "PKCE generation, oauth",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F169": {
      "label": "Client integration role, oauth",
      "display": "Node callback-based OAuth1/1A/2 client APIs and protected-resource requests. Its full-package counter includes OAuth1 and transitive strategy installations, not only new OAuth2 application choices.",
      "asOf": "2026-11-20"
    },
    "F170": {
      "label": "Project function, oauth",
      "display": "protected patch_getOAuthAccessToken() {\n    const oauth2 = this._oauth2;\n    const _oauth2_getOAuthAccessToken = oauth2.getOAuthAccessToken as (\n        code: string,\n        params: any,\n        callback: oauth2tokenCallback,\n    ) => void;\n    (oauth2 as any).getOAuthAccessToken = (code: string, params: any, callback: oauth2tokenCallback) => {\n        const patchedCallback: oauth2tokenCallback = (err, accessToken, refreshToken, params) => {\n            if (err) {\n                return callback(err, null as any, null as any, null as any);\n            }\n            if (!accessToken) {\n                return callback(\n                    {\n                        statusCode: 400,\n                        data: JSON.stringify(params),\n                    },\n                    null as any,\n                    null as any,\n                    null as any,\n                );\n            }\n            callback(null as any, accessToken, refreshToken, params);\n        };\n        _oauth2_getOAuthAccessToken.call(oauth2, code, params, patchedCallback);\n    };\n}\n",
      "asOf": "2026-11-20"
    },
    "F171": {
      "label": "Project source file, oauth",
      "display": "components/server/src/auth/generic-auth-provider.ts",
      "asOf": "2026-11-20"
    },
    "F172": {
      "label": "Project full_name, oauth",
      "display": "gitpod-io/gitpod",
      "asOf": "2026-11-20"
    },
    "F173": {
      "label": "Project stargazers_count, oauth",
      "display": "13.8K",
      "asOf": "2026-11-20"
    },
    "F174": {
      "label": "Library name, oidc-client-ts",
      "display": "oidc-client-ts",
      "asOf": "2026-11-20"
    },
    "F175": {
      "label": "Monthly downloads, oidc-client-ts",
      "display": "12.0M",
      "asOf": "2026-11-20"
    },
    "F176": {
      "label": "License, oidc-client-ts",
      "display": "Apache-2.0",
      "asOf": "2026-11-20"
    },
    "F177": {
      "label": "Package release, oidc-client-ts",
      "display": "3.5.0",
      "asOf": "2026-11-20"
    },
    "F178": {
      "label": "Package release date, oidc-client-ts",
      "display": "Mar 2026",
      "asOf": "2026-11-20"
    },
    "F179": {
      "label": "Install, oidc-client-ts",
      "display": "npm install oidc-client-ts@3.5.0",
      "asOf": "2026-11-20"
    },
    "F180": {
      "label": "Quickstart, oidc-client-ts",
      "display": "import { UserManager } from \"oidc-client-ts\";\nconst manager = new UserManager({ authority: \"https://issuer.example.com\", client_id: \"registered-client\", redirect_uri: window.location.origin + \"/callback\", response_type: \"code\", scope: \"openid profile\" });\nawait manager.signinRedirect();\n",
      "asOf": "2026-11-20"
    },
    "F181": {
      "label": "Official description, oidc-client-ts",
      "display": "Provides an OpenID Connect and OAuth2 client library.",
      "asOf": "2026-11-20"
    },
    "F182": {
      "label": "Quickstart source file, oidc-client-ts",
      "display": "UserManager API reference",
      "asOf": "2026-11-20"
    },
    "F183": {
      "label": "Repository stars, oidc-client-ts",
      "display": "2.0K",
      "asOf": "2026-11-20"
    },
    "F184": {
      "label": "Metadata discovery, oidc-client-ts",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F185": {
      "label": "PKCE generation, oidc-client-ts",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F186": {
      "label": "Client integration role, oidc-client-ts",
      "display": "Browser-oriented UserManager for OIDC/OAuth sign-in, sign-out, access-token lifecycle, and identity-provider callbacks. It is the underlying peer of react-oidc-context, so counters overlap.",
      "asOf": "2026-11-20"
    },
    "F187": {
      "label": "Project function, oidc-client-ts",
      "display": "export const AuthProvider = (props: AuthProviderProps): React.JSX.Element => {\n    const {\n        children,\n\n        onSigninCallback,\n        skipSigninCallback,\n\n        matchSignoutCallback,\n        onSignoutCallback,\n\n        onRemoveUser,\n\n        userManager: userManagerProp = null,\n        ...userManagerSettings\n    } = props;\n\n    const [userManager] = React.useState(() => {\n        return userManagerProp ??\n            (UserManagerImpl\n                ? new UserManagerImpl(userManagerSettings as UserManagerSettings)\n                : ({ settings: userManagerSettings } as UserManager));\n    });\n\n    const [state, dispatch] = React.useReducer(reducer, initialAuthState);\n    const userManagerContext = React.useMemo(\n        () =>\n            Object.assign(\n                {\n                    settings: userManager.settings,\n                    events: userManager.events,\n                },\n                Object.fromEntries(\n                    userManagerContextKeys.map((key) => [\n                        key,\n                        userManager[key]?.bind(userManager) ??\n                        unsupportedEnvironment(key),\n                    ]),\n                ) as Pick<UserManager, typeof userManagerContextKeys[number]>,\n                Object.fromEntries(\n                    navigatorKeys.map((key) => [\n                        key,\n                        userManager[key]\n                            ? async (args: ProcessResourceOwnerPasswordCredentialsArgs & never[]) => {\n                                dispatch({\n                                    type: \"NAVIGATOR_INIT\",\n                                    method: key,\n                                });\n                                try {\n                                    return await userManager[key](args);\n                                } catch (error) {\n                                    dispatch({\n                                        type: \"ERROR\",\n                                        error: {\n                                            ...normalizeError(error, `Unknown error while executing ${key}(...).`),\n                                            source: key,\n                                            args: args,\n                                        } as ErrorContext,\n                                    });\n                                    return null;\n                                } finally {\n                                    dispatch({ type: \"NAVIGATOR_CLOSE\" });\n                                }\n                            }\n                            : unsupportedEnvironment(key),\n                    ]),\n                ) as Pick<UserManager, typeof navigatorKeys[number]>,\n            ),\n        [userManager],\n    );\n    const didInitialize = React.useRef(false);\n\n    React.useEffect(() => {\n        if (!userManager || didInitialize.current) {\n            return;\n        }\n        didInitialize.current = true;\n\n        void (async (): Promise<void> => {\n            // sign-in\n            try {\n                let user: User | undefined | null = null;\n\n                // check if returning back from authority server\n                if (hasAuthParams() && !skipSigninCallback) {\n                    user = await userManager.signinCallback();\n                    if (onSigninCallback) await onSigninCallback(user);\n                }\n                user = !user ? await userManager.getUser() : user;\n                dispatch({ type: \"INITIALISED\", user });\n            } catch (error) {\n                dispatch({\n                    type: \"ERROR\",\n                    error: signinError(error),\n                });\n            }\n\n            // sign-out\n            try {\n                if (matchSignoutCallback && matchSignoutCallback(userManager.settings)) {\n                    const resp = await userManager.signoutCallback();\n                    if (onSignoutCallback) await onSignoutCallback(resp);\n                }\n            } catch (error) {\n                dispatch({\n                    type: \"ERROR\",\n                    error: signoutError(error),\n                });\n            }\n        })();\n    }, [userManager, skipSigninCallback, onSigninCallback, onSignoutCallback, matchSignoutCallback]);\n\n    // register to userManager events\n    React.useEffect(() => {\n        if (!userManager) return undefined;\n        // event UserLoaded (e.g. initial load, silent renew success)\n        const handleUserLoaded = (user: User) => {\n            dispatch({ type: \"USER_LOADED\", user });\n        };\n        userManager.events.addUserLoaded(handleUserLoaded);\n\n        // event UserUnloaded (e.g. userManager.removeUser)\n        const handleUserUnloaded = () => {\n            dispatch({ type: \"USER_UNLOADED\" });\n        };\n        userManager.events.addUserUnloaded(handleUserUnloaded);\n\n        // event UserSignedOut (e.g. user was signed out in background (checkSessionIFrame option))\n        const handleUserSignedOut = () => {\n            dispatch({ type: \"USER_SIGNED_OUT\" });\n        };\n        userManager.events.addUserSignedOut(handleUserSignedOut);\n\n        // event SilentRenewError (silent renew error)\n        const handleSilentRenewError = (error: Error) => {\n            dispatch({\n                type: \"ERROR\",\n                error: renewSilentError(error),\n            });\n        };\n        userManager.events.addSilentRenewError(handleSilentRenewError);\n\n        return () => {\n            userManager.events.removeUserLoaded(handleUserLoaded);\n            userManager.events.removeUserUnloaded(handleUserUnloaded);\n            userManager.events.removeUserSignedOut(handleUserSignedOut);\n            userManager.events.removeSilentRenewError(handleSilentRenewError);\n        };\n    }, [userManager]);\n\n    const removeUser = React.useCallback(async () => {\n        if (!userManager) unsupportedEnvironment(\"removeUser\");\n        await userManager.removeUser();\n        if (onRemoveUser) await onRemoveUser();\n    }, [userManager, onRemoveUser]);\n\n    const contextValue = React.useMemo(() => {\n        return {\n            ...state,\n            ...userManagerContext,\n            removeUser,\n        };\n    }, [state, userManagerContext, removeUser]);\n\n    return (\n        <AuthContext.Provider value={contextValue}>\n            {children}\n        </AuthContext.Provider>\n    );\n};\n",
      "asOf": "2026-11-20"
    },
    "F188": {
      "label": "Project source file, oidc-client-ts",
      "display": "src/AuthProvider.tsx",
      "asOf": "2026-11-20"
    },
    "F189": {
      "label": "Project full_name, oidc-client-ts",
      "display": "authts/react-oidc-context",
      "asOf": "2026-11-20"
    },
    "F190": {
      "label": "Project stargazers_count, oidc-client-ts",
      "display": "1.0K",
      "asOf": "2026-11-20"
    },
    "F191": {
      "label": "Library name, passport-oauth2",
      "display": "passport-oauth2",
      "asOf": "2026-11-20"
    },
    "F192": {
      "label": "Monthly downloads, passport-oauth2",
      "display": "11.8M",
      "asOf": "2026-11-20"
    },
    "F193": {
      "label": "License, passport-oauth2",
      "display": "MIT",
      "asOf": "2026-11-20"
    },
    "F194": {
      "label": "Package release, passport-oauth2",
      "display": "1.8.0",
      "asOf": "2026-11-20"
    },
    "F195": {
      "label": "Package release date, passport-oauth2",
      "display": "Feb 2024",
      "asOf": "2026-11-20"
    },
    "F196": {
      "label": "Install, passport-oauth2",
      "display": "npm install passport-oauth2@1.8.0",
      "asOf": "2026-11-20"
    },
    "F197": {
      "label": "Quickstart, passport-oauth2",
      "display": "const { Strategy } = require(\"passport-oauth2\");\nconst strategy = new Strategy({ authorizationURL: process.env.OAUTH_AUTHORIZATION_URL, tokenURL: process.env.OAUTH_TOKEN_URL, clientID: process.env.OAUTH_CLIENT_ID, clientSecret: process.env.OAUTH_CLIENT_SECRET, callbackURL: process.env.OAUTH_REDIRECT_URI, state: true }, (_accessToken, _refreshToken, _profile, done) => done(null, false));\nconsole.log(strategy.name);\n",
      "asOf": "2026-11-20"
    },
    "F198": {
      "label": "Official description, passport-oauth2",
      "display": "Adds an OAuth 2.0 authentication strategy to Passport.",
      "asOf": "2026-11-20"
    },
    "F199": {
      "label": "Quickstart source file, passport-oauth2",
      "display": "lib/strategy.js",
      "asOf": "2026-11-20"
    },
    "F200": {
      "label": "Repository stars, passport-oauth2",
      "display": "617",
      "asOf": "2026-11-20"
    },
    "F201": {
      "label": "Metadata discovery, passport-oauth2",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F202": {
      "label": "PKCE generation, passport-oauth2",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F203": {
      "label": "Client integration role, passport-oauth2",
      "display": "Provider-independent OAuth2 strategy interface for an existing Passport/Node authentication host. The host supplies callback routing, registered endpoints, identity lookup, and session policy; the package is a strategy rather than the whole user/session application.",
      "asOf": "2026-11-20"
    },
    "F204": {
      "label": "Project function, passport-oauth2",
      "display": "function Strategy(options, verify) {\n  options = options || {};\n  options.authorizationURL = options.authorizationURL || 'https://accounts.google.com/o/oauth2/v2/auth';\n  options.tokenURL = options.tokenURL || 'https://www.googleapis.com/oauth2/v4/token';\n\n  OAuth2Strategy.call(this, options, verify);\n  this.name = 'google';\n  this._userProfileURL = options.userProfileURL || 'https://www.googleapis.com/oauth2/v3/userinfo';\n  \n  var url = uri.parse(this._userProfileURL);\n  if (url.pathname.indexOf('/userinfo') == (url.pathname.length - '/userinfo'.length)) {\n    this._userProfileFormat = 'openid';\n  } else {\n    this._userProfileFormat = 'google+'; // Google Sign-In\n  }\n}\n",
      "asOf": "2026-11-20"
    },
    "F205": {
      "label": "Project source file, passport-oauth2",
      "display": "lib/strategy.js",
      "asOf": "2026-11-20"
    },
    "F206": {
      "label": "Project full_name, passport-oauth2",
      "display": "jaredhanson/passport-google-oauth2",
      "asOf": "2026-11-20"
    },
    "F207": {
      "label": "Project stargazers_count, passport-oauth2",
      "display": "832",
      "asOf": "2026-11-20"
    },
    "F208": {
      "label": "Library name, arctic",
      "display": "arctic",
      "asOf": "2026-11-20"
    },
    "F209": {
      "label": "Monthly downloads, arctic",
      "display": "5.9M",
      "asOf": "2026-11-20"
    },
    "F210": {
      "label": "License, arctic",
      "display": "MIT",
      "asOf": "2026-11-20"
    },
    "F211": {
      "label": "Package release, arctic",
      "display": "3.7.0",
      "asOf": "2026-11-20"
    },
    "F212": {
      "label": "Package release date, arctic",
      "display": "May 2025",
      "asOf": "2026-11-20"
    },
    "F213": {
      "label": "Install, arctic",
      "display": "npm install arctic@3.7.0",
      "asOf": "2026-11-20"
    },
    "F214": {
      "label": "Quickstart, arctic",
      "display": "import { OAuth2Client, CodeChallengeMethod, generateCodeVerifier, generateState } from \"arctic\";\nconst client = new OAuth2Client(process.env.OAUTH_CLIENT_ID, null, process.env.OAUTH_REDIRECT_URI);\nconst verifier = generateCodeVerifier();\nconst state = generateState();\nconst url = client.createAuthorizationURLWithPKCE(process.env.OAUTH_AUTHORIZATION_URL, state, CodeChallengeMethod.S256, verifier, [\"openid\"]);\nconsole.log(url.href);\n",
      "asOf": "2026-11-20"
    },
    "F215": {
      "label": "Official description, arctic",
      "display": "Provides OAuth 2.0 clients for specific providers.",
      "asOf": "2026-11-20"
    },
    "F216": {
      "label": "Quickstart source file, arctic",
      "display": "src/client.ts, src/oauth2.ts",
      "asOf": "2026-11-20"
    },
    "F217": {
      "label": "Repository stars, arctic",
      "display": "1.7K",
      "asOf": "2026-11-20"
    },
    "F218": {
      "label": "Metadata discovery, arctic",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F219": {
      "label": "PKCE generation, arctic",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F220": {
      "label": "Client integration role, arctic",
      "display": "OAuth2 endpoint-specific clients, generic OAuth2Client, and PKCE/state helpers. Maintainer deprecated Arctic in July2026; selected3.7.0 remains the measured package, and current maintained/new-project recommendation is not inferred from downloads.",
      "asOf": "2026-11-20"
    },
    "F221": {
      "label": "Project function, arctic",
      "display": "export const handleOAuthAuthorizeUrl = async (options: HandleOAuthAuthorizeUrlOptions) => {\n  const { c, clientOptions, redirectPath } = options;\n\n  let prompt = options.prompt ?? 'login';\n\n  if (!clientOptions.clientId || !clientOptions.clientSecret) {\n    throw new AppError(AppErrorCode.NOT_SETUP);\n  }\n\n  const { authorization_endpoint } = await getOpenIdConfiguration(clientOptions.wellKnownUrl, {\n    requiredScopes: clientOptions.scope,\n  });\n\n  const oAuthClient = new OAuth2Client(clientOptions.clientId, clientOptions.clientSecret, clientOptions.redirectUrl);\n\n  const scopes = clientOptions.scope;\n  const state = options.state ?? generateState();\n\n  const codeVerifier = generateCodeVerifier();\n\n  const url = oAuthClient.createAuthorizationURLWithPKCE(\n    authorization_endpoint,\n    state,\n    CodeChallengeMethod.S256,\n    codeVerifier,\n    scopes,\n  );\n\n  // Pass the prompt to the authorization endpoint.\n  if (process.env.NEXT_PRIVATE_OIDC_PROMPT && isOidcPrompt(process.env.NEXT_PRIVATE_OIDC_PROMPT)) {\n    prompt = process.env.NEXT_PRIVATE_OIDC_PROMPT;\n  }\n\n  url.searchParams.set('prompt', prompt);\n\n  setCookie(c, `${clientOptions.id}_oauth_state`, state, {\n    ...sessionCookieOptions,\n    sameSite: 'lax',\n    maxAge: oauthCookieMaxAge,\n  });\n\n  setCookie(c, `${clientOptions.id}_code_verifier`, codeVerifier, {\n    ...sessionCookieOptions,\n    sameSite: 'lax',\n    maxAge: oauthCookieMaxAge,\n  });\n\n  if (redirectPath) {\n    setCookie(c, `${clientOptions.id}_redirect_path`, `${state} ${redirectPath}`, {\n      ...sessionCookieOptions,\n      sameSite: 'lax',\n      maxAge: oauthCookieMaxAge,\n    });\n  }\n\n  return c.json({\n    redirectUrl: url.toString(),\n  });\n};\n",
      "asOf": "2026-11-20"
    },
    "F222": {
      "label": "Project source file, arctic",
      "display": "packages/auth/server/lib/utils/handle-oauth-authorize-url.ts",
      "asOf": "2026-11-20"
    },
    "F223": {
      "label": "Project full_name, arctic",
      "display": "documenso/documenso",
      "asOf": "2026-11-20"
    },
    "F224": {
      "label": "Project stargazers_count, arctic",
      "display": "15.8K",
      "asOf": "2026-11-20"
    },
    "F225": {
      "label": "Library name, react-oidc-context",
      "display": "react-oidc-context",
      "asOf": "2026-11-20"
    },
    "F226": {
      "label": "Monthly downloads, react-oidc-context",
      "display": "4.2M",
      "asOf": "2026-11-20"
    },
    "F227": {
      "label": "License, react-oidc-context",
      "display": "MIT",
      "asOf": "2026-11-20"
    },
    "F228": {
      "label": "Package release, react-oidc-context",
      "display": "3.3.1",
      "asOf": "2026-11-20"
    },
    "F229": {
      "label": "Package release date, react-oidc-context",
      "display": "Mar 2026",
      "asOf": "2026-11-20"
    },
    "F230": {
      "label": "Install, react-oidc-context",
      "display": "npm install react-oidc-context@3.3.1 react@18 react-dom@18 oidc-client-ts@3.5.0",
      "asOf": "2026-11-20"
    },
    "F231": {
      "label": "Quickstart, react-oidc-context",
      "display": "import React from \"react\";\nimport { createRoot } from \"react-dom/client\";\nimport { AuthProvider, useAuth } from \"react-oidc-context\";\nconst host = document.createElement(\"div\");\ndocument.body.append(host);\nfunction Login() { const auth = useAuth(); return <button onClick={() => void auth.signinRedirect()}>Sign in</button>; }\ncreateRoot(host).render(<AuthProvider authority=\"https://issuer.example.com\" client_id=\"registered-client\" redirect_uri={window.location.origin + \"/callback\"} onSigninCallback={() => window.history.replaceState({}, document.title, window.location.pathname)}><Login /></AuthProvider>);\n",
      "asOf": "2026-11-20"
    },
    "F232": {
      "label": "Official description, react-oidc-context",
      "display": "Adds OpenID Connect and OAuth2 authentication to React through the context API.",
      "asOf": "2026-11-20"
    },
    "F233": {
      "label": "Quickstart source file, react-oidc-context",
      "display": "example/index.tsx, README.md",
      "asOf": "2026-11-20"
    },
    "F234": {
      "label": "Repository stars, react-oidc-context",
      "display": "1.0K",
      "asOf": "2026-11-20"
    },
    "F235": {
      "label": "Metadata discovery, react-oidc-context",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F236": {
      "label": "PKCE generation, react-oidc-context",
      "display": "Yes",
      "asOf": "2026-11-20"
    },
    "F237": {
      "label": "Client integration role, react-oidc-context",
      "display": "React AuthProvider, hooks, and authentication-state facade over oidc-client-ts. It handles callback interception and exposes the underlying UserManager; it is neither an independent protocol engine nor an exact re-export.",
      "asOf": "2026-11-20"
    },
    "F238": {
      "label": "Library name, simple-oauth2",
      "display": "simple-oauth2",
      "asOf": "2026-11-20"
    },
    "F239": {
      "label": "Monthly downloads, simple-oauth2",
      "display": "3.3M",
      "asOf": "2026-11-20"
    },
    "F240": {
      "label": "License, simple-oauth2",
      "display": "Apache-2.0",
      "asOf": "2026-11-20"
    },
    "F241": {
      "label": "Package release, simple-oauth2",
      "display": "5.1.0",
      "asOf": "2026-11-20"
    },
    "F242": {
      "label": "Package release date, simple-oauth2",
      "display": "Jun 2024",
      "asOf": "2026-11-20"
    },
    "F243": {
      "label": "Install, simple-oauth2",
      "display": "npm install simple-oauth2@5.1.0",
      "asOf": "2026-11-20"
    },
    "F244": {
      "label": "Quickstart, simple-oauth2",
      "display": "const { ClientCredentials } = require(\"simple-oauth2\");\nconst client = new ClientCredentials({ client: { id: process.env.OAUTH_CLIENT_ID, secret: process.env.OAUTH_CLIENT_SECRET }, auth: { tokenHost: process.env.OAUTH_TOKEN_HOST, tokenPath: process.env.OAUTH_TOKEN_PATH } });\nclient.getToken({}).then((token) => console.log(token.expired())).catch(console.error);\n",
      "asOf": "2026-11-20"
    },
    "F245": {
      "label": "Repository stars, simple-oauth2",
      "display": "1.6K",
      "asOf": "2026-11-20"
    },
    "F246": {
      "label": "Metadata discovery, simple-oauth2",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F247": {
      "label": "PKCE generation, simple-oauth2",
      "display": "No",
      "asOf": "2026-11-20"
    },
    "F248": {
      "label": "Client integration role, simple-oauth2",
      "display": "Node grant classes with explicit endpoint configuration, including authorization code and client credentials, plus AccessToken expiry, refresh, and revocation methods. A client-credentials token request is not an end-user sign-in session.",
      "asOf": "2026-11-20"
    }
  },
  "dataCheckedAt": "2026-11-20",
  "agent": {
    "exaCall": {
      "endpoint": "/search",
      "body": {
        "query": "Best JavaScript OAuth client libraries openid-client oauth4webapi simple-oauth2 badgateway code examples",
        "numResults": 5
      },
      "docsUrl": "https://exa.ai/docs/reference/search"
    },
    "calls": []
  }
}
