-
-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: scope in body responses is always a string
1 parent
e01a5e4
commit a2a54c4
Showing
9 changed files
with
44 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,25 @@ | ||
const isFormat = require('@node-oauth/formats'); | ||
const InvalidScopeError = require('../errors/invalid-scope-error'); | ||
const toArray = s => Array.isArray(s) ? s : s.split(' '); | ||
|
||
module.exports = { | ||
parseScope: function (requestedScope) { | ||
if (!isFormat.nqschar(requestedScope)) { | ||
throw new InvalidScopeError('Invalid parameter: `scope`'); | ||
if (typeof requestedScope === 'undefined' || requestedScope === null) { | ||
return undefined; | ||
} | ||
|
||
if (requestedScope == null) { | ||
return undefined; | ||
const internalScope = toArray(requestedScope); | ||
|
||
if (internalScope.length === 0) { | ||
throw new InvalidScopeError('Invalid parameter: `scope`'); | ||
} | ||
|
||
return requestedScope.split(' '); | ||
internalScope.forEach(value => { | ||
if (!isFormat.nqschar(value)) { | ||
throw new InvalidScopeError('Invalid parameter: `scope`'); | ||
} | ||
}); | ||
|
||
return internalScope; | ||
} | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters