node-oauth / node-oauth2-server

🚀 The successor to oauthjs/oauth2-server. 🔒 Complete, compliant, maintained and well tested OAuth2 Server for node.js. Includes native async await and PKCE.
https://www.npmjs.com/package/@node-oauth/oauth2-server
MIT License
286 stars 39 forks source link

Typings for `validateScope` don't correctly reflect that `scope` arg can be undefined #264

Closed dhensby closed 10 months ago

dhensby commented 10 months ago

Specify your setup

Describe the bug

Typings for validateScope don't correctly reflect that scope arg can be undefined

To Reproduce

Steps to reproduce the behavior:

  1. Receive an HTTP request with no scope parameter
  2. Note that scope parameter to model.validateScope() method is `undefined

Expected behavior

The typings correctly reflect that the scope argument is optional.

Screenshots

n/a

Additional context

The scope util that is responsible for parsing the scopes from a request (https://github.com/node-oauth/node-oauth2-server/blob/v5.0.0/lib/utils/scope-util.js#L10-L12) returns undefined when no scope parameter is present and this return value is then passed to the validateScope() method.