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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export types for contentSecurityPolicy and directives #56

Open
2 tasks done
emilfjellstrom opened this issue Mar 1, 2022 · 0 comments
Open
2 tasks done

Export types for contentSecurityPolicy and directives #56

emilfjellstrom opened this issue Mar 1, 2022 · 0 comments

Comments

@emilfjellstrom
Copy link

馃尡 Feature Request

Is your feature request related to a problem? Please describe.

A clear and concise description of what you want and what your use case is.

Hello, I have been working on my own interpretation of this package to handle specific headers for my company and I would like to import the types for directives in contentSecurityPolicy so that I'm able to extend the interface.

Describe the solution you'd like

A clear and concise description of what you want to happen.

Adding the types to the export would be the ideal way forward. Being able to export the types means that we can extend it to make certain keys and values strict to a specific value or to only accept string[]

Describe alternatives you've considered

A clear and concise description of any alternative solutions or features you've considered.

Currently, I have been trying to access the types through this method.

import { createSecureHeaders } from 'next-secure-headers';

type ArgumentTypes<F extends Function> = F extends (...args: infer A) => any ? A : never;

type SecureHeadersArguments = ArgumentTypes<typeof createSecureHeaders>[0];

export type Directives = SecureHeadersArguments['contentSecurityPolicy'];

But I'm getting a type error on the last line:

Property 'contentSecurityPolicy' does not exist on type 'Partial<{ contentSecurityPolicy: ContentSecurityPolicyOption; expectCT: ExpectCTOption; forceHTTPSRedirect: ForceHTTPSRedirectOption; ... 4 more ...; xssProtection: XSSProtectionOption; }> | undefined'.ts(2339)

Documentation, Adoption, Migration Strategy

If you can, explain how users will be able to use this and how it might be documented. Maybe a mock-up?

import { ContentSecurityPolicyOption } from "next-secure-headers";

type Directives = ContentSecurityPolicyOption['directives']
  • I've tried to find similar issues and pull requests
  • I would like to work on this feature 馃挭馃徎
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant