Quick Start Guide

1. Installation

Install the SSO client library using npm or yarn:

npm install @doneisbetter/sso-client

# or using yarn
yarn add @doneisbetter/sso-client

2. Initialize the Client

Create an instance of the SSO client:

import { SSOClient } from '@doneisbetter/sso-client';

const sso = new SSOClient('https://sso.doneisbetter.com');

3. Implement Authentication

Add login functionality to your application:

// Register/login a user
const response = await sso.register({
  username: 'user@example.com'
});

// Check session status
const session = await sso.validateSession();
if (session.isValid) {
  console.log('User:', session.user);
}

// Logout
await sso.logout();

4. Handle Errors

Implement proper error handling:

try {
  const session = await sso.validateSession();
  if (session.isValid) {
    // User is authenticated
  }
} catch (error) {
  if (error.code === 'SESSION_EXPIRED') {
    // Redirect to login
  } else {
    // Handle other errors
  }
}

5. Next Steps

For more detailed information, check out these guides: