Comment on page
Webhooks
elKYC (Allpass) uses webhooks to notify your backend when an event happens in your client-side SDK. Webhooks are useful for asynchronous events like when a user completes a Verification, or passes any step. You should specify your backend endpoint url and get your AES-256-CBC key.
You can do it within workplace
Integration page.
Every application has it's own AES-256-CBC key. Webhook data is encrypted with this key
The Allpass webhook request has the same structure as all Allpass responses:
1
export class ResponseEntity {
2
@ApiProperty()
3
status: boolean;
4
5
@ApiProperty({ example: 200 })
6
statusCode: number;
7
8
@ApiProperty({ type: String })
9
data: string;
10
11
@ApiProperty({ example: '2021-08-20T14:52:33.648Z' })
12
time: string;
13
14
constructor(data: string) {
15
this.status = true;
16
this.statusCode = 200;
17
this.data = data;
18
this.time = new Date().toISOString();
19
}
20
}
Where data is encrypted string.
Webhook data must be decrypted before use with your AES-256-CBC key. Example:
1
import crypto from 'crypto';
2
3
function decryptData(encryptedTextWithIv: string, key: string): string {
4
const keyBuff = Buffer.from(key, 'hex');
5
const iv = Buffer.from(encryptedTextWithIv.slice(0, 32), 'hex');
6
const encryptedText = encryptedTextWithIv.slice(32);
7
const decipher = crypto.createDecipheriv('aes-256-cbc', keyBuff, iv);
8
let decrypted = decipher.update(encryptedText, 'hex', 'utf8');
9
decrypted += decipher.final('utf8');
10
11
return decrypted;
12
}
13
14
const aes256cbc = `*************`; // Your crypt key from integration page
15
16
const encryptedDataString = '... Encrypted data in Base64 ...';
17
const decryptedDataString = decryptData(aes256cbc, encryptedDataString);
18
19
console.log('Decrypted data object:', JSON.parse(decryptedDataString));
Example of encrypting data for public-api request:
1
import crypto from 'crypto';
2
3
function encryptData(data: any, key: string): string {
4
const keyBuff = Buffer.from(key, 'hex');
5
const iv = crypto.randomBytes(16);
6
const cipher = crypto.createCipheriv('aes-256-cbc', keyBuff, iv);
7
let encrypted = cipher.update(JSON.stringify(data), 'utf8', 'hex');
8
encrypted += cipher.final('hex');
9
10
return iv.toString('hex') + encrypted;
11
}
12
13
const aes256cbc = `*************`; // Your crypt key from integration page
14
const data = {}; // you data object
15
16
try {
17
const encryptedDataString = encryptData(data, aes256cbc);
18
19
console.log('Encrypted data string:', encryptedDataString);
20
} catch (e) {
21
console.log(e);
22
}
Last modified 3mo ago