0.9.0 • Published 2 years ago

@ew-did-registry/jwt v0.9.0

Weekly downloads
388
License
GPL-3.0-or-later
Repository
-
Last release
2 years ago

JWT Package

The JWT package is internally consumed by the Claims package to perform necessary operations on JWTs.

// Initiate the JWT implementation
const jwt = new IJWT(keyPair);

// Provide digitally signed JWT using ECDSA using P-256 curve and SHA-256 hash algorithm
// Various options can be specified, including Token expiration
// Returns encdoded token
try {
  const token = await jwt.sign(payload, { algorithm: 'ES256' });
} catch(e) {
  console.log(e);
}

// Siganture verification; options can be specified 
// Returns decoded payload, if signature is valid. Throws error otherwise
try {
  const decoded = await jwt.verify(token, publicKey);
} catch(e) {
  console.log(e);
}

// Decoding JWT without verifying the signature. This is require to retrieve DID of the subject
// Returns decoded object, which consists of header and payload
// If "complete" option is default(false), only payload is returned
// "json" options forces JSON.parse on the payload even if the header doesn't contain "typ":"JWT"
const decoded = jwt.decode(token, {complete: true});
console.log(decoded.header);
console.log(decoded.payload.did);
0.9.0

2 years ago

0.8.0

3 years ago

0.7.0

3 years ago

0.6.0

4 years ago

0.5.2-alpha.96.0

4 years ago

0.5.2-alpha.94.0

4 years ago

0.5.2-alpha.90.0

4 years ago

0.5.2-alpha.84.0

4 years ago

0.5.2-alpha.78.0

4 years ago

0.5.2-alpha.75.0

4 years ago

0.5.2-alpha.65.0

4 years ago

0.5.2-alpha.62.0

4 years ago

0.5.2-alpha.57.0

4 years ago

0.5.2-alpha.52.0

4 years ago

0.5.2-alpha.44.0

4 years ago

0.5.2-alpha.40.0

4 years ago

0.5.2-alpha.41.0

4 years ago

0.5.0

4 years ago

0.4.0

4 years ago

0.3.0

4 years ago

0.2.0

4 years ago

0.1.0-alpha.0

4 years ago