Generating Signed URL

To access our portal securely from your system, use the following code snippet to generate the required signed URL. And do make sure this URL will be for a single-time use only, upon refreshing the page in the middle of the process, you will be invalidated.

const express = require("express");
const crypto = require("crypto");
require("body-parser-xml")(express);



app.use(express.json());

app.post("/generate-signature", (req, res) => {
  // Fields from the webhook request, this will change every time
  const orgId = req.body.customerReferenceNo;

  // Partner's auth0 client id
  const clientId = req.body.clientId;

  // Partner's auth0 Sercret
  const clientSecret = req.body.clientSecret;

  // Credilinq's Portal URL
  const endpointUrl = req.body.endpointUrl;

  // Current Timestamp
 const timestamp = new Date().getTime();

  const hmacPayload =
        clientSecret +
        '|' +
        orgId +
        '|' +
        clientId +
        '|' +
        timestamp +
        '|' +
        clientSecret;


   const hmac = crypto.createHmac('sha256', secret)
    .update(hmacPayload)
    .digest('hex')


  const link = `${endpointUrl}/embeddedlogin?org_id=${orgId}&client_id=${clientId}&timestamp=${timestamp}&signature=${hmac}`

  res.status(200).send(link);
});

app.listen(PORT, () => console.log(`🚀 Server running on port ${PORT}`));