From 4af14235d578870a68bded3b2ae6101eea5f8b43 Mon Sep 17 00:00:00 2001 From: Artem Zakharchenko Date: Thu, 10 Oct 2024 19:28:44 +0200 Subject: [PATCH 1/3] fix: update and use `cookie` directly --- global.d.ts | 4 ---- package.json | 2 +- pnpm-lock.yaml | 22 ++++++++------------- src/core/utils/request/getRequestCookies.ts | 19 +++++++++++++++--- test/node/graphql-api/cookies.node.test.ts | 6 ++---- 5 files changed, 27 insertions(+), 26 deletions(-) diff --git a/global.d.ts b/global.d.ts index b35933e17..73978e004 100644 --- a/global.d.ts +++ b/global.d.ts @@ -1,7 +1,3 @@ -declare module '@bundled-es-modules/cookie' { - export * as default from 'cookie' -} - declare module '@bundled-es-modules/statuses' { import * as statuses from 'statuses' export default statuses diff --git a/package.json b/package.json index 73dc51602..58163ff54 100644 --- a/package.json +++ b/package.json @@ -133,7 +133,6 @@ ], "sideEffects": false, "dependencies": { - "@bundled-es-modules/cookie": "^2.0.0", "@bundled-es-modules/statuses": "^1.0.1", "@bundled-es-modules/tough-cookie": "^0.1.6", "@inquirer/confirm": "^3.0.0", @@ -142,6 +141,7 @@ "@types/cookie": "^0.6.0", "@types/statuses": "^2.0.4", "chalk": "^4.1.2", + "cookie": "^1.0.0", "graphql": "^16.8.1", "headers-polyfill": "^4.0.2", "is-node-process": "^1.2.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 611143cee..d12ee352e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -5,9 +5,6 @@ settings: excludeLinksFromLockfile: false dependencies: - '@bundled-es-modules/cookie': - specifier: ^2.0.0 - version: 2.0.0 '@bundled-es-modules/statuses': specifier: ^1.0.1 version: 1.0.1 @@ -32,6 +29,9 @@ dependencies: chalk: specifier: ^4.1.2 version: 4.1.2 + cookie: + specifier: ^1.0.0 + version: 1.0.0 graphql: specifier: ^16.8.1 version: 16.9.0 @@ -420,12 +420,6 @@ packages: to-fast-properties: 2.0.0 dev: true - /@bundled-es-modules/cookie@2.0.0: - resolution: {integrity: sha512-Or6YHg/kamKHpxULAdSqhGqnWFneIXu1NKvvfBBzKGwpVsYuFIQ5aBPHDnnoR3ghW1nvSkALd+EF9iMtY7Vjxw==} - dependencies: - cookie: 0.5.0 - dev: false - /@bundled-es-modules/statuses@1.0.1: resolution: {integrity: sha512-yn7BklA5acgcBr+7w064fGV+SGIFySjCKpqjcWgBAIfrAkY+4GQTJJHQMeT3V/sgz23VTEVV8TtOmkvJAhFVfg==} dependencies: @@ -3497,16 +3491,16 @@ packages: engines: {node: '>= 0.6'} dev: true - /cookie@0.5.0: - resolution: {integrity: sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw==} - engines: {node: '>= 0.6'} - dev: false - /cookie@0.6.0: resolution: {integrity: sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw==} engines: {node: '>= 0.6'} dev: true + /cookie@1.0.0: + resolution: {integrity: sha512-bsSztFoaR8bw9MlFCrTHzc1wOKCUKOBsbgFdoDilZDkETAOOjKSqV7L+EQLbTaylwvZasd9vM4MGKotJaUfSpA==} + engines: {node: '>=18'} + dev: false + /cookies@0.9.1: resolution: {integrity: sha512-TG2hpqe4ELx54QER/S3HQ9SRVnQnGBtKUz5bLQWtYAQ+o6GpgMs6sYUvaiJjVxb+UXwhRhAEP3m7LbsIZ77Hmw==} engines: {node: '>= 0.8'} diff --git a/src/core/utils/request/getRequestCookies.ts b/src/core/utils/request/getRequestCookies.ts index 9eab0f803..78356d36e 100644 --- a/src/core/utils/request/getRequestCookies.ts +++ b/src/core/utils/request/getRequestCookies.ts @@ -1,8 +1,21 @@ -import cookieUtils from '@bundled-es-modules/cookie' +import * as cookieUtils from 'cookie' import { cookieStore } from '../cookieStore' +function parseCookies(input: string): Record { + const parsedCookies = cookieUtils.parse(input) + const cookies: Record = {} + + for (const cookieName in parsedCookies) { + if (typeof parsedCookies[cookieName] !== 'undefined') { + cookies[cookieName] = parsedCookies[cookieName] + } + } + + return cookies +} + function getAllDocumentCookies() { - return cookieUtils.parse(document.cookie) + return parseCookies(document.cookie) } function getDocumentCookies(request: Request): Record { @@ -40,7 +53,7 @@ export function getAllRequestCookies(request: Request): Record { */ const requestCookieHeader = request.headers.get('cookie') const cookiesFromHeaders = requestCookieHeader - ? cookieUtils.parse(requestCookieHeader) + ? parseCookies(requestCookieHeader) : {} const cookiesFromDocument = getDocumentCookies(request) diff --git a/test/node/graphql-api/cookies.node.test.ts b/test/node/graphql-api/cookies.node.test.ts index 353aa8c66..4cab39b82 100644 --- a/test/node/graphql-api/cookies.node.test.ts +++ b/test/node/graphql-api/cookies.node.test.ts @@ -1,7 +1,5 @@ -/** - * @vitest-environment node - */ -import cookieUtils from '@bundled-es-modules/cookie' +// @vitest-environment node +import * as cookieUtils from 'cookie' import { graphql as executeGraphql, buildSchema } from 'graphql' import { graphql, HttpResponse } from 'msw' import { setupServer } from 'msw/node' From 5511af160dd2bc8a32c15b58cf72a9b08678b793 Mon Sep 17 00:00:00 2001 From: Artem Zakharchenko Date: Fri, 11 Oct 2024 12:01:20 +0200 Subject: [PATCH 2/3] chore: revert to @bundled-es-modules/cookie --- global.d.ts | 4 ++++ package.json | 2 +- pnpm-lock.yaml | 22 +++++++++++++-------- src/core/utils/request/getRequestCookies.ts | 2 +- test/browser/graphql-api/cookies.test.ts | 2 +- test/node/graphql-api/cookies.node.test.ts | 2 +- 6 files changed, 22 insertions(+), 12 deletions(-) diff --git a/global.d.ts b/global.d.ts index 73978e004..b35933e17 100644 --- a/global.d.ts +++ b/global.d.ts @@ -1,3 +1,7 @@ +declare module '@bundled-es-modules/cookie' { + export * as default from 'cookie' +} + declare module '@bundled-es-modules/statuses' { import * as statuses from 'statuses' export default statuses diff --git a/package.json b/package.json index 58163ff54..73dc51602 100644 --- a/package.json +++ b/package.json @@ -133,6 +133,7 @@ ], "sideEffects": false, "dependencies": { + "@bundled-es-modules/cookie": "^2.0.0", "@bundled-es-modules/statuses": "^1.0.1", "@bundled-es-modules/tough-cookie": "^0.1.6", "@inquirer/confirm": "^3.0.0", @@ -141,7 +142,6 @@ "@types/cookie": "^0.6.0", "@types/statuses": "^2.0.4", "chalk": "^4.1.2", - "cookie": "^1.0.0", "graphql": "^16.8.1", "headers-polyfill": "^4.0.2", "is-node-process": "^1.2.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d12ee352e..611143cee 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -5,6 +5,9 @@ settings: excludeLinksFromLockfile: false dependencies: + '@bundled-es-modules/cookie': + specifier: ^2.0.0 + version: 2.0.0 '@bundled-es-modules/statuses': specifier: ^1.0.1 version: 1.0.1 @@ -29,9 +32,6 @@ dependencies: chalk: specifier: ^4.1.2 version: 4.1.2 - cookie: - specifier: ^1.0.0 - version: 1.0.0 graphql: specifier: ^16.8.1 version: 16.9.0 @@ -420,6 +420,12 @@ packages: to-fast-properties: 2.0.0 dev: true + /@bundled-es-modules/cookie@2.0.0: + resolution: {integrity: sha512-Or6YHg/kamKHpxULAdSqhGqnWFneIXu1NKvvfBBzKGwpVsYuFIQ5aBPHDnnoR3ghW1nvSkALd+EF9iMtY7Vjxw==} + dependencies: + cookie: 0.5.0 + dev: false + /@bundled-es-modules/statuses@1.0.1: resolution: {integrity: sha512-yn7BklA5acgcBr+7w064fGV+SGIFySjCKpqjcWgBAIfrAkY+4GQTJJHQMeT3V/sgz23VTEVV8TtOmkvJAhFVfg==} dependencies: @@ -3491,16 +3497,16 @@ packages: engines: {node: '>= 0.6'} dev: true + /cookie@0.5.0: + resolution: {integrity: sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw==} + engines: {node: '>= 0.6'} + dev: false + /cookie@0.6.0: resolution: {integrity: sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw==} engines: {node: '>= 0.6'} dev: true - /cookie@1.0.0: - resolution: {integrity: sha512-bsSztFoaR8bw9MlFCrTHzc1wOKCUKOBsbgFdoDilZDkETAOOjKSqV7L+EQLbTaylwvZasd9vM4MGKotJaUfSpA==} - engines: {node: '>=18'} - dev: false - /cookies@0.9.1: resolution: {integrity: sha512-TG2hpqe4ELx54QER/S3HQ9SRVnQnGBtKUz5bLQWtYAQ+o6GpgMs6sYUvaiJjVxb+UXwhRhAEP3m7LbsIZ77Hmw==} engines: {node: '>= 0.8'} diff --git a/src/core/utils/request/getRequestCookies.ts b/src/core/utils/request/getRequestCookies.ts index 78356d36e..5cbe4bd7d 100644 --- a/src/core/utils/request/getRequestCookies.ts +++ b/src/core/utils/request/getRequestCookies.ts @@ -1,4 +1,4 @@ -import * as cookieUtils from 'cookie' +import cookieUtils from '@bundled-es-modules/cookie' import { cookieStore } from '../cookieStore' function parseCookies(input: string): Record { diff --git a/test/browser/graphql-api/cookies.test.ts b/test/browser/graphql-api/cookies.test.ts index c451f8dcc..fdc988853 100644 --- a/test/browser/graphql-api/cookies.test.ts +++ b/test/browser/graphql-api/cookies.test.ts @@ -1,4 +1,4 @@ -import * as cookieUtils from 'cookie' +import cookieUtils from '@bundled-es-modules/cookie' import { test, expect } from '../playwright.extend' import { gql } from '../../support/graphql' diff --git a/test/node/graphql-api/cookies.node.test.ts b/test/node/graphql-api/cookies.node.test.ts index 4cab39b82..7d6bd77b4 100644 --- a/test/node/graphql-api/cookies.node.test.ts +++ b/test/node/graphql-api/cookies.node.test.ts @@ -1,5 +1,5 @@ // @vitest-environment node -import * as cookieUtils from 'cookie' +import cookieUtils from '@bundled-es-modules/cookie' import { graphql as executeGraphql, buildSchema } from 'graphql' import { graphql, HttpResponse } from 'msw' import { setupServer } from 'msw/node' From 20e0b2a5206a78efa29d28f1d3210182cd788d87 Mon Sep 17 00:00:00 2001 From: Artem Zakharchenko Date: Thu, 7 Nov 2024 13:15:42 +0100 Subject: [PATCH 3/3] fix: update `"@bundled-es-modules/cookie` to 2.0.1 --- package.json | 2 +- pnpm-lock.yaml | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index dab02563f..7514d8110 100644 --- a/package.json +++ b/package.json @@ -133,7 +133,7 @@ ], "sideEffects": false, "dependencies": { - "@bundled-es-modules/cookie": "^2.0.0", + "@bundled-es-modules/cookie": "^2.0.1", "@bundled-es-modules/statuses": "^1.0.1", "@bundled-es-modules/tough-cookie": "^0.1.6", "@inquirer/confirm": "^3.0.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3c2d9073b..19ea6ebb8 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -6,8 +6,8 @@ settings: dependencies: '@bundled-es-modules/cookie': - specifier: ^2.0.0 - version: 2.0.0 + specifier: ^2.0.1 + version: 2.0.1 '@bundled-es-modules/statuses': specifier: ^1.0.1 version: 1.0.1 @@ -409,10 +409,10 @@ packages: to-fast-properties: 2.0.0 dev: true - /@bundled-es-modules/cookie@2.0.0: - resolution: {integrity: sha512-Or6YHg/kamKHpxULAdSqhGqnWFneIXu1NKvvfBBzKGwpVsYuFIQ5aBPHDnnoR3ghW1nvSkALd+EF9iMtY7Vjxw==} + /@bundled-es-modules/cookie@2.0.1: + resolution: {integrity: sha512-8o+5fRPLNbjbdGRRmJj3h6Hh1AQJf2dk3qQ/5ZFb+PXkRNiSoMGGUKlsgLfrxneb72axVJyIYji64E2+nNfYyw==} dependencies: - cookie: 0.5.0 + cookie: 0.7.2 dev: false /@bundled-es-modules/statuses@1.0.1: @@ -3908,16 +3908,16 @@ packages: engines: {node: '>= 0.6'} dev: true - /cookie@0.5.0: - resolution: {integrity: sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw==} - engines: {node: '>= 0.6'} - dev: false - /cookie@0.6.0: resolution: {integrity: sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw==} engines: {node: '>= 0.6'} dev: true + /cookie@0.7.2: + resolution: {integrity: sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==} + engines: {node: '>= 0.6'} + dev: false + /cookies@0.9.1: resolution: {integrity: sha512-TG2hpqe4ELx54QER/S3HQ9SRVnQnGBtKUz5bLQWtYAQ+o6GpgMs6sYUvaiJjVxb+UXwhRhAEP3m7LbsIZ77Hmw==} engines: {node: '>= 0.8'}