Documentation
    Preparing search index...

    Cookie parser parses the HTTP cookie header and collects all cookies inside an object of key-value pair, but doesn't attempt to decrypt or unsign or decode the individual values.

    The cookie values are lazily decrypted, or unsigned to avoid unncessary processing, which infact can be used as a means to burden the server by sending too many cookies which even doesn't belongs to the server.

    Index

    Constructors

    Methods

    Constructors

    • Create a new instance of CookieParser

      Parameters

      • cookieHeader: string

        The raw cookie header string from the request

      • encryption: Encryption

        The encryption instance for cookie operations

      Returns CookieParser

    Methods

    • Attempts to decode a cookie by the name. When calling this method, you are assuming that the cookie was just stringified in the first place and not signed or encrypted.

      Parameters

      • key: string

        The cookie key to decode

      • stringified: boolean = true

        Whether the cookie value was stringified

      Returns any

      The decoded cookie value or null if decoding fails

    • Attempts to unsign a cookie by the name. When calling this method, you are assuming that the cookie was signed in the first place.

      Parameters

      • key: string

        The cookie key to unsign

      Returns any

      The original cookie value or null if unsigning fails

    • Attempts to decrypt a cookie by the name. When calling this method, you are assuming that the cookie was encrypted in the first place.

      Parameters

      • key: string

        The cookie key to decrypt

      Returns any

      The decrypted cookie value or null if decryption fails

    • Returns an object of cookies key-value pair. Do note, the cookies are not decoded, unsigned or decrypted inside this list.

      Returns Record<string, any>

      Raw cookies as key-value pairs