Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.d.ts 6.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. // Type definitions for cookie 0.4
  2. // Project: https://github.com/jshttp/cookie
  3. // Definitions by: Pine Mizune <https://github.com/pine>
  4. // Piotr Błażejewicz <https://github.com/peterblazejewicz>
  5. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  6. /**
  7. * Basic HTTP cookie parser and serializer for HTTP servers.
  8. */
  9. /**
  10. * Additional serialization options
  11. */
  12. export interface CookieSerializeOptions {
  13. /**
  14. * Specifies the value for the {@link https://tools.ietf.org/html/rfc6265#section-5.2.3|Domain Set-Cookie attribute}. By default, no
  15. * domain is set, and most clients will consider the cookie to apply to only
  16. * the current domain.
  17. */
  18. domain?: string | undefined;
  19. /**
  20. * Specifies a function that will be used to encode a cookie's value. Since
  21. * value of a cookie has a limited character set (and must be a simple
  22. * string), this function can be used to encode a value into a string suited
  23. * for a cookie's value.
  24. *
  25. * The default function is the global `encodeURIComponent`, which will
  26. * encode a JavaScript string into UTF-8 byte sequences and then URL-encode
  27. * any that fall outside of the cookie range.
  28. */
  29. encode?(value: string): string;
  30. /**
  31. * Specifies the `Date` object to be the value for the {@link https://tools.ietf.org/html/rfc6265#section-5.2.1|`Expires` `Set-Cookie` attribute}. By default,
  32. * no expiration is set, and most clients will consider this a "non-persistent cookie" and will delete
  33. * it on a condition like exiting a web browser application.
  34. *
  35. * *Note* the {@link https://tools.ietf.org/html/rfc6265#section-5.3|cookie storage model specification}
  36. * states that if both `expires` and `maxAge` are set, then `maxAge` takes precedence, but it is
  37. * possible not all clients by obey this, so if both are set, they should
  38. * point to the same date and time.
  39. */
  40. expires?: Date | undefined;
  41. /**
  42. * Specifies the boolean value for the {@link https://tools.ietf.org/html/rfc6265#section-5.2.6|`HttpOnly` `Set-Cookie` attribute}.
  43. * When truthy, the `HttpOnly` attribute is set, otherwise it is not. By
  44. * default, the `HttpOnly` attribute is not set.
  45. *
  46. * *Note* be careful when setting this to true, as compliant clients will
  47. * not allow client-side JavaScript to see the cookie in `document.cookie`.
  48. */
  49. httpOnly?: boolean | undefined;
  50. /**
  51. * Specifies the number (in seconds) to be the value for the `Max-Age`
  52. * `Set-Cookie` attribute. The given number will be converted to an integer
  53. * by rounding down. By default, no maximum age is set.
  54. *
  55. * *Note* the {@link https://tools.ietf.org/html/rfc6265#section-5.3|cookie storage model specification}
  56. * states that if both `expires` and `maxAge` are set, then `maxAge` takes precedence, but it is
  57. * possible not all clients by obey this, so if both are set, they should
  58. * point to the same date and time.
  59. */
  60. maxAge?: number | undefined;
  61. /**
  62. * Specifies the value for the {@link https://tools.ietf.org/html/rfc6265#section-5.2.4|`Path` `Set-Cookie` attribute}.
  63. * By default, the path is considered the "default path".
  64. */
  65. path?: string | undefined;
  66. /**
  67. * Specifies the boolean or string to be the value for the {@link https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-03#section-4.1.2.7|`SameSite` `Set-Cookie` attribute}.
  68. *
  69. * - `true` will set the `SameSite` attribute to `Strict` for strict same
  70. * site enforcement.
  71. * - `false` will not set the `SameSite` attribute.
  72. * - `'lax'` will set the `SameSite` attribute to Lax for lax same site
  73. * enforcement.
  74. * - `'strict'` will set the `SameSite` attribute to Strict for strict same
  75. * site enforcement.
  76. * - `'none'` will set the SameSite attribute to None for an explicit
  77. * cross-site cookie.
  78. *
  79. * More information about the different enforcement levels can be found in {@link https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-03#section-4.1.2.7|the specification}.
  80. *
  81. * *note* This is an attribute that has not yet been fully standardized, and may change in the future. This also means many clients may ignore this attribute until they understand it.
  82. */
  83. sameSite?: true | false | 'lax' | 'strict' | 'none' | undefined;
  84. /**
  85. * Specifies the boolean value for the {@link https://tools.ietf.org/html/rfc6265#section-5.2.5|`Secure` `Set-Cookie` attribute}. When truthy, the
  86. * `Secure` attribute is set, otherwise it is not. By default, the `Secure` attribute is not set.
  87. *
  88. * *Note* be careful when setting this to `true`, as compliant clients will
  89. * not send the cookie back to the server in the future if the browser does
  90. * not have an HTTPS connection.
  91. */
  92. secure?: boolean | undefined;
  93. }
  94. /**
  95. * Additional parsing options
  96. */
  97. export interface CookieParseOptions {
  98. /**
  99. * Specifies a function that will be used to decode a cookie's value. Since
  100. * the value of a cookie has a limited character set (and must be a simple
  101. * string), this function can be used to decode a previously-encoded cookie
  102. * value into a JavaScript string or other object.
  103. *
  104. * The default function is the global `decodeURIComponent`, which will decode
  105. * any URL-encoded sequences into their byte representations.
  106. *
  107. * *Note* if an error is thrown from this function, the original, non-decoded
  108. * cookie value will be returned as the cookie's value.
  109. */
  110. decode?(value: string): string;
  111. }
  112. /**
  113. * Parse an HTTP Cookie header string and returning an object of all cookie
  114. * name-value pairs.
  115. *
  116. * @param str the string representing a `Cookie` header value
  117. * @param [options] object containing parsing options
  118. */
  119. export function parse(str: string, options?: CookieParseOptions): { [key: string]: string };
  120. /**
  121. * Serialize a cookie name-value pair into a `Set-Cookie` header string.
  122. *
  123. * @param name the name for the cookie
  124. * @param value value to set the cookie to
  125. * @param [options] object containing serialization options
  126. * @throws {TypeError} when `maxAge` options is invalid
  127. */
  128. export function serialize(name: string, value: string, options?: CookieSerializeOptions): string;