@whatwg-node/cookie-store 0.2.0 → 0.2.1-rc-20230710182705-1e8ffff

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -30,6 +30,7 @@ class CookieStore extends EventTarget {
30
30
  sameSite: 'strict',
31
31
  expires: null,
32
32
  domain: null,
33
+ httpOnly: false,
33
34
  };
34
35
  if (typeof init === 'string') {
35
36
  item.name = init;
@@ -101,6 +102,7 @@ class CookieStore extends EventTarget {
101
102
  sameSite: 'strict',
102
103
  expires: null,
103
104
  domain: null,
105
+ httpOnly: false,
104
106
  };
105
107
  if (typeof init === 'string') {
106
108
  item.name = init;
@@ -13,6 +13,9 @@ function getCookieString(item) {
13
13
  if (typeof item.expires === 'number') {
14
14
  cookieString += '; Expires=' + new Date(item.expires).toUTCString();
15
15
  }
16
+ else if (item.expires) {
17
+ cookieString += '; Expires=' + item.expires.toUTCString();
18
+ }
16
19
  if ((item.name && item.name.startsWith('__Secure')) || item.secure) {
17
20
  item.sameSite = 'lax';
18
21
  cookieString += '; Secure';
@@ -28,6 +31,9 @@ function getCookieString(item) {
28
31
  cookieString += '; SameSite=None';
29
32
  break;
30
33
  }
34
+ if (item.httpOnly) {
35
+ cookieString += '; HttpOnly';
36
+ }
31
37
  return cookieString;
32
38
  }
33
39
  exports.getCookieString = getCookieString;
@@ -27,6 +27,7 @@ export class CookieStore extends EventTarget {
27
27
  sameSite: 'strict',
28
28
  expires: null,
29
29
  domain: null,
30
+ httpOnly: false,
30
31
  };
31
32
  if (typeof init === 'string') {
32
33
  item.name = init;
@@ -98,6 +99,7 @@ export class CookieStore extends EventTarget {
98
99
  sameSite: 'strict',
99
100
  expires: null,
100
101
  domain: null,
102
+ httpOnly: false,
101
103
  };
102
104
  if (typeof init === 'string') {
103
105
  item.name = init;
@@ -10,6 +10,9 @@ export function getCookieString(item) {
10
10
  if (typeof item.expires === 'number') {
11
11
  cookieString += '; Expires=' + new Date(item.expires).toUTCString();
12
12
  }
13
+ else if (item.expires) {
14
+ cookieString += '; Expires=' + item.expires.toUTCString();
15
+ }
13
16
  if ((item.name && item.name.startsWith('__Secure')) || item.secure) {
14
17
  item.sameSite = 'lax';
15
18
  cookieString += '; Secure';
@@ -25,5 +28,8 @@ export function getCookieString(item) {
25
28
  cookieString += '; SameSite=None';
26
29
  break;
27
30
  }
31
+ if (item.httpOnly) {
32
+ cookieString += '; HttpOnly';
33
+ }
28
34
  return cookieString;
29
35
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whatwg-node/cookie-store",
3
- "version": "0.2.0",
3
+ "version": "0.2.1-rc-20230710182705-1e8ffff",
4
4
  "description": "Cookie Store",
5
5
  "sideEffects": false,
6
6
  "dependencies": {
@@ -6,6 +6,7 @@ export interface Cookie {
6
6
  secure?: boolean;
7
7
  sameSite?: CookieSameSite;
8
8
  value: string;
9
+ httpOnly?: boolean;
9
10
  }
10
11
  export interface CookieStoreDeleteOptions {
11
12
  name: string;
@@ -25,6 +26,7 @@ export interface CookieListItem {
25
26
  expires: Date | number | null;
26
27
  secure?: boolean;
27
28
  sameSite?: CookieSameSite;
29
+ httpOnly?: boolean;
28
30
  }
29
31
  export type CookieList = CookieListItem[];
30
32
  export interface CookieChangeEventInit extends EventInit {
@@ -6,6 +6,7 @@ export interface Cookie {
6
6
  secure?: boolean;
7
7
  sameSite?: CookieSameSite;
8
8
  value: string;
9
+ httpOnly?: boolean;
9
10
  }
10
11
  export interface CookieStoreDeleteOptions {
11
12
  name: string;
@@ -25,6 +26,7 @@ export interface CookieListItem {
25
26
  expires: Date | number | null;
26
27
  secure?: boolean;
27
28
  sameSite?: CookieSameSite;
29
+ httpOnly?: boolean;
28
30
  }
29
31
  export type CookieList = CookieListItem[];
30
32
  export interface CookieChangeEventInit extends EventInit {