Overview
The FAD SDK supports multiple environments to separate testing and production workloads. Use the getFadEnvironments() method to retrieve available environment values.
getFadEnvironments()
Static method that returns an object containing all available SDK environments.
static getFadEnvironments (): FadEnvironment
Return Value
Returns an object with environment constants:
Test/development environment for safe testing without affecting production data
Production environment for live applications
Usage
Basic Environment Configuration
import FadSDK from '@fad-producto/fad-sdk' ;
const TOKEN = 'your-fad-sdk-token' ;
// Get available environments
const environments = FadSDK . getFadEnvironments ();
console . log ( environments );
// Output: { UATHA: 2, PROD: 3 }
// Initialize with UATHA (test) environment
const options = {
environment: FadSDK . getFadEnvironments (). UATHA
};
const FAD_SDK = new FadSDK ( TOKEN , options );
Environment Selection
UATHA (Test)
PROD (Production)
Use the UATHA environment for development and testing. const options = {
environment: FadSDK . getFadEnvironments (). UATHA
};
const FAD_SDK = new FadSDK ( TOKEN , options );
When to use UATHA:
Development and testing
Integration testing
QA validation
Demos and proof of concepts
Training and onboarding
Use the PROD environment for live production applications. const options = {
environment: FadSDK . getFadEnvironments (). PROD
};
const FAD_SDK = new FadSDK ( TOKEN , options );
When to use PROD:
Live production applications
Real user data processing
Production deployments
Ensure thorough testing in UATHA before deploying to PROD.
Environment Values
UATHA
The test/development environment. Characteristics:
Safe for testing and development
Isolated from production data
May have different rate limits
Used for integration testing
Base URL: Points to FAD’s testing infrastructure
Example:
import FadSDK from '@fad-producto/fad-sdk' ;
const FAD_SDK = new FadSDK ( TOKEN , {
environment: FadSDK . getFadEnvironments (). UATHA
});
try {
const response = await FAD_SDK . startRegula (
credentials ,
FadSDK . Constants . Regula . CaptureType . DOCUMENT_READER ,
true ,
true ,
configuration
);
console . log ( 'Test response:' , response );
} finally {
FAD_SDK . end ();
}
PROD
The production environment. Characteristics:
Live production infrastructure
Real user data processing
Production rate limits and quotas
Subject to SLA guarantees
Base URL: Points to FAD’s production infrastructure
Example:
import FadSDK from '@fad-producto/fad-sdk' ;
const FAD_SDK = new FadSDK ( TOKEN , {
environment: FadSDK . getFadEnvironments (). PROD
});
try {
const response = await FAD_SDK . startFacetec (
credentials ,
configuration
);
console . log ( 'Production response:' , response );
} finally {
FAD_SDK . end ();
}
Environment-Based Configuration
Dynamic Environment Selection
import FadSDK from '@fad-producto/fad-sdk' ;
// Determine environment based on your app's configuration
const isProduction = process . env . NODE_ENV === 'production' ;
const options = {
environment: isProduction
? FadSDK . getFadEnvironments (). PROD
: FadSDK . getFadEnvironments (). UATHA
};
const FAD_SDK = new FadSDK ( TOKEN , options );
console . log ( `SDK initialized in ${ isProduction ? 'PROD' : 'UATHA' } mode` );
Environment Configuration Object
import FadSDK from '@fad-producto/fad-sdk' ;
const CONFIG = {
development: {
environment: FadSDK . getFadEnvironments (). UATHA ,
debug: true ,
verbose: true
},
staging: {
environment: FadSDK . getFadEnvironments (). UATHA ,
debug: true ,
verbose: false
},
production: {
environment: FadSDK . getFadEnvironments (). PROD ,
debug: false ,
verbose: false
}
};
const currentEnv = process . env . APP_ENV || 'development' ;
const config = CONFIG [ currentEnv ];
const FAD_SDK = new FadSDK ( TOKEN , config );
Custom Base URLs
You can override the default environment URLs by providing a custom baseUrl in the options:
import FadSDK from '@fad-producto/fad-sdk' ;
const options = {
environment: FadSDK . getFadEnvironments (). PROD ,
// Override with custom URLs
baseUrl: {
iframeUrl: 'https://custom-iframe.yourdomain.com' ,
fadWebUrl: 'https://custom-web.yourdomain.com' ,
biometricsByStepsUrl: 'https://custom-biometrics.yourdomain.com'
}
};
const FAD_SDK = new FadSDK ( TOKEN , options );
Custom base URLs override the default environment URLs. Ensure your custom URLs point to valid FAD SDK endpoints.
Best Practices
Always test in UATHA first
Before deploying any changes to production, thoroughly test all functionality in the UATHA environment. // Development/Staging
const devOptions = {
environment: FadSDK . getFadEnvironments (). UATHA
};
// Only after successful testing
const prodOptions = {
environment: FadSDK . getFadEnvironments (). PROD
};
Use environment variables
Store environment configuration in environment variables rather than hardcoding. // .env.development
FAD_ENVIRONMENT = UATHA
FAD_TOKEN = dev - token
// .env.production
FAD_ENVIRONMENT = PROD
FAD_TOKEN = prod - token
// Application code
const envMap = {
'UATHA' : FadSDK . getFadEnvironments (). UATHA ,
'PROD' : FadSDK . getFadEnvironments (). PROD
};
const options = {
environment: envMap [ process . env . FAD_ENVIRONMENT ] || FadSDK . getFadEnvironments (). UATHA
};
const FAD_SDK = new FadSDK ( process . env . FAD_TOKEN , options );
Separate credentials per environment
Use different tokens and credentials for each environment. const credentials = {
UATHA: {
token: process . env . FAD_TOKEN_UATHA ,
license: process . env . LICENSE_KEY_UATHA
},
PROD: {
token: process . env . FAD_TOKEN_PROD ,
license: process . env . LICENSE_KEY_PROD
}
};
const env = process . env . NODE_ENV === 'production' ? 'PROD' : 'UATHA' ;
const config = credentials [ env ];
const FAD_SDK = new FadSDK ( config . token , {
environment: FadSDK . getFadEnvironments ()[ env ]
});
Log environment information
Environment Comparison
Feature UATHA (Test) PROD (Production) Purpose Development & Testing Live Production Data Test/Mock Data Real User Data Rate Limits Generous for testing Production quotas SLA Best effort Guaranteed uptime Monitoring Basic Full monitoring & alerts Cost Free/Reduced Production pricing
Default Environment
If no environment is specified in the options, the SDK defaults to UATHA (test environment).
// These are equivalent:
const FAD_SDK_1 = new FadSDK ( TOKEN );
const FAD_SDK_2 = new FadSDK ( TOKEN , {
environment: FadSDK . getFadEnvironments (). UATHA
});
Troubleshooting
Wrong environment being used
Verify your environment configuration: const environments = FadSDK . getFadEnvironments ();
console . log ( 'Available environments:' , environments );
const options = {
environment: FadSDK . getFadEnvironments (). PROD
};
console . log ( 'Selected environment:' , options . environment );
console . log ( 'Is PROD?' , options . environment === environments . PROD );
Ensure you’re using the correct token for the selected environment:
UATHA tokens only work in UATHA environment
PROD tokens only work in PROD environment
// Check token matches environment
const isProd = options . environment === FadSDK . getFadEnvironments (). PROD ;
const tokenEnv = TOKEN . includes ( 'prod' ) ? 'PROD' : 'UATHA' ;
if ( isProd && tokenEnv !== 'PROD' ) {
console . warn ( 'Token mismatch: Using UATHA token in PROD environment' );
}
Next Steps
Constructor Learn more about SDK initialization
Constants Explore SDK constants and values
FadSDK Class View all available methods