refactor: Use functional design for the authentication of apps

This commit is contained in:
Faruk AYDIN
2022-10-03 21:14:54 +03:00
parent 0abab06124
commit 4d5be952ce
17 changed files with 523 additions and 22 deletions

View File

@@ -0,0 +1,22 @@
import crypto from 'crypto';
import OAuth from 'oauth-1.0a';
const oauthClient = ($: any) => {
const consumerData = {
key: $.auth.consumerKey as string,
secret: $.auth.consumerSecret as string,
};
return new OAuth({
consumer: consumerData,
signature_method: 'HMAC-SHA1',
hash_function(base_string, key) {
return crypto
.createHmac('sha1', key)
.update(base_string)
.digest('base64');
},
});
};
export default oauthClient;