Class JsonWebTokenManager<PROPS, JWT_PROPS, CREATION_ARGS, TEST_ARGS>

Manages the creation and verification of json web tokens.

Since

0.1.0

Type Parameters

  • PROPS extends JsonWebTokenProperty<unknown, unknown, JsonWebTokenData>[]

    The properties of the token.

  • JWT_PROPS extends JsonWebTokenData & TokenTypeMatchingForAllProperties<PROPS> = TokenTypeMatchingForAllProperties<PROPS>

    The type of the token's data.

  • CREATION_ARGS extends CREATION_ARGS_FOR_ALL_PROPERTIES<PROPS> = CREATION_ARGS_FOR_ALL_PROPERTIES<PROPS>

    The type of the arguments needed to create the token.

  • TEST_ARGS extends TEST_ARGS_FOR_ALL_PROPERTIES<PROPS> = TEST_ARGS_FOR_ALL_PROPERTIES<PROPS>

    The type of the arguments needed to test the token.

Hierarchy

  • JsonWebTokenManager

Constructors

Properties

Methods

Constructors

  • Creates a new JsonWebTokenManager.

    Type Parameters

    • PROPS extends JsonWebTokenProperty<unknown, unknown, JsonWebTokenData>[]

    • JWT_PROPS extends JsonWebTokenData = TokenTypeMatchingForAllProperties<PROPS>

    • CREATION_ARGS extends unknown = CREATION_ARGS_FOR_ALL_PROPERTIES<PROPS>

    • TEST_ARGS extends unknown = TEST_ARGS_FOR_ALL_PROPERTIES<PROPS>

    Parameters

    • secret: string

      The secret used to sign the token. Must be the same for all instances of the same type and must be kept secret.

    • properties: PROPS = ...

      The properties of the token.

    Returns JsonWebTokenManager<PROPS, JWT_PROPS, CREATION_ARGS, TEST_ARGS>

    Since

    0.1.0

Properties

properties: PROPS = ...

The properties of the token.

secret: string

The secret used to sign the token. Must be the same for all instances of the same type and must be kept secret.

Methods

  • Creates a new token.

    Parameters

    • args: CREATION_ARGS

      The arguments needed to create the token.

    Returns string

    The created and signed token.

    Since

    0.1.0

  • Signs the token.

    Parameters

    • payload: JWT_PROPS

      The payload to sign.

    Returns string

    The signed token.

    Since

    0.1.1

  • Unpacks the token.

    Parameters

    • token: string

      The token to unpack.

    Returns JWT_PROPS

    The token's data.

    Throws

    Throws an error if the token is invalid.

    Since

    0.1.1

  • Verifies a token.

    Parameters

    • token: string

      The token to verify.

    • args: TEST_ARGS

      The arguments needed to verify the token.

    Returns JWT_PROPS

    The token's data.

    Throws

    Throws an error if the token is invalid.

    Since

    0.1.0

Generated using TypeDoc