Bluestep JS Documentation
    Preparing search index...

    Class Builder

    See Java.Crypto.Jwts

    Index
    • Returns an audience builder. Add audience values with add(aud), then call and() to return to this builder.

      Returns AudienceBuilder

    • Sets an arbitrary claim (a.k.a. body) param, if a parameter has already been set for that key then this method will override it.

      NOTE: If you pass a Java.Time.Date value, this library will convert that date value into the number of seconds since epoch

      Parameters

      • claimKey: string

        the key in the claim segment to write to

      • claimValue: string | number | Date

        the value to assign

      Returns this

    • Generates the final JWT with the configuration parameters and key signatures as set.

      Returns string

    • Sets the standard "exp" claim.

      Parameters

      • exp: Date

        the value to assign

      Returns this

    • Returns a header builder. Add header params with add(key, value), then call and() to return to this builder.

      Returns HeaderBuilder

    • Sets the standard "jti" claim.

      Parameters

      • jti: string

        the value to assign

      Returns this

    • Sets the standard "iat" claim.

      Parameters

      • iat: Date

        the value to assign

      Returns this

    • Sets the standard "iss" claim.

      Parameters

      • iss: string

        the value to assign

      Returns this

    • Sets the standard "nbf" claim.

      Parameters

      • nbf: Date

        the value to assign

      Returns this

    • Sets the value for standard "aud" parameter in the JWT's claim segment (Also known as the Body). If this property has already been set, then this method will override it. This is the same as calling claim("aud", "your value here");

      Parameters

      • aud: string

        the value to assign

      Returns this

      since jjwt 0.12; use audience().add(aud).and().

    • Sets an arbitrary header param, if a parameter for that key is already set, then this method will override it.

      Parameters

      • key: string

        they key for this parameter

      • value: string

        the value to write over it

      Returns this

      since jjwt 0.12; use header().add(key, value).and().

    • Sets the value for standard "jti" parameter in the JWT's claim segment (Also known as the Body). If this property has already been set, then this method will override it. This is the same as calling claim("jti", "your value here");

      Parameters

      • jti: string

        the value to assign

      Returns this

      since jjwt 0.12; use id(jti).

    • Sets the value for standard "iat" parameter in the JWT's claim segment (Also known as the Body). If this property has already been set, then this method will override it. This is the same as calling claim("iat", "your value here");

      NOTE: While it may seem confusing to pass a Java.Time.Date object, the library automatically converts that value into a number representing that date value as the number of seconds since epoch

      Parameters

      • iat: Date

        the value to assign

      Returns this

      since jjwt 0.12; use issuedAt(iat).

    • Sets the value for standard "iss" parameter in the JWT's claim segment (Also known as the Body). If this property has already been set, then this method will override it. This is the same as calling claim("iss", "your value here"); @param iss the value to assign @deprecated since jjwt 0.12; use issuer(iss)`.

      Parameters

      • iss: string

      Returns this

    • Sets the value for standard "nbf" parameter in the JWT's claim segment (Also known as the Body). If this property has already been set, then this method will override it. This is the same as calling claim("nbf", "your value here");

      Parameters

      • nbf: Date

        the value to assign

      Returns this

      since jjwt 0.12; use notBefore(nbf).

    • Sets the value for standard "sub" parameter in the JWT's claim segment (Also known as the Body). If this property has already been set, then this method will override it. This is the same as calling claim("sub", "your value here");

      Parameters

      • sub: string

        the value to assign

      Returns this

      since jjwt 0.12; use subject(sub).

    • set the key with which you are going to sign this token

      Parameters

      Returns this

      const pKey = B.crypto.createPrivateKeyFromPKCS8("RSA", privKey); const jwtBuilder = B.crypto.jwts.Jwts.builder(); const fullJsonWebToken = jwtBuilder .subject("user-1") .claim("key","value") .signWith(pKey) .compact(); // the compact method converts it to a string


      NOTE: The library sets the header parameter "alg" from the key: RS256 / RS384 / RS512
      for 2048 / 3072 / 4096-bit RSA keys.
      @param
    • Sets the standard "sub" claim.

      Parameters

      • sub: string

        the value to assign

      Returns this