Generating policy and signature using from Javascript?
nizamani opened this issue · comments
We want to generate policy and signature using Javascript with nestJS but couldn't find anywhere in documentation how to do this. Right now we are using Php sdk with class FilestackSecurity to generate policy and signature but we want to move everything to JS. That's why I want to ask if there a way that we can use Javascipt server side to generate policy and signature?
import { createHmac } from 'crypto';
const policy = Buffer.from(JSON.stringify({
expiry: Date.now() / 1000 + 30 * 86400 * 630,
call: ['read', 'convert'],
})).toString('base64');
const signature = createHmac('sha256', config.env.FILESTACK_SECRET_KEY)
.update(policy)
.digest('hex');