-
Notifications
You must be signed in to change notification settings - Fork 602
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #503 - Add optional client_id to OAuth2
- Loading branch information
Showing
5 changed files
with
107 additions
and
7 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
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/*global InvalidCharacterError*/ | ||
|
||
/** | ||
Adapted from https://github.com/davidchambers/Base64.js | ||
@public | ||
*/ | ||
|
||
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; | ||
|
||
export default { | ||
encode(input) { | ||
let str = String(input); | ||
let output = ''; | ||
for ( | ||
// initialize result and counter | ||
let block, charCode, idx = 0, map = chars; | ||
// if the next str index does not exist: | ||
// change the mapping table to "=" | ||
// check if d has no fractional digits | ||
str.charAt(idx | 0) || (map = '=', idx % 1); | ||
// "8 - idx % 1 * 8" generates the sequence 2, 4, 6, 8 | ||
output += map.charAt(63 & block >> 8 - idx % 1 * 8) | ||
) { | ||
charCode = str.charCodeAt(idx += 3 / 4); | ||
if (charCode > 0xFF) { | ||
throw new InvalidCharacterError("'base64Encode' failed: The string to be encoded contains characters outside of the Latin1 range."); | ||
} | ||
block = block << 8 | charCode; | ||
} | ||
return output; | ||
} | ||
}; |
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