Baroshem / nuxt-security

🛡 Automatically configure your app to follow OWASP security patterns and principles by using HTTP Headers and Middleware
https://nuxt-security.vercel.app/
MIT License
737 stars 56 forks source link

Chore/2.0.0 rc.1 #448

Closed Baroshem closed 3 weeks ago

Baroshem commented 1 month ago

Types of changes

Description

Closes https://github.com/Baroshem/nuxt-security/pull/441 Closes https://github.com/Baroshem/nuxt-security/issues/447 Closes https://github.com/Baroshem/nuxt-security/issues/444 Closes https://github.com/Baroshem/nuxt-security/issues/446 Closes https://github.com/Baroshem/nuxt-security/issues/433 Closes https://github.com/Baroshem/nuxt-security/issues/232

Checklist:

vercel[bot] commented 1 month ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
nuxt-security ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 30, 2024 0:41am
vejja commented 1 month ago

Wonderful ! Looking forward to RC release 🎉🎉🎉

vejja commented 4 weeks ago

Hi @GalacticHypernova We have a typescript error on type OptionalThrowError<T> = Pick<T, 'throwError'>; which prevents the release.

src/types/module.ts(9,38): error TS2344: Type 'string' does not satisfy the constraint 'keyof T'.

Would you mind having a look at this ?

GalacticHypernova commented 4 weeks ago

Would you mind having a look at this ?

Looks like TS needs a stricter type constraint. I believe doing something like this will solve it

type OptionalThrowError<T extends Record<string, any>> = 'throwError' extends keyof T ? Pick<T, 'throwError'> : never;
vejja commented 3 weeks ago

After review, I am setting all fields optional and falling back to default config values in nested route rules.

This is because Nuxt internally forces our NuxtSecurityRouteRules fields to be optional. There is nothing we can do about this, as the Nuxt Module Builder internally overwrite our types with a DeepPartial<> utility.

This allows the user to use optional fields, while our code thinks they are mandatory - leading to potential type errors. I prefer to let our code know that they are in fact optional, and provide a fallback value.

GalacticHypernova commented 3 weeks ago

Sorry for the late response, sounds good!