Class for handling Compact JSON Web Tokens (JWTs). This class provides methods to create, verify, and decode JWTs using various cryptographic algorithms. More information on JWTs can be found here

Constructors

Properties

Methods

Constructors

Properties

didResolver: UniversalResolver = ...

DID Resolver instance for resolving decentralized identifiers.

Methods

  • Parses a JWT without verifying its signature.

    Parameters

    • options: ParseJwtOptions

      Parameters for JWT decoding, including the JWT string.

    Returns JwtParseResult

    both encoded and decoded JWT parts

    Example

    const { encoded: encodedJwt, decoded: decodedJwt } = Jwt.parse({ jwt: myJwt });
    
  • Creates a signed JWT.

    Parameters

    • options: SignJwtOptions

      Parameters for JWT creation including signer DID and payload.

    Returns Promise<string>

    The compact JWT as a string.

    Example

    const jwt = await Jwt.sign({ signerDid: myDid, payload: myPayload });
    
  • Verifies a JWT.

    Parameters

    Returns Promise<JwtVerifyResult>

    Verified JWT information including signer DID, header, and payload.

    Example

    const verifiedJwt = await Jwt.verify({ jwt: myJwt });