Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions apps/e2e/tests/js/cookies.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,10 @@ it("should set refresh token cookies for trusted parent domains", async ({ expec
const customReady = await waitUntil(() => cookieStore.has(customCookieName), 10_000);
expect(customReady).toBe(true);

expect(cookieStore.has(defaultCookieName)).toBe(true);
expect(cookieStore.has(defaultCookieName)).toBe(false);
expect(cookieStore.has(customCookieName)).toBe(true);

const valuesEqual = await waitUntil(() => cookieStore.get(customCookieName) === cookieStore.get(defaultCookieName), 10_000);
expect(valuesEqual).toBe(true);

const defaultValue = cookieStore.get(defaultCookieName)!;
const defaultValue = cookieStore.get(customCookieName)!;
const parsedValue = JSON.parse(decodeURIComponent(defaultValue));
expect(typeof parsedValue.refresh_token).toBe("string");
expect(parsedValue.refresh_token.length).toBeGreaterThan(10);
Expand Down
4 changes: 2 additions & 2 deletions packages/template/src/lib/cookie.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,9 @@ function setCookieClientInternal(name: string, value: string, options: SetCookie

function deleteCookieClientInternal(name: string, options: DeleteCookieOptions = {}) {
if (options.domain !== undefined) {
Cookies.remove(name, { domain: options.domain });
Cookies.remove(name, { domain: options.domain, secure: determineSecureFromClientContext() });
}
Cookies.remove(name);
Cookies.remove(name, { secure: determineSecureFromClientContext() });
}

export function setOrDeleteCookieClient(name: string, value: string | null, options: SetCookieOptions & DeleteCookieOptions = {}) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,8 @@ export class _StackClientAppImplIncomplete<HasTokenStore extends boolean, Projec
}
const value = refreshToken && updatedAt ? this._formatRefreshCookieValue(refreshToken, updatedAt) : null;
await setCookie(domain.data, value);
const isSecure = await isSecureCookieContext();
await setOrDeleteCookie(this._getRefreshTokenDefaultCookieNameForSecure(isSecure), null);
});
}
private async _getTrustedParentDomain(currentDomain: string): Promise<string | null> {
Expand Down