@cedarjs/cookie-jar 1.1.1-next.18 → 2.0.0-rc.24

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.
@@ -1,13 +1,13 @@
1
- import cookie from 'cookie';
1
+ import type { SerializeOptions } from 'cookie';
2
2
  export type CookieParams = {
3
3
  value: string;
4
- options?: cookie.CookieSerializeOptions;
4
+ options?: SerializeOptions;
5
5
  };
6
6
  /** Specialized cookie map, that lets you set cookies with options */
7
7
  export declare class CookieJar {
8
8
  private map;
9
9
  constructor(cookieString?: string | null);
10
- set(name: string, value: string, options?: cookie.CookieSerializeOptions): this;
10
+ set(name: string, value: string, options?: SerializeOptions): this;
11
11
  get(name: string): string | undefined;
12
12
  getWithOptions(name: string): CookieParams | undefined;
13
13
  has(name: string): boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"CookieJar.d.ts","sourceRoot":"","sources":["../src/CookieJar.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAA;AAE3B,MAAM,MAAM,YAAY,GAAG;IACzB,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,CAAC,EAAE,MAAM,CAAC,sBAAsB,CAAA;CACxC,CAAA;AAED,qEAAqE;AACrE,qBAAa,SAAS;IACpB,OAAO,CAAC,GAAG,CAAkC;gBAIjC,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI;IAYjC,GAAG,CACR,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,MAAM,CAAC,sBAAsB;IAUlC,GAAG,CAAC,IAAI,EAAE,MAAM;IAIhB,cAAc,CAAC,IAAI,EAAE,MAAM;IAI3B,GAAG,CAAC,IAAI,EAAE,MAAM;IAIvB;;;OAGG;IACI,KAAK,CAAC,IAAI,EAAE,MAAM;IASzB,kEAAkE;IAC3D,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM;IAQnB,OAAO;IAIP,CAAC,MAAM,CAAC,QAAQ,CAAC;IAIxB,IAAW,IAAI,WAEd;CACF"}
1
+ {"version":3,"file":"CookieJar.d.ts","sourceRoot":"","sources":["../src/CookieJar.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAA;AAE9C,MAAM,MAAM,YAAY,GAAG;IACzB,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,CAAC,EAAE,gBAAgB,CAAA;CAC3B,CAAA;AAED,qEAAqE;AACrE,qBAAa,SAAS;IACpB,OAAO,CAAC,GAAG,CAAkC;gBAIjC,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI;IAuBjC,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,gBAAgB;IAM3D,GAAG,CAAC,IAAI,EAAE,MAAM;IAIhB,cAAc,CAAC,IAAI,EAAE,MAAM;IAI3B,GAAG,CAAC,IAAI,EAAE,MAAM;IAIvB;;;OAGG;IACI,KAAK,CAAC,IAAI,EAAE,MAAM;IASzB,kEAAkE;IAC3D,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM;IAQnB,OAAO;IAIP,CAAC,MAAM,CAAC,QAAQ,CAAC;IAIxB,IAAW,IAAI,WAEd;CACF"}
package/dist/CookieJar.js CHANGED
@@ -31,26 +31,27 @@ __export(CookieJar_exports, {
31
31
  CookieJar: () => CookieJar
32
32
  });
33
33
  module.exports = __toCommonJS(CookieJar_exports);
34
- var import_cookie = __toESM(require("cookie"));
34
+ var cookie = __toESM(require("cookie"));
35
35
  class CookieJar {
36
36
  map = /* @__PURE__ */ new Map();
37
- // This allows CookieJar to be used in MWRequest.cookie also
38
- // note that options are not available when constructed this way
37
+ // This allows CookieJar to be used in MiddlewareRequest.cookie
38
+ // Also note that options are not available when constructed this way
39
39
  constructor(cookieString) {
40
- if (cookieString) {
41
- const parsedCookies = import_cookie.default.parse(cookieString);
42
- this.map = new Map(
43
- Object.entries(parsedCookies).map(([key, value]) => {
44
- return [key, { value }];
45
- })
46
- );
40
+ if (cookieString === null || typeof cookieString === "undefined") {
41
+ return;
47
42
  }
43
+ const parsedCookies = cookie.parse(cookieString);
44
+ this.map = new Map(
45
+ Object.entries(parsedCookies).map(([key, value]) => {
46
+ if (typeof value === "undefined") {
47
+ throw new Error("Cookie value is undefined");
48
+ }
49
+ return [key, { value }];
50
+ })
51
+ );
48
52
  }
49
53
  set(name, value, options) {
50
- this.map.set(name, {
51
- value,
52
- options
53
- });
54
+ this.map.set(name, { value, options });
54
55
  return this;
55
56
  }
56
57
  get(name) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cedarjs/cookie-jar",
3
- "version": "1.1.1-next.18+5ffd3124d",
3
+ "version": "2.0.0-rc.24",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/cedarjs/cedar.git",
@@ -23,13 +23,13 @@
23
23
  "test": "vitest run"
24
24
  },
25
25
  "dependencies": {
26
- "cookie": "0.7.2",
26
+ "cookie": "1.0.2",
27
27
  "esbuild": "0.25.9",
28
28
  "fast-glob": "3.3.3",
29
29
  "fs-extra": "11.2.0"
30
30
  },
31
31
  "devDependencies": {
32
- "@cedarjs/framework-tools": "1.1.1-next.18",
32
+ "@cedarjs/framework-tools": "2.0.0-rc.24",
33
33
  "@types/fs-extra": "11.0.4",
34
34
  "tsx": "4.20.5",
35
35
  "typescript": "5.9.2",
@@ -38,5 +38,5 @@
38
38
  "publishConfig": {
39
39
  "access": "public"
40
40
  },
41
- "gitHead": "5ffd3124d3d4ceb7843408264c96ecceff8542f5"
41
+ "gitHead": "ce96a12c39646361695a287b05eee7ec92aab200"
42
42
  }