Negatively Proportional Model
    Have ideas to improve npm?Join in the discussion! »

    @lindorm-io/jwt
    TypeScript icon, indicating that this package has built-in type declarations

    0.2.1 • Public • Published

    @lindorm-io/jwt

    JWT tools for lindorm.io packages.

    Installation

    npm install --save @lindorm-io/jwt

    Usage

    Token Issuer

    const issuer = new TokenIssuer({
      issuer: "https://authentication.service/",
      keystore: keyPairKeyStore,
      logger: winstonLogger,
    });
    
    const {
      id: tokenId,
      expiresIn,
      expires,
      level,
      token,
    } = issuer.sign({
      audience: "access",
      expiry: "5 minutes",
      subject: "account_id",
      payload: { withData: "data" },
    });
    
    const {
      id,
      payload,
      subject,
    } = issuer.verify({
      audience: "access",
      token,
      issuer: "https://authentication.service/",
    });
    
    TokenIssuer.dateToExpiry(new Date("2020-01-01 08:00:00.000")) // -> 1577865600
    TokenIssuer.expiryToDate(1577865600) // -> new Date("2020-01-01 08:00:00.000")
    
    TokenIssuer.getExpiry("10 seconds") // -> 1577865610
    TokenIssuer.getExpiry(20) // -> 1577865610
    TokenIssuer.getExpiry(new Date("2020-01-01 08:00:00.000")) // -> 1577865600

    Token Sanitiser

    sanitiseToken(token) // -> <base64-header>.<base64-body>

    Keywords

    none

    Install

    npm i @lindorm-io/jwt

    DownloadsWeekly Downloads

    8

    Version

    0.2.1

    License

    ISC

    Unpacked Size

    37.7 kB

    Total Files

    62

    Last publish

    Collaborators

    • avatar