1. Authentication

Authentication

Check if HAT exists

Parameters

Type

hatDomain

string

Example:

const hatDomain = "testing.hubat.net";
try {
   const res = hat.auth().isDomainRegistered(hatDomain);    
   if (res) {
        // HAT domain is registered
   }   
} catch (e) {
    // HAT domain doesn't exist
}

Sign out

Example:

hat.auth().signOut();

Get HAT domain

Example:

const res = hat.auth().getHatDomain();    
if (res) {
    // Returns the HAT Domain
    // eg. testing.hubat.net
}

Get auth token

Example:

const res = hat.auth().getToken();    
if (res) {
    // Returns the auth token
}

Check if token has expired

Example:

const token = '<auth-token>';

if (hat.auth().isTokenExpired(token)) {
    // Token has expired
}

Generate HAT login URL

Example:

const hatDomain = 'testing.hubat.net';
const appId = 'our-app-id';
const redirect = 'callback-url';
const fallback = 'fallback-url';

const url = hat.auth().generateHatLoginUrl(hatDomain, appId, redirect, fallback);    
if (url) {
    window.location.href = url;
}

Last updated