Psifi-Solutions / csrf-csrf

A utility package to help implement stateless CSRF protection using the Double Submit Cookie Pattern in express.
Other
110 stars 17 forks source link

Types broken with tsc build #64

Closed psibean closed 2 weeks ago

psibean commented 3 months ago

Edit / Update: For v3.0.4 and v3.0.5, types are broken in the releases, 3.0.6 fixes this problem and has no other changes but fixing the types. However the actual build still creates a broken package that needs to be manually tweaked in order to work.

Ugh. Real pain in the ass to just get some basic type declaration output working, firstly tsc doesn't support having just a single .d.ts file output, so I opted to use tsup to output the declaration file so I could split the types out of the main file. And now tsup seems to strip all of the export keywords and / or doesn't export all of the types the way tsc does when it emits the declaration file.

Annoying af.

brtvcl commented 3 months ago

My staging build failed because of this issue. I fixed it by changing the version in package.json.

    -  "csrf-csrf": "^3.0.4",
    +  "csrf-csrf": "3.0.4",

In my dev environment I had 3.0.4 installed for a while. Pushed some code to staging today. My build process installed the updated 3.0.5 version and I got an error.

psibean commented 3 months ago

I tried to unpublish 3.0.5, but couldn't since it ended up with dependents quite quickly.

This is 100% my fault for rushing and trying to push out a fix, and I ended up making things WAY worse.

I don't quite understand why tsup is removing the export keywords and making the type exports unavailable in 3.0.4

Getting TypeScript to just output a single declaration file with all the types exported is a lot more convoluted than it should be. 😐

Apologies. I'll make sure 3.0.6 actually works before I hit that publish. 🤦‍♂️

brtvcl commented 3 months ago

Temporary solution to downgrading is fine for now. Will be waiting for the 3.0.6. Thanks for the library ✌️

psibean commented 3 months ago

The "issue" with the build setup isn't fixed, but I manually constructed a fixed 3.0.6.

I tested 3.0.6 with my own typescript project prior to publishing. I was able to build & run, and csrf worked, and I had access to the types as expected.

Please let me know if there's any issues with 3.0.6

brtvcl commented 3 months ago

3.0.6 seems to be working 👍

psibean commented 2 weeks ago

Think I've fixed this up.