generateAuthURL

Generate a URL to redirect the user to the JoyID App authorization page. This function cound be useful when you do not need to initiate authorize request immediately.

Types

function generateAuthURL (
  request: AuthRequest,
  type: 'popup' | 'redirect'
): string

interface AuthRequest {
  /**
   * The URL of your app that JoyID app should redirect to after authentication
   */
  redirectURL: string
  /**
   * name of your app
   */
  name?: string
  /**
   * logo of your app
   */
  logo?: string
  /**
   * The challenge that was requested to be signed
   */
  challenge?: string
  /**
   * Custom state that will be returned to your app after authentication
   */
  state?: any
}

Example

async function myAuthWithRedirect() {
  const request = {
    redirectURL: 'https://example.com',
    title: 'Example App',
    logo: 'https://example.com/logo.png',
    challenge: 'Sign this message',
  }
  const url = generateAuthURL(request, 'redirect')
  // do something with the url
  // etc. await myFunction(url)
  // custom redirect
  window.location.href = url
}
Table of Contents