@transak/transak-kyc-sdk
TypeScript icon, indicating that this package has built-in type declarations

3.1.3 • Public • Published

Transak SDK

A library for decentralised applications to KYC their global user base.

Example usage

<div id="transakMount"></div>
import { TransakConfig, Transak, KycLevel } from '@transak/transak-kyc-sdk';

const transakConfig: TransakConfig = {
  apiKey: '<your-api-key>', // (Required)
  environment: Transak.ENVIRONMENTS.STAGING/Transak.ENVIRONMENTS.PRODUCTION, // (Required)
  containerId: 'transakMount', // Id of the element where you want to initialize the iframe
  
  didSessionId: '1ee48fb0-18b8-478e-b232-9a88b87fd908', // The session ID created via the API
  kycLevel: KycLevel.SIMPLE, // | STANDARD | ENHANCED
  
  widgetWidth: '100px', // optional
  widgetHeight: '300px', // optional
};

let transak = new Transak(transakConfig);

transak.init();

// To get all SDK events
Transak.on('*', (data) => {
  console.log(data);
});

// This will trigger when the user closed the widget
Transak.on(Transak.EVENTS.TRANSAK_WIDGET_CLOSE, () => {
  console.log('Transak SDK closed!');
});

/*
* This will trigger when the user completes the KYC process
*/
Transak.on(Transak.EVENTS.TRANSAK_KYC_COMPLETE, () => {
  // ...
});

/*
* This will trigger when the user is on the Decentralized ID page and
* clicks the button to create a credential claim
*/
Transak.on(Transak.EVENTS.TRANSAK_CREDENTIAL_CLAIM_CREATED, () => {
  // ...
});

Using Modal UI

If you want to use our modal UI, do not pass the containerId and use transak.close() instead of transak.cleanup()

React Gotchas

Do not forget to clean up by using the transak.cleanup() or transak.close()

useEffect(() => {
  return () => {
    transak.cleanup();
  };
}, []);

Package Sidebar

Install

npm i @transak/transak-kyc-sdk

Weekly Downloads

6

Version

3.1.3

License

ISC

Unpacked Size

78.5 kB

Total Files

8

Last publish

Collaborators

  • transakgs
  • aditya1910
  • kutsav
  • sshandilya
  • yeshuagarwal