I am facing problem in creating the Sinch auth ticket for Android and IOS client using Nodejs. I tried sinch-ticketgen NPM module but it is generating tickets for javascript only, we can not use this ticket for Android and IOS clients.
Following is the code snippet I am using for the ticket generation but it is not working,
const crypto = require('crypto');
const shasum = crypto.createHash('sha1');
const key = '0b25bb2d-f5dd-4337-9f99-a318196f886a';
const secret = 'm1aur2Q4FUWWNuMlKq3KKg==';
const userId = 'sanket';
const sequence = 0;
const stringToSign = userId + key + sequence + secret;
shasum.update(stringToSign);
const singnature = shasum.digest('utf8'); //utf8
console.log('Signature ', singnature.toString('base64'));
const token = singnature.toString('base64').trim();
console.log(token);
Pseducode for the ticket generation is given in the https://www.sinch.com/docs/voice/ios/#applicationauthentication
I tried java example its working fine, not getting where I am making mistake in Nodejs ticket creation.
Following is the working Nodejs snippet for it.
const crypto = require('crypto');
const shasum = crypto.createHash('sha1');
const key = '0b25bb2d-f5dd-4337-9f99-a318196f886a';
const secret = 'm1aur2Q4FUWWNuMlKq3KKg==';
const userId = 'sanket';
const sequence = 0;
const stringToSign = userId + key + sequence + secret;
shasum.update(stringToSign);
const singnature = shasum.digest();
console.log('Signature ', singnature.toString('base64'));
const token = singnature.toString('base64').trim();
console.log(token);