Skip to content

Commit

Permalink
Revert "fix: encode client_secret_basic - _ . ! ~ * ' ( ) characters"
Browse files Browse the repository at this point in the history
This reverts commit 5a2ea80, even
though it is the correct implementation some of the most widely used
identity providers don't follow the specification.
  • Loading branch information
panva committed Jan 6, 2024
1 parent 0378bba commit 66c2ee2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 21 deletions.
21 changes: 1 addition & 20 deletions lib/helpers/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,7 @@ const request = require('./request');
const { keystores } = require('./weak_cache');
const merge = require('./merge');

function formUrlEncode(token) {
return encodeURIComponent(token).replace(/(?:[-_.!~*'()]|%20)/g, (substring) => {
switch (substring) {
case '-':
case '_':
case '.':
case '!':
case '~':
case '*':
case "'":
case '(':
case ')':
return `%${substring.charCodeAt(0).toString(16).toUpperCase()}`;
case '%20':
return '+';
default:
throw new Error();
}
});
}
const formUrlEncode = (value) => encodeURIComponent(value).replace(/%20/g, '+');

async function clientAssertion(endpoint, payload) {
let alg = this[`${endpoint}_endpoint_auth_signing_alg`];
Expand Down
2 changes: 1 addition & 1 deletion test/client/client_instance.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2274,7 +2274,7 @@ describe('Client', () => {
expect(await clientInternal.authFor.call(client, 'token')).to.eql({
headers: {
Authorization:
'Basic YW4lM0FpZGVudGlmaWVyOnNvbWUrc2VjdXJlKyUyNitub24lMkRzdGFuZGFyZCtzZWNyZXQ=',
'Basic YW4lM0FpZGVudGlmaWVyOnNvbWUrc2VjdXJlKyUyNitub24tc3RhbmRhcmQrc2VjcmV0',
},
});
});
Expand Down

0 comments on commit 66c2ee2

Please sign in to comment.