File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -84,13 +84,15 @@ class AuthorizationCodeGrantType extends AbstractGrantType {
8484 throw new InvalidRequestError ( 'Invalid parameter: `code`' ) ;
8585 }
8686
87+ // normalize string|number to string
8788 const requestCode = toString ( request . body . code ) ;
8889
8990 if ( ! isFormat . vschar ( requestCode ) ) {
9091 throw new InvalidRequestError ( 'Invalid parameter: `code`' ) ;
9192 }
9293
93- const code = await this . model . getAuthorizationCode ( requestCode ) ;
94+ // XXX: still passing the original value from request to model
95+ const code = await this . model . getAuthorizationCode ( request . body . code ) ;
9496
9597 if ( ! code ) {
9698 throw new InvalidGrantError ( 'Invalid grant: authorization code is invalid' ) ;
Original file line number Diff line number Diff line change @@ -81,7 +81,7 @@ class RefreshTokenGrantType extends AbstractGrantType {
8181 throw new InvalidRequestError ( 'Invalid parameter: `refresh_token`' ) ;
8282 }
8383
84- const token = await this . model . getRefreshToken ( refreshToken ) ;
84+ const token = await this . model . getRefreshToken ( request . body . refresh_token ) ;
8585
8686 if ( ! token ) {
8787 throw new InvalidGrantError ( 'Invalid grant: refresh token is invalid' ) ;
Original file line number Diff line number Diff line change @@ -173,6 +173,7 @@ class AuthorizeHandler {
173173
174174 const redirectUri = request . body . redirect_uri || request . query . redirect_uri ;
175175
176+ // XXX: why is there no 'Missing parameter: `redirect_uri`' error?
176177 if ( isDefined ( redirectUri ) && ( ! isString ( redirectUri ) || ! isFormat . uri ( redirectUri ) ) ) {
177178 throw new InvalidRequestError ( 'Invalid request: `redirect_uri` is not a valid URI' ) ;
178179 }
Original file line number Diff line number Diff line change @@ -18,6 +18,8 @@ const UnsupportedGrantTypeError = require('../errors/unsupported-grant-type-erro
1818const auth = require ( 'basic-auth' ) ;
1919const pkce = require ( '../pkce/pkce' ) ;
2020const isFormat = require ( '@node-oauth/formats' ) ;
21+ const { isInTypes, toString } = require ( '../utils/param-util' ) ;
22+ const isStringOrNumber = isInTypes ( 'string' , 'number' ) ;
2123
2224/**
2325 * Grant types.
@@ -123,7 +125,7 @@ class TokenHandler {
123125 throw new InvalidRequestError ( 'Missing parameter: `client_secret`' ) ;
124126 }
125127
126- if ( ! isFormat . vschar ( credentials . clientId ) ) {
128+ if ( ! isStringOrNumber ( credentials . clientId ) || ! isFormat . vschar ( toString ( credentials . clientId ) ) ) {
127129 throw new InvalidRequestError ( 'Invalid parameter: `client_id`' ) ;
128130 }
129131
Original file line number Diff line number Diff line change 11const isFormat = require ( '@node-oauth/formats' ) ;
22const InvalidScopeError = require ( '../errors/invalid-scope-error' ) ;
3+ const { isInTypes } = require ( '../utils/param-util' ) ;
34const whiteSpace = / \s + / g;
5+ const isString = isInTypes ( 'string' ) ;
46
57/**
68 * @module ScopeUtil
@@ -22,7 +24,7 @@ function parseScope (requestedScope) {
2224 return undefined ;
2325 }
2426
25- if ( typeof requestedScope !== 'string' ) {
27+ if ( ! isString ( requestedScope ) ) {
2628 throw new InvalidScopeError ( 'Invalid parameter: `scope`' ) ;
2729 }
2830
You can’t perform that action at this time.
0 commit comments