How to use the openid-client.generators.codeChallenge function in openid-client

To help you get started, we’ve selected a few openid-client examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github stelace / stelace / src / services / authentication.js View on Github external
}

      const client = await getOAuthClient({
        publicPlatformId,
        provider,
        ssoConnection,
        serverPort,
        protocol: 'openid'
      })

      let codeVerifier
      let codeChallenge

      if (ssoConnection.pkceEnabled) {
        codeVerifier = generators.codeVerifier()
        codeChallenge = generators.codeChallenge(codeVerifier)
      }

      // prevents CSRF attack by verifying the returned state matches this value
      const state = await storeAuthenticationValue({
        platformId,
        env,
        provider,
        type: 'oAuthLoginState',
        data: { codeVerifier }
      })

      const authorizationParams = {
        redirect_uri: getSSOLoginCallbackUrl({ publicPlatformId, provider, serverPort }),
        response_type: 'code',
        scope: ssoConnection.scope,
        state