From acd0a96452413a060ed1ccc174b82184e16a95bc Mon Sep 17 00:00:00 2001 From: coratgerl <73360179+coratgerl@users.noreply.github.com> Date: Sat, 28 Oct 2023 18:41:15 +0200 Subject: [PATCH] fix: lint --- spec/AuthenticationAdapters.spec.js | 22 ++++++++++------------ src/Adapters/Auth/apple.js | 1 - src/Adapters/Auth/facebook.js | 1 - src/Adapters/Auth/utils.js | 3 ++- 4 files changed, 12 insertions(+), 15 deletions(-) diff --git a/spec/AuthenticationAdapters.spec.js b/spec/AuthenticationAdapters.spec.js index f3f9ce4ace..dee82fdc58 100644 --- a/spec/AuthenticationAdapters.spec.js +++ b/spec/AuthenticationAdapters.spec.js @@ -1454,7 +1454,6 @@ describe('oauth2 auth adapter', () => { describe('apple signin auth adapter', () => { const apple = require('../lib/Adapters/Auth/apple'); const jwt = require('jsonwebtoken'); - const util = require('util'); const authUtils = require('../lib/Adapters/Auth/utils'); it('(using client id as string) should throw error with missing id_token', async () => { @@ -1516,7 +1515,7 @@ describe('apple signin auth adapter', () => { spyOn(authUtils, 'getHeaderFromToken').and.callFake(() => fakeDecodedToken.header); spyOn(authUtils, 'getSigningKey').and.resolveTo(fakeSigningKey); spyOn(jwt, 'verify').and.callFake(() => fakeClaim); - + const result = await apple.validateAuthData( { id: 'the_user_id', token: 'the_token' }, { clientId: 'secret' } @@ -2007,7 +2006,6 @@ describe('microsoft graph auth adapter', () => { describe('facebook limited auth adapter', () => { const facebook = require('../lib/Adapters/Auth/facebook'); const jwt = require('jsonwebtoken'); - const util = require('util'); const authUtils = require('../lib/Adapters/Auth/utils'); // TODO: figure out a way to run this test alongside facebook classic tests @@ -2068,7 +2066,7 @@ describe('facebook limited auth adapter', () => { exp: Date.now(), sub: 'the_user_id', }; - const fakeDecodedToken = { header: { kid: '123', alg: 'RS256' }}; + const fakeDecodedToken = { header: { kid: '123', alg: 'RS256' } }; const fakeSigningKey = { kid: '123', rsaPublicKey: 'the_rsa_public_key' }; spyOn(authUtils, 'getHeaderFromToken').and.callFake(() => fakeDecodedToken.header); spyOn(authUtils, 'getSigningKey').and.resolveTo(fakeSigningKey); @@ -2083,7 +2081,7 @@ describe('facebook limited auth adapter', () => { }); it('should not verify invalid id_token', async () => { - const fakeDecodedToken = { header: { kid: '123', alg: 'RS256' }}; + const fakeDecodedToken = { header: { kid: '123', alg: 'RS256' } }; const fakeSigningKey = { kid: '123', rsaPublicKey: 'the_rsa_public_key' }; spyOn(authUtils, 'getHeaderFromToken').and.callFake(() => fakeDecodedToken); spyOn(authUtils, 'getSigningKey').and.resolveTo(fakeSigningKey); @@ -2118,7 +2116,7 @@ describe('facebook limited auth adapter', () => { exp: Date.now(), sub: 'the_user_id', }; - const fakeDecodedToken = { header: { kid: '123', alg: 'RS256' }}; + const fakeDecodedToken = { header: { kid: '123', alg: 'RS256' } }; const fakeSigningKey = { kid: '123', rsaPublicKey: 'the_rsa_public_key' }; spyOn(authUtils, 'getHeaderFromToken').and.callFake(() => fakeDecodedToken); spyOn(authUtils, 'getSigningKey').and.resolveTo(fakeSigningKey); @@ -2138,7 +2136,7 @@ describe('facebook limited auth adapter', () => { exp: Date.now(), sub: 'the_user_id', }; - const fakeDecodedToken = { header: { kid: '123', alg: 'RS256' }}; + const fakeDecodedToken = { header: { kid: '123', alg: 'RS256' } }; const fakeSigningKey = { kid: '123', rsaPublicKey: 'the_rsa_public_key' }; spyOn(authUtils, 'getHeaderFromToken').and.callFake(() => fakeDecodedToken); spyOn(authUtils, 'getSigningKey').and.resolveTo(fakeSigningKey); @@ -2158,7 +2156,7 @@ describe('facebook limited auth adapter', () => { exp: Date.now(), sub: 'the_user_id', }; - const fakeDecodedToken = { header: { kid: '123', alg: 'RS256' }}; + const fakeDecodedToken = { header: { kid: '123', alg: 'RS256' } }; const fakeSigningKey = { kid: '123', rsaPublicKey: 'the_rsa_public_key' }; spyOn(authUtils, 'getHeaderFromToken').and.callFake(() => fakeDecodedToken); spyOn(authUtils, 'getSigningKey').and.resolveTo(fakeSigningKey); @@ -2176,7 +2174,7 @@ describe('facebook limited auth adapter', () => { iss: 'https://not.facebook.com', sub: 'the_user_id', }; - const fakeDecodedToken = { header: { kid: '123', alg: 'RS256' }}; + const fakeDecodedToken = { header: { kid: '123', alg: 'RS256' } }; const fakeSigningKey = { kid: '123', rsaPublicKey: 'the_rsa_public_key' }; spyOn(authUtils, 'getHeaderFromToken').and.callFake(() => fakeDecodedToken); spyOn(authUtils, 'getSigningKey').and.resolveTo(fakeSigningKey); @@ -2202,7 +2200,7 @@ describe('facebook limited auth adapter', () => { iss: 'https://not.facebook.com', sub: 'the_user_id', }; - const fakeDecodedToken = { header: { kid: '123', alg: 'RS256' }}; + const fakeDecodedToken = { header: { kid: '123', alg: 'RS256' } }; const fakeSigningKey = { kid: '123', rsaPublicKey: 'the_rsa_public_key' }; spyOn(authUtils, 'getHeaderFromToken').and.callFake(() => fakeDecodedToken); spyOn(authUtils, 'getSigningKey').and.resolveTo(fakeSigningKey); @@ -2229,7 +2227,7 @@ describe('facebook limited auth adapter', () => { iss: 'https://not.facebook.com', sub: 'the_user_id', }; - const fakeDecodedToken = { header: { kid: '123', alg: 'RS256' }}; + const fakeDecodedToken = { header: { kid: '123', alg: 'RS256' } }; const fakeSigningKey = { kid: '123', rsaPublicKey: 'the_rsa_public_key' }; spyOn(authUtils, 'getHeaderFromToken').and.callFake(() => fakeDecodedToken); spyOn(authUtils, 'getSigningKey').and.resolveTo(fakeSigningKey); @@ -2308,7 +2306,7 @@ describe('facebook limited auth adapter', () => { aud: 'invalid_client_id', sub: 'a_different_user_id', }; - const fakeDecodedToken = { header: { kid: '123', alg: 'RS256' }}; + const fakeDecodedToken = { header: { kid: '123', alg: 'RS256' } }; const fakeSigningKey = { kid: '123', rsaPublicKey: 'the_rsa_public_key' }; spyOn(authUtils, 'getHeaderFromToken').and.callFake(() => fakeDecodedToken); spyOn(authUtils, 'getSigningKey').and.resolveTo(fakeSigningKey); diff --git a/src/Adapters/Auth/apple.js b/src/Adapters/Auth/apple.js index 34b2084e36..4fd1153b75 100644 --- a/src/Adapters/Auth/apple.js +++ b/src/Adapters/Auth/apple.js @@ -3,7 +3,6 @@ const Parse = require('parse/node').Parse; const jwksClient = require('jwks-rsa'); -const util = require('util'); const jwt = require('jsonwebtoken'); const authUtils = require('./utils'); diff --git a/src/Adapters/Auth/facebook.js b/src/Adapters/Auth/facebook.js index 2ca8f326c2..896fad0ff4 100644 --- a/src/Adapters/Auth/facebook.js +++ b/src/Adapters/Auth/facebook.js @@ -2,7 +2,6 @@ const Parse = require('parse/node').Parse; const crypto = require('crypto'); const jwksClient = require('jwks-rsa'); -const util = require('util'); const jwt = require('jsonwebtoken'); const httpsRequest = require('./httpsRequest'); const authUtils = require('./utils'); diff --git a/src/Adapters/Auth/utils.js b/src/Adapters/Auth/utils.js index 66d049cb7a..0d4d7cd8a2 100644 --- a/src/Adapters/Auth/utils.js +++ b/src/Adapters/Auth/utils.js @@ -1,4 +1,5 @@ const jwt = require('jsonwebtoken'); +const util = require('util'); const Parse = require('parse/node').Parse; const getHeaderFromToken = token => { const decodedToken = jwt.decode(token, { complete: true }); @@ -16,7 +17,7 @@ const getHeaderFromToken = token => { */ async function getSigningKey(client, key) { return util.promisify(client.getSigningKey)(key); -}; +} module.exports = { getHeaderFromToken, getSigningKey,