How to use the @arcblock/did.toStrictHex function in @arcblock/did

To help you get started, we’ve selected a few @arcblock/did examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ArcBlock / forge-js / did / did-auth / lib / jwt.js View on Github external
const decode = (token, payloadOnly = true) => {
  const [headerB64, bodyB64, sigB64] = token.split('.');
  const header = JSON.parse(fromBase64(headerB64));
  const body = JSON.parse(fromBase64(bodyB64));
  const sig = Buffer.from(fromBase64(sigB64)).toString('hex');
  if (payloadOnly) {
    return body;
  }
  return { header, body, signature: `0x${toStrictHex(sig)}` };
};