Dataswyft API Platform: Developers Docs
WebsiteGitHubSlackLogin
  • About Dataswyft
    • Community & Support
  • Learn about Dataswyft Platform
    • Decentralized Data Servers
    • Personal Data Account
      • HMIC Permissions
      • Namespaces
      • Single Sign-On
    • Data Wallet
      • Data Wallet Canvas and Solutions
      • CheckD Data Wallet: Release Notes
    • Dataswyft One
      • Compute Tools
  • Build on Dataswyft Platform
    • Dataswyft One APIs
      • Data API
        • Filtering, Querying & Transforming Data
        • Data Debit
      • File Storage API
      • Computations API
      • Postman Collection
    • Integrating with Data Wallets
    • Getting Started
      • Quick Start
      • Developers Portal
        • Updating and Submitting an Application
        • Deleting an Application
        • Application Statuses
      • Application Example - React
        • 1. Environment Setup
        • 2. Create Main Structure
        • 3. Main Page & Routing
        • 4. User Authentication
        • 6. CRUD Operations
        • 5. Component Pages
  • Deploy
    • Application Review
    • Rating Assurance & Certification
    • Live Application Ratings
  • Knowledge Base
    • Security Practices
    • FAQ
    • Glossary of Terms
  • Dataswyft
Powered by GitBook
On this page

Was this helpful?

  1. Build on Dataswyft Platform
  2. Advanced Topics
  3. User Journeys
  4. Password Management
  5. Guides
  6. JavaScript

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 3 years ago

Was this helpful?