Classes

CookieStorage

Storage of cookies, mirroring the cookies to the current request / response at the server side and the document.cookie property at the client side. The storage caches the cookies internally.

Constants

MAX_EXPIRE_DATE : Date

Implementation note: This is the largest possible safe value that has been tested, used to represent "infinity".

COOKIE_SEPARATOR : string

Separator used to separate cookie declarations in the Cookie HTTP header or the return value of the document.cookie property.

CookieStorage 

Storage of cookies, mirroring the cookies to the current request / response at the server side and the document.cookie property at the client side. The storage caches the cookies internally.

Kind: global class


new CookieStorage(window, request, response) 

Initializes the cookie storage.

Param Type Description
window Window The window utility.
request Request The current HTTP request.
response Response The current HTTP response.

cookieStorage._window : Window 

The window utility used to determine whether the IMA is being run at the client or at the server.

Kind: instance property of CookieStorage


cookieStorage._request : Request 

The current HTTP request. This field is used at the server side.

Kind: instance property of CookieStorage


cookieStorage._response : Response 

The current HTTP response. This field is used at the server side.

Kind: instance property of CookieStorage


cookieStorage._options : Object 

The overriding cookie attribute values.

Kind: instance property of CookieStorage


cookieStorage._transformFunction : Object 

Transform encode and decode functions for cookie value.

Kind: instance property of CookieStorage


cookieStorage.init(options, transformFunction) 

Kind: instance method of CookieStorage

Param Type
options Object
transformFunction Object

cookieStorage.has() 

Kind: instance method of CookieStorage


cookieStorage.get() 

Kind: instance method of CookieStorage


cookieStorage.set(name, value, [options]) 

Kind: instance method of CookieStorage

Param Type Description
name string The key identifying the storage entry.
value \* The storage entry value.
[options] Object The cookie options. The maxAge is the maximum age in seconds of the cookie before it will be deleted, the expires is an alternative to that, specifying the moment at which the cookie will be discarded. The domain and path specify the cookie’s domain and path. The httpOnly and secure flags set the flags of the same name of the cookie.

cookieStorage.delete(name, [options]) ⇒ Storage 

Deletes the cookie identified by the specified name.

Kind: instance method of CookieStorage
Returns: Storage - This storage.

Param Type Description
name string Name identifying the cookie.
[options] Object The cookie options. The domain and path specify the cookie’s domain and path. The httpOnly and secure flags set the flags of the same name of the cookie.

cookieStorage.clear() 

Kind: instance method of CookieStorage


cookieStorage.keys() 

Kind: instance method of CookieStorage


cookieStorage.size() 

Kind: instance method of CookieStorage


cookieStorage.getCookiesStringForCookieHeader() ⇒ string 

Returns all cookies in this storage serialized to a string compatible with the Cookie HTTP header.

Kind: instance method of CookieStorage
Returns: string - All cookies in this storage serialized to a string compatible with the Cookie HTTP header.


cookieStorage.parseFromSetCookieHeader(setCookieHeader) 

Parses cookies from the provided Set-Cookie HTTP header value.

The parsed cookies will be set to the internal storage, and the current HTTP response (via the Set-Cookie HTTP header) if at the server side, or the browser (via the document.cookie property).

Kind: instance method of CookieStorage

Param Type Description
setCookieHeader string The value of the Set-Cookie HTTP header.

cookieStorage._parse() 

Parses cookies from a cookie string and sets the parsed cookies to the internal storage.

The method obtains the cookie string from the request’s Cookie HTTP header when used at the server side, and the document.cookie property at the client side.

Kind: instance method of CookieStorage


cookieStorage._firstLetterToLowerCase(word) ⇒ string 

Creates a copy of the provided word (or text) that has its first character converted to lower case.

Kind: instance method of CookieStorage
Returns: string - A copy of the provided string with its first character converted to lower case.

Param Type Description
word string The word (or any text) that should have its first character converted to lower case.

cookieStorage._generateCookieString(name, value, options) ⇒ string 

Generates a string representing the specified cookied, usable either with the document.cookie property or the Set-Cookie HTTP header.

(Note that the Cookie HTTP header uses a slightly different syntax.)

Kind: instance method of CookieStorage
Returns: string - A string representing the cookie. Setting this string to the document.cookie property will set the cookie to the browser’s cookie storage.

Param Type Description
name string The cookie name.
value boolean | number | string The cookie value, will be converted to string.
options Object Cookie attributes. Only the attributes listed in the type annotation of this field are supported. For documentation and full list of cookie attributes see http://tools.ietf.org/html/rfc2965#page-5

cookieStorage._getExpirationAsDate(expiration) ⇒ Date 

Converts the provided cookie expiration to a Date instance.

Kind: instance method of CookieStorage
Returns: Date - Cookie expiration as a Date instance.

Param Type Description
expiration number | string | Date Cookie expiration in seconds from now, or as a string compatible with the Date constructor.

cookieStorage._extractCookie(cookieString) ⇒ Object 

Extract cookie name, value and options from cookie string.

Kind: instance method of CookieStorage

Param Type Description
cookieString string The value of the Set-Cookie HTTP header.

cookieStorage._extractNameAndValue(pair, pairIndex) ⇒ Array.<?(boolean\|string\|Date)> 

Extract name and value for defined pair and pair index.

Kind: instance method of CookieStorage

Param Type
pair string
pairIndex number

cookieStorage._sanitizeCookieValue(value) ⇒ string 

Sanitize cookie value by rules in (@see http://tools.ietf.org/html/rfc6265#section-4r.1.1). Erase all invalid characters from cookie value.

Kind: instance method of CookieStorage
Returns: string - Sanitized value

Param Type Description
value string Cookie value

cookieStorage._recomputeCookieMaxAgeAndExpires(options) 

Recomputes cookie’s attributes maxAge and expires between each other.

Kind: instance method of CookieStorage

Param Type Description
options Object Cookie attributes. Only the attributes listed in the type annotation of this field are supported. For documentation and full list of cookie attributes see http://tools.ietf.org/html/rfc2965#page-5

MAX_EXPIRE_DATE : Date 

Implementation note: This is the largest possible safe value that has been tested, used to represent “infinity”.

Kind: global constant


Separator used to separate cookie declarations in the Cookie HTTP header or the return value of the document.cookie property.

Kind: global constant