title: Generating JTI claim for JWT in javascript
body: <p>I am asking this since a colleague has been stuck on this for a few days now. The problem is, he's trying to use the JTI claim in his JWT but he can't seem to figure out how to properly generate it. Nowhere can we find a clear and straight to the point explanation on how to generate and format the JTI, if that is necessary at all. We would appreciate it if anyone could clear things up for us. </p>
  
  <p><strong>UPDATE:</strong>
  This is an example of the code used</p>
  
  <pre><code>var randomNumber1 = Math.floor(Math.random() * Math.floor(254));
  var randomText = Math.random().toString(36).substr(2, 12);
  var randomNumber2 = Math.floor(Math.random() * Math.floor(81458));
  
  var oHeader = {alg: 'HS256', cty: 'text/plain'};
  var oPayload = {};
  oPayload.publicKey = "myPublicKey";
  oPayload.schema = "mySchema";
  oPayload.baseUrl = "www.example.org";
  oPayload.exp = (new Date().getTime() / 1000|0)  + 5 * 60;
  oPayload.iss = "myIssuer";
  oPayload.domain = "myDomain";
  oPayload.jti = randomNumber1 + "-" + randomText + "-" + (new 
  Date().getTime() / 1000|0)  + 5 * 60;
  oPayload.iat = new Date().getTime() / 1000|0;
  
  var hash = CryptoJS.MD5("Message", (new Date().getTime() / 1000|0)  
  + 5 * 60);
  console.log(hash);
  </code></pre>
  
  <p>If more information is required, please do ask. </p>
  
  <p>Thanks in advance.</p>