Skip to main content
The primary class of the SDK. Instantiate it with your API key, then call verify() to launch the employment verification widget.

Constructor

new Transcrypts(options: TranscryptsOptions)
Creates a new Transcrypts SDK instance.

Parameters

ParameterTypeRequiredDescription
optionsTranscryptsOptionsYesConfiguration options for the SDK.

Exceptions

Error messageCondition
Transcrypts: apiKey is requiredoptions.apiKey is falsy or missing.

Examples

Basic initialization:
import { Transcrypts } from 'transcrypts';

const transcrypts = new Transcrypts({
  apiKey: 'your-api-key',
});
With all options:
import { Transcrypts } from 'transcrypts';

const transcrypts = new Transcrypts({
  apiKey: 'your-api-key',
  widgetUrl: 'https://custom-widget.example.com',
  containerStyle: {
    backgroundColor: 'rgba(0, 0, 0, 0.8)',
  },
});

verify(options)

verify(options: VerifyOptions): Promise<VerificationResult>
Opens the Transcrypts verification widget in a full-screen iframe overlay and returns a promise that resolves when the verification flow completes. The widget is mounted to document.body as a fixed-position overlay. Body scroll is disabled while the widget is open. The overlay and iframe are removed automatically when the verification completes, fails, or is dismissed by the user.

Parameters

ParameterTypeRequiredDescription
optionsVerifyOptionsYesVerification options including SSN and optional user info.

Returns

Promise<VerificationResult> — Resolves with a VerificationResult object.

Promise Resolution Scenarios

Scenariosuccessverifiederror
Verification succeededtruetrueundefined
User closed the widgetfalsefalse{ code: 'USER_CLOSED', message: 'User closed the verification widget' }
User pressed Escape keyfalsefalse{ code: 'USER_CLOSED', message: 'User closed the verification widget' }
User clicked backdropfalsefalse{ code: 'USER_CLOSED', message: 'User closed the verification widget' }

Promise Rejection Scenarios

ScenarioError message
options.ssn is falsyTranscrypts: ssn is required
Verification failedMessage from widget payload, or 'Verification failed' as fallback

Example

const transcrypts = new Transcrypts({ apiKey: 'your-api-key' });

try {
  const result = await transcrypts.verify({
    ssn: '123-45-6789',
    user: {
      firstName: 'Jane',
      lastName: 'Doe',
      email: 'jane@example.com',
    },
  });

  if (result.success && result.verified) {
    console.log('Verification ID:', result.verificationId);
    console.log('Work history:', result.workExperience);
  } else if (result.error?.code === 'USER_CLOSED') {
    console.log('User dismissed the widget');
  }
} catch (error) {
  console.error('Verification failed:', error.message);
}

on(eventType, callback)

on(
  eventType: TranscryptsEventType,
  callback: (event: TranscryptsEvent) => void
): () => void
Subscribes a callback function to a specific widget event type. Multiple callbacks can be registered for the same event type.

Parameters

ParameterTypeRequiredDescription
eventTypeTranscryptsEventTypeYesThe event type to listen for.
callback(event: TranscryptsEvent) => voidYesFunction called when the event fires.

Returns

() => void — An unsubscribe function. Call it to remove the callback.

Example

const transcrypts = new Transcrypts({ apiKey: 'your-api-key' });

// Subscribe to the 'ready' event
const unsubscribe = transcrypts.on('ready', (event) => {
  console.log('Widget is ready:', event);
});

// Subscribe to verification completion
transcrypts.on('verification_complete', (event) => {
  console.log('Verification complete:', event.payload);
});

// Later: unsubscribe from the 'ready' event
unsubscribe();