Skip to content

Commit c59ff0a

Browse files
refactor: update cookie options to use storageSettings for maxCookieLength: Daniel feedback
1 parent 2875e93 commit c59ff0a

4 files changed

Lines changed: 7 additions & 21 deletions

File tree

lib/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export {
2626
isServer,
2727
getCookieOptions,
2828
} from "./utils";
29-
export type { CookieOptions, CookieOptionValue } from "./utils";
29+
export type { CookieOptions } from "./utils";
3030

3131
export {
3232
getClaim,

lib/utils/getCookieOptions.test.ts

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@ import { describe, it, expect } from "vitest";
33
import {
44
getCookieOptions,
55
TWENTY_NINE_DAYS,
6-
MAX_COOKIE_LENGTH,
76
GLOBAL_COOKIE_OPTIONS,
87
} from "./getCookieOptions";
8+
import { storageSettings } from "../sessionManager/index";
99

1010
describe("getCookieOptions", () => {
1111
it("returns the default configuration when no options provided", () => {
1212
const result = getCookieOptions();
1313

1414
expect(result).toMatchObject({
1515
maxAge: TWENTY_NINE_DAYS,
16-
maxCookieLength: MAX_COOKIE_LENGTH,
16+
maxCookieLength: storageSettings.maxLength,
1717
sameSite: "lax",
1818
httpOnly: true,
1919
path: "/",
@@ -27,15 +27,13 @@ describe("getCookieOptions", () => {
2727
path: "/custom",
2828
maxAge: 60,
2929
domain: "example.com",
30-
customOption: "value",
3130
});
3231

3332
expect(result.secure).toBe(true);
3433
expect(result.sameSite).toBe("none");
3534
expect(result.path).toBe("/custom");
3635
expect(result.maxAge).toBe(60);
3736
expect(result.domain).toBe("example.com");
38-
expect(result.customOption).toBe("value");
3937
});
4038

4139
it("preserves GLOBAL_COOKIE_OPTIONS when not overridden", () => {
@@ -61,16 +59,6 @@ describe("getCookieOptions", () => {
6159
expect(result.sameSite).toBe("lax");
6260
expect(result.path).toBe("/");
6361
});
64-
65-
it("supports custom passthrough options", () => {
66-
const result = getCookieOptions({
67-
customFlag: true,
68-
anotherOption: "test",
69-
});
70-
71-
expect(result.customFlag).toBe(true);
72-
expect(result.anotherOption).toBe("test");
73-
});
7462
});
7563

7664
describe("GLOBAL_COOKIE_OPTIONS", () => {
@@ -79,6 +67,6 @@ describe("GLOBAL_COOKIE_OPTIONS", () => {
7967
expect(GLOBAL_COOKIE_OPTIONS.sameSite).toBe("lax");
8068
expect(GLOBAL_COOKIE_OPTIONS.path).toBe("/");
8169
expect(GLOBAL_COOKIE_OPTIONS.maxAge).toBe(TWENTY_NINE_DAYS);
82-
expect(GLOBAL_COOKIE_OPTIONS.maxCookieLength).toBe(MAX_COOKIE_LENGTH);
70+
expect(GLOBAL_COOKIE_OPTIONS.maxCookieLength).toBe(storageSettings.maxLength);
8371
});
8472
});

lib/utils/getCookieOptions.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export type CookieOptionValue = string | number | boolean | undefined;
1+
import { storageSettings } from "../sessionManager/index.js";
22

33
export interface CookieOptions {
44
maxAge?: number;
@@ -8,11 +8,9 @@ export interface CookieOptions {
88
httpOnly?: boolean;
99
secure?: boolean;
1010
path?: string;
11-
[key: string]: CookieOptionValue;
1211
}
1312

1413
export const TWENTY_NINE_DAYS = 2505600;
15-
export const MAX_COOKIE_LENGTH = 3000;
1614

1715
/**
1816
* Default cookie options used across Kinde SDKs.
@@ -27,7 +25,7 @@ export const MAX_COOKIE_LENGTH = 3000;
2725
*/
2826
export const GLOBAL_COOKIE_OPTIONS: CookieOptions = {
2927
maxAge: TWENTY_NINE_DAYS,
30-
maxCookieLength: MAX_COOKIE_LENGTH,
28+
maxCookieLength: storageSettings.maxLength,
3129
sameSite: "lax",
3230
httpOnly: true,
3331
path: "/",

lib/utils/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export {
1010
generateKindeSDKHeader,
1111
} from "./exchangeAuthCode";
1212
export { getCookieOptions } from "./getCookieOptions";
13-
export type { CookieOptions, CookieOptionValue } from "./getCookieOptions";
13+
export type { CookieOptions } from "./getCookieOptions";
1414
export { checkAuth } from "./checkAuth";
1515
export { isCustomDomain } from "./isCustomDomain";
1616
export { setRefreshTimer, clearRefreshTimer } from "./refreshTimer";

0 commit comments

Comments
 (0)