Standard library - auth

module auth

  def emptyToken : null -> token   // since PR 1270

  def signIn : string -> string -> string -> result(data, data)
  def signUp : string -> string -> string -> data -> result(data, data)
  def requestPasswordReset : string -> string -> result(data, string)
module end

The empty token

auth.emptyToken() can be used as a default value to substitute a token when there is actually none. These empty tokens are permitted for authentication (an empty string is passed), and string.ofToken will return the empty string.

Auth0 username-password flow

auth.signIn, auth.signUp, and auth.requestPasswordReset currently work with auth0 auth plugins to implement in-app username+password flows (not generally advised; redirecting to a web OAuth flow is better). The first argument to all three is the name of the auth plugin (typically just "auth0"), the second is the username, and for signIn and signUp, the third argument is the password. For signUp, there is also a fourth argument, a map of optional user info to include in the user record.