-
-
Notifications
You must be signed in to change notification settings - Fork 77
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
Use @types/simple-oauth2
instead of redoing it
#225
Use @types/simple-oauth2
instead of redoing it
#225
Conversation
Every library appends their user-agent to the one that's been set at a level above them. Hence any provided user-agent comes before the default user agent. To provide context, the version number of `@fastify/oauth2` + the home page of it is included in the User-Agent. That way an API can diagnose possibly faulty consumers and file an issue. If someone wouldn't want to expose this, they can always set a custom User-Agent header directly in the http settings. Especially if fastify#225 gets merged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets discuss this first:
By putting it as dependency and not dev dependency the types package will also be installed as production dependencies by Projects that use this plugin.
Yes, that is unfortunate, it's a balancing act between smaller install size and correct/complete types I think. One improvement could be that this module stops blankety passing through the options to Another could be to add these types as a dev dependency and validate in the type tests that the types defined in this module are indeed assignable to the one in The latter I would then like to complement with fleshing out some of the http options (which in the |
Maybe better to talk to the simple-oauth2 team to merge this PR |
@Uzlopak One doesn't exclude the other. Also, that PR has some of the same concerns (lelylan/simple-oauth2#436 (comment)) as I raise here. |
I'll make an alternative PR soon that avoids adding this as a prod dependency |
This is an alternative to fastify#225 where rather than using `@types/simple-oauth2` in the published types we ensure at test time that the local types are indeed compatible with the published types of `@types/simple-oauth2`. That way a consumer that wants to have access to the full types of `simple-oauth2` can add `@types/simple-oauth2` in their own project, knowing that it will be compatible
Every library appends their user-agent to the one that's been set at a level above them. Hence any provided user-agent comes before the default user agent. To provide context, the version number of `@fastify/oauth2` + the home page of it is included in the User-Agent. That way an API can diagnose possibly faulty consumers and file an issue. If someone wouldn't want to expose this, they can always set a custom User-Agent header directly in the http settings. Especially if fastify#225 gets merged.
Closing in favor of #229 |
* Fix `test:coverage` command * Add default user-agent + enable custom one Every library appends their user-agent to the one that's been set at a level above them. Hence any provided user-agent comes before the default user agent. To provide context, the version number of `@fastify/oauth2` + the home page of it is included in the User-Agent. That way an API can diagnose possibly faulty consumers and file an issue. If someone wouldn't want to expose this, they can always set a custom User-Agent header directly in the http settings. Especially if #225 gets merged. * Update index.js Co-authored-by: Manuel Spigolon <[email protected]> * Fix feedback, allow disabling of user-agent * Simplify user-agent string * Move `credentials` initialization to the top * Naming tweak in test * Remove multi-`user-agent` use The RFC 9110 states: "The User-Agent field value consists of one or more product identifiers, each followed by zero or more comments (Section 5.6.5), which together identify the user agent software and its significant subproducts. By convention, the product identifiers are listed in decreasing order of their significance for identifying the user agent software." But since many are not aware of it, it may be better to remove it --------- Co-authored-by: Manuel Spigolon <[email protected]>
This is an alternative to #225 where rather than using `@types/simple-oauth2` in the published types we ensure at test time that the local types are indeed compatible with the published types of `@types/simple-oauth2`. That way a consumer that wants to have access to the full types of `simple-oauth2` can add `@types/simple-oauth2` in their own project, knowing that it will be compatible
Prior to #172 the
Credentials
was typed to a much more slim subset of whatsimple-oauth2
currently accepts, but in #172 (which contained #170 / #152) it was extended to pretty much be the full typing ofsimple-oauth2
, but without actually referring to@types/simple-oauth2
.This PR adds
@types/simple-oauth2
and uses the types from that one instead – and does so in a backwards compatible way by keepingProviderConfiguration
andCredentials
.My personal motivation for this was that I wanted to add a HTTP Header to some requests (I want to add a
User-Agent
as I personally think that's good practice to do) and when I looked around if it was supported I realized that it was, but through theCredentials['http']
that's currently typed as:This is what it looks like in
@types/simple-oauth2
, much more complete:When looking through the git log, PR:s and issues I can't find any mentioning of why these types wasn't referred to instead of duplicating them. Maybe the
@types/simple-oauth2
wasn't available at the time, but now that they are I think its a good idea to refer to them.Checklist
npm run test
andnpm run benchmark
and the Code of conduct