Skip to main content

Client Libraries

The Upollo client libraries can be used identify users before they login, or if they use your application/site from multiple devices.

Client libraries are available for web (running in the browser), and for native iOS and Android mobile applications. They can be paired with a server library to protect logins, payments, etc.

Follow the quick start to get set up using a client library, or read on below for usage details.

Availability

Upollo has client libraries available for the following environments and languages:

  • Web (JavaScript or TypeScript): Available on NPM as @userwatch/web
  • iOS (Swift): Available via Cocoapods as Userwatch
  • Android (Kotlin or Java): Available in the Maven Central Repository as co.userwatch:userwatch-android

API

The main UserwatchClient and its methods are outlined below. UserInfo, EventType and the response types are all protocol buffers. Their details are documented in Userwatch/user-watchproto.

// To use:
// import UserwatchClient from "@userwatch/web";

export class UserwatchClient {
// Accepts the project's public api key and an optional options object.
// 'options' can contain an optional 'url' to override the userwatch api.
constructor(publicApiKey: string, options?: { url?: string });

// Inform Userwatch of an event in your client application, and get back
// an immediate assessment of the user.
//
// Include any UserInfo you have, or an empty UserInfo if you have none.
async assess(
userinfo: uwproto_UserInfo | User,
eventtype: uwproto_EventType = uwproto_EventType.EVENT_TYPE_LOGIN
): Promise<uwproto_AnalysisResponse>;

// Inform Userwatch of an event in your client application, and get back
// a receipt in the form of an EventToken.
//
// Include any UserInfo you have, or an empty UserInfo if you have none.
async track(
userinfo: uwproto_UserInfo | User,
eventtype: uwproto_EventType = uwproto_EventType.EVENT_TYPE_LOGIN
): Promise<uwproto_EventResponse>;

// Quickly check for any known issues with an email, password or phone.
// While these typically involve a round trip to Upollo servers, a raw
// password is never shared beyond the Upollo client library; its hash
// is used instead.
async checkEmail(email: string): Promise<uwproto_CheckEmailResponse>;
async checkPassword(password: string): Promise<uwproto_CheckPasswordResponse>;
async checkPhone(phone: string): Promise<uwproto_CheckPhoneResponse>;
}