RegisterLogin
DocsPricing
RegisterLogin
  • Getting Started
  • Introduction
  • Quick Start
  • SDKs
  • React
  • TypeScript
  • Next.js
  • Express
  • NestJS
  • Python
  • API Reference
  • Support and Resources
  • FAQ
  • Contact Support

AuthSafe

Product

HighlightFeatureIntegrationPricingFAQ

Company

AboutBlogContactSitemap

Developer

DashboardDocumentation

Legal

Terms & ConditionsPrivacyComplianceShippingCancellation

© 2026 AuthSafe. All rights reserved.

We value your privacy

This website uses cookies for anonymous analytics to help us improve your experience. No personal information is stored or shared. You can allow or reject analytics tracking at any time. See our Privacy Policy.

We use cookies for anonymous analytics. No personal info is stored. See our Privacy Policy.

Type Definitions

Complete TypeScript type reference for the authsafe-ts SDK.

OAuth Types

OAuthConfig

Configuration for OAuthService initialization.
interface OAuthConfig {
  clientId: string;
  redirectUri: string;
  scope?: string[];
  authority?: string;
  popupRedirectUri?: string;
  silentRedirectUri?: string;
  automaticSilentRenew?: boolean;
  env?: 'development' | 'production';
}
Properties:
  • clientId - OAuth client identifier from AuthSafe dashboard
  • redirectUri - Callback URL after authentication
  • scope - Requested scopes (default: ['openid', 'email', 'profile'])
  • authority - Custom authority URL (auto-detected if omitted)
  • popupRedirectUri - Popup authentication callback
  • silentRedirectUri - Silent token refresh callback
  • automaticSilentRenew - Enable automatic token renewal
  • env - Environment for secure cookie settings

User

Authenticated user object.
interface User {
  id_token: string;
  session_state: string | null;
  access_token: string;
  refresh_token?: string;
  token_type: string;
  scope: string;
  profile: UserProfile;
  expires_at: number;
  expires_in?: number;
  expired?: boolean;
  scopes: string[];
}
Profile:
interface UserProfile {
  sub: string; // User ID
  name?: string;
  email?: string;
  email_verified?: boolean;
  picture?: string;
  iss: string; // Issuer
  aud: string; // Audience
  exp: number; // Expiration time
  iat: number; // Issued at
}

TokenResponse

Response from token endpoint.
interface TokenResponse {
  access_token: string;
  token_type: string;
  expires_in: number;
  refresh_token?: string;
  id_token?: string;
  scope?: string;
}

SignoutOptions

Options for signout methods.
interface SignoutOptions {
  id_token_hint?: string;
  post_logout_redirect_uri?: string;
  state?: string;
}

MFA Types

MfaMethod

Configured multi-factor authentication method.
interface MfaMethod {
  id: string;
  type: 'totp' | 'email';
  is_primary: boolean;
  created_at: string;
  last_used_at?: string;
}

TotpSetupResponse

TOTP setup data with QR code.
interface TotpSetupResponse {
  secret: string; // BASE32 encoded secret
  qr_code: string; // Data URL for QR code image
}

MfaVerifyResponse

MFA verification result.
interface MfaVerifyResponse {
  success: boolean;
  message?: string;
}

SSO Types

SSOConnection

SSO provider configuration.
interface SSOConnection {
  id: string;
  name: string;
  provider: 'saml' | 'google' | 'microsoft' | 'github' | 'custom-oidc';
  enabled: boolean;
  created_at: string;
  updated_at?: string;
  metadata?: Record<string, any>;
}

SAMLConfig

SAML provider configuration.
interface SAMLConfig {
  entity_id: string;
  sign_in_url: string;
  certificate: string;
  sign_request?: boolean;
  signature_algorithm?: 'sha256' | 'sha512';
  name_id_format?: string;
  requested_attributes?: string[];
}

OIDCConfig

OIDC provider configuration.
interface OIDCConfig {
  client_id: string;
  client_secret: string;
  authorization_endpoint: string;
  token_endpoint: string;
  userinfo_endpoint?: string;
  jwks_uri?: string;
  scope?: string[];
  response_type?: string;
}

User Types

UserProfile

Extended user information.
interface UserProfile {
  id: string;
  email: string;
  email_verified: boolean;
  name?: string;
  given_name?: string;
  family_name?: string;
  picture?: string;
  locale?: string;
  timezone?: string;
  phone_number?: string;
  phone_number_verified?: boolean;
  created_at: string;
  updated_at: string;
  last_login?: string;
  metadata?: Record<string, any>;
}

UserUpdateData

Data for updating user profiles.
interface UserUpdateData {
  name?: string;
  given_name?: string;
  family_name?: string;
  picture?: string;
  locale?: string;
  timezone?: string;
  phone_number?: string;
  metadata?: Record<string, any>;
}

PasswordChangeData

Password change request.
interface PasswordChangeData {
  current_password: string;
  new_password: string;
  confirm_password?: string;
}

Branding Types

BrandingConfig

Application branding configuration.
interface BrandingConfig {
  logo: string;
  favicon: string;
  primary_color: string;
  secondary_color: string;
  background_color: string;
  text_color: string;
  company_name: string;
  support_email?: string;
  privacy_url?: string;
  terms_url?: string;
  custom_css?: string;
}

Utility Types

PasswordStrength

Password strength analysis result.
interface PasswordStrength {
  score: number; // 0-4
  strength: 'weak' | 'medium' | 'strong' | 'very-strong';
  feedback: string[];
  suggestions: string[];
}
Score Levels:
  • 0 - Too weak
  • 1 - Weak
  • 2 - Medium
  • 3 - Strong
  • 4 - Very strong

API Response Types

ApiResponse

Standard API response wrapper.
interface ApiResponse<T> {
  success: boolean;
  data?: T;
  error?: {
    code: string;
    message: string;
    details?: any;
  };
}

PaginatedResponse

Paginated list response.
interface PaginatedResponse<T> {
  items: T[];
  total: number;
  page: number;
  limit: number;
  has_more: boolean;
}

Error Types

AuthError

Authentication error.
interface AuthError extends Error {
  error: string;
  error_description?: string;
  state?: string;
}

ApiError

API request error.
interface ApiError extends Error {
  status: number;
  code: string;
  details?: any;
}

Usage Examples

Type Assertions

import { User, OAuthConfig, MfaMethod } from 'authsafe-ts';

const config: OAuthConfig = {
  clientId: 'my-client-id',
  redirectUri: 'https://myapp.com/callback',
  scope: ['openid', 'profile', 'email'],
};

const user: User | null = await oauthService.getUser();

if (user) {
  const userId: string = user.profile.sub;
  const email: string = user.profile.email!;
}

Custom Type Guards

function isTotpMethod(method: MfaMethod): boolean {
  return method.type === 'totp';
}

function hasRefreshToken(
  user: User | null,
): user is User & { refresh_token: string } {
  return user !== null && typeof user.refresh_token === 'string';
}

Generic API Function

async function fetchData<T>(
  httpService: HttpService,
  endpoint: string,
): Promise<ApiResponse<T>> {
  try {
    const data = await httpService.get<T>(endpoint);
    return { success: true, data };
  } catch (error) {
    return {
      success: false,
      error: {
        code: 'API_ERROR',
        message: error.message,
      },
    };
  }
}

Related

  • OAuthService - OAuth service reference
  • Utilities - Helper functions
  • TypeScript SDK Overview