Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(v8): server action cookie options #617

Merged
merged 3 commits into from
Oct 18, 2023
Merged

fix(v8): server action cookie options #617

merged 3 commits into from
Oct 18, 2023

Conversation

renchris
Copy link
Contributor

Highlights

  • Support for Server Action .save() and .destroy() Cookie Options
  • Documentation
  • Bump Next Dependency

Feature Overview

  • getServerActionIronSession's .save() and .destroy() functions properly take in cookieOptions and reflect the changes to Set-Cookie

    • No longer serialize() the cookie name, seal (the encrypted value), and options
    • Remove the extractCookieComponents and setServerActionCookie helper functions that destructured the serialized values
    • .set() the cookie name, seal, and options directly in the .save() and .destroy() functions
  • Remove encode() as a CookieOptions attribute

  • Add options to the CookieHandler set type definition with NextJS cookies()'s options type ResponseCookie

  • More documentation added for Iron Session Options: type definitions, types of Iron Session options, and usage example

  • Allow for cookies() to reflect the priority attribute to Set-Cookies by contributing to next/edge-runtime with fix: cookies() .set() reflect priority attribute into set-cookie vercel/edge-runtime#640

    • fix is now included in [email protected]
    • updated examples/next's dependency next to 13.5.5
  • Move the NextJS Example's dependencies from examples/next/pnpm-lock.yaml to the root folder's pnpm-lock.yaml file

Key References

Recognition

Thank you and credit to @devjmetivier for noticing setServerActionCookie not passing in cookie options with his #586 (comment) and renchris#1 PR

@vercel
Copy link

vercel bot commented Oct 17, 2023

Someone is attempting to deploy a commit to a Personal Account owned by @vvo on Vercel.

@vvo first needs to authorize it.

@renchris renchris mentioned this pull request Oct 17, 2023
13 tasks
@vvo vvo merged commit 5c99921 into vvo:v8 Oct 18, 2023
@vvo
Copy link
Owner

vvo commented Oct 18, 2023

@renchris had some conflicts given the repo changes I have done, can you double check now?

@renchris
Copy link
Contributor Author

Hey @vvo. The merged commit looks all good! However, when I am trying to set up the new current v8 branch I get an error on install

I tried and fails:

  • pulling the upstream v8 changes into my fork
  • git cloning a new vvo/iron-session repository again
  • codespaces

Ran the repository set up commands again

fnm install
corepack enable
pnpm install

Fails upon pnpm install

pnpm install
Scope: all 6 workspace projects
Lockfile is up to date, resolution step is skipped
Packages: +784
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Progress: resolved 784, reused 784, downloaded 0, added 784, done

devDependencies:
+ @release-it/conventional-changelog 7.0.2
+ @types/cookie 0.5.3
+ @types/node 20.8.7
+ @typescript-eslint/eslint-plugin 6.8.0
+ @typescript-eslint/parser 6.8.0
+ c8 8.0.1
+ cookie 0.5.0
+ eslint 8.51.0
+ eslint-config-prettier 9.0.0
+ eslint-import-resolver-node 0.3.9
+ eslint-import-resolver-typescript 3.6.1
+ eslint-plugin-import 2.28.1
+ eslint-plugin-prettier 5.0.1
+ iron-webcrypto 1.0.0
+ prettier 3.0.3
+ prettier-plugin-packagejson 2.4.6
+ publint 0.2.4
+ release-it 16.2.1
+ tsup 7.2.0
+ tsx 3.14.0
+ typescript 5.2.2

. prepare$ pnpm build
│ > [email protected] build /iron-session
│ > tsc --noEmit && tsup
│ examples/koa/lib/session.ts(2,32): error TS2307: Cannot find module 'iron-session' or its correspondin…
│ examples/lagon/lib/session.ts(1,48): error TS2307: Cannot find module 'iron-session' or its correspond…
│ src/index.test.ts(4,41): error TS2307: Cannot find module 'iron-session' or its corresponding type dec…
│  ELIFECYCLE  Command failed with exit code 2.
└─ Failed in 1.3s at /iron-session
 ELIFECYCLE  Command failed with exit code 1.

From the recent repo changes you have done, are the examples folder somehow now attempting to build before the root Iron Session library folder is built?

@renchris
Copy link
Contributor Author

I'm not familiar with the desired behavior of your recent ci changes are, however, changing back the build command in the package.json allows it to successfully build again.

  "scripts": {
-    "build": "tsc --noEmit && tsup",
+    "build": "pnpm i && tsup && cp dist/index.d.ts dist/index.node.d.cts",
    "bun:dev": "pnpm --filter=bun-example dev",
    "bun:start": "pnpm --filter=bun-example start",
    "deno:dev": "pnpm --filter=deno-example dev",
    "deno:start": "pnpm --filter=deno-example start",
    "koa:dev": "pnpm --filter=koa-example dev",
    "koa:start": "pnpm --filter=koa-example start",
    "lagon:dev": "pnpm --filter=lagon-example dev",
    "lint": "tsc --noEmit && tsc --noEmit -p examples/next/tsconfig.json && tsc --noEmit -p examples/bun/tsconfig.json && pnpm eslint . && deno lint examples/deno && publint",
-    "prepare": "pnpm build",
    "release": "pnpm lint",
    "test": "c8 -r text -r lcov node --loader tsx --test src/*.test.ts && pnpm build",
    "test:watch": "node --loader tsx --test --watch src/*.test.ts"
  },

@vvo
Copy link
Owner

vvo commented Oct 19, 2023

@renchris I'll fix that indeed, thanks for the heads-up

@vvo
Copy link
Owner

vvo commented Oct 19, 2023

Updated @renchris give it another try

@renchris
Copy link
Contributor Author

Great, it builds successfully again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants