From 3c458b0058e22daf2a3870675156e1ec9f420e69 Mon Sep 17 00:00:00 2001 From: Frazer Smith Date: Tue, 7 Jan 2025 20:38:14 +0000 Subject: [PATCH] refactor: prefix unused params with underscores --- examples/discovery.js | 2 +- examples/facebook.js | 2 +- examples/github.js | 2 +- examples/google-with-pkce.js | 2 +- examples/google.js | 2 +- examples/linkedin.js | 2 +- examples/vatsim-dev.js | 2 +- examples/vatsim.js | 2 +- index.js | 4 ++-- test/index.test.js | 18 +++++++++--------- 10 files changed, 19 insertions(+), 19 deletions(-) diff --git a/examples/discovery.js b/examples/discovery.js index cfa773a..a21c10a 100644 --- a/examples/discovery.js +++ b/examples/discovery.js @@ -75,7 +75,7 @@ fastify.get('/interaction/callback/google', function (request, reply) { Authorization: 'Bearer ' + result.token.access_token }, json: true - }, function (err, res, data) { + }, function (err, _res, data) { if (err) { reply.send(err) return diff --git a/examples/facebook.js b/examples/facebook.js index da05d7d..d3d59f0 100644 --- a/examples/facebook.js +++ b/examples/facebook.js @@ -33,7 +33,7 @@ fastify.get('/login/facebook/callback', function (request, reply) { Authorization: 'Bearer ' + result.access_token }, json: true - }, function (err, res, data) { + }, function (err, _res, data) { if (err) { reply.send(err) return diff --git a/examples/github.js b/examples/github.js index 8674f46..cab16d6 100644 --- a/examples/github.js +++ b/examples/github.js @@ -79,7 +79,7 @@ fastify.get('/login/github/verifyAccessToken', function (request, reply) { body: JSON.stringify({ access_token: accessToken }), json: true }, - function (err, res, data) { + function (err, _res, data) { if (err) { reply.send(err) return diff --git a/examples/google-with-pkce.js b/examples/google-with-pkce.js index c5a0c22..9329cf6 100644 --- a/examples/google-with-pkce.js +++ b/examples/google-with-pkce.js @@ -70,7 +70,7 @@ fastify.get('/interaction/callback/google', function (request, reply) { Authorization: 'Bearer ' + result.token.access_token }, json: true - }, function (err, res, data) { + }, function (err, _res, data) { if (err) { reply.send(err) return diff --git a/examples/google.js b/examples/google.js index 3a8c985..e3083c2 100644 --- a/examples/google.js +++ b/examples/google.js @@ -34,7 +34,7 @@ fastify.get('/login/google/callback', function (request, reply) { Authorization: 'Bearer ' + result.token.access_token }, json: true - }, function (err, res, data) { + }, function (err, _res, data) { if (err) { reply.send(err) return diff --git a/examples/linkedin.js b/examples/linkedin.js index 5a6d63d..ae02a04 100644 --- a/examples/linkedin.js +++ b/examples/linkedin.js @@ -42,7 +42,7 @@ fastify.get('/login/linkedin/callback', function (request, reply) { }, json: true }, - function (err, res, data) { + function (err, _res, data) { if (err) { reply.send(err) return diff --git a/examples/vatsim-dev.js b/examples/vatsim-dev.js index d8e2503..3d36839 100644 --- a/examples/vatsim-dev.js +++ b/examples/vatsim-dev.js @@ -38,7 +38,7 @@ fastify.get('/login/vatsim/callback', function (request, reply) { }, json: true }, - function (err, res, data) { + function (err, _res, data) { if (err) { reply.send(err) return diff --git a/examples/vatsim.js b/examples/vatsim.js index a686577..641fc32 100644 --- a/examples/vatsim.js +++ b/examples/vatsim.js @@ -38,7 +38,7 @@ fastify.get('/login/vatsim/callback', function (request, reply) { }, json: true }, - function (err, res, data) { + function (err, _res, data) { if (err) { reply.send(err) return diff --git a/index.js b/index.js index b6ede6f..695ce3c 100644 --- a/index.js +++ b/index.js @@ -21,7 +21,7 @@ const random = (bytes = 32) => randomBytes(bytes).toString('base64url') const codeVerifier = random const codeChallenge = verifier => createHash('sha256').update(verifier).digest('base64url') -function defaultGenerateStateFunction (request, callback) { +function defaultGenerateStateFunction (_request, callback) { callback(null, random(16)) } @@ -607,7 +607,7 @@ fastifyOauth2.APPLE_CONFIGURATION = { // // Symbol used in here because we would not like the user to modify this behavior and // do not want to mess up with property name collision - [kGenerateCallbackUriParams]: function (callbackUriParams, requestObject, scope, state) { + [kGenerateCallbackUriParams]: function (callbackUriParams, _requestObject, scope, _state) { const stringifyScope = Array.isArray(scope) ? scope.join(' ') : scope // This behavior is not documented on Apple Developer Docs, but it displays through runtime error. // Related Docs: https://developer.apple.com/documentation/sign_in_with_apple/sign_in_with_apple_js/incorporating_sign_in_with_apple_into_other_platforms diff --git a/test/index.test.js b/test/index.test.js index 6c56911..4572dfa 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -272,7 +272,7 @@ t.test('fastify-oauth2', t => { scope: ['notifications'] }) - fastify.get('/', function (request, reply) { + fastify.get('/', function (request) { return this.githubOAuth2.getAccessTokenFromAuthorizationCodeFlow(request) .then(result => { // attempts to refresh the token @@ -350,7 +350,7 @@ t.test('fastify-oauth2', t => { userAgent: 'test/1.2.3' }) - fastify.get('/', function (request, reply) { + fastify.get('/', function (request) { return this.githubOAuth2.getAccessTokenFromAuthorizationCodeFlow(request) .then(result => { // attempts to refresh the token @@ -394,7 +394,7 @@ t.test('fastify-oauth2', t => { userAgent: 'test/1.2.3' }) - fastify.get('/', function (request, reply) { + fastify.get('/', function (request) { return this.githubOAuth2.getAccessTokenFromAuthorizationCodeFlow(request) .then(result => { // attempts to refresh the token @@ -433,7 +433,7 @@ t.test('fastify-oauth2', t => { userAgent: false }) - fastify.get('/', function (request, reply) { + fastify.get('/', function (request) { return this.githubOAuth2.getAccessTokenFromAuthorizationCodeFlow(request) .then(result => { // attempts to refresh the token @@ -2602,7 +2602,7 @@ t.test('options.generateStateFunction', t => { auth: fastifyOauth2.GITHUB_CONFIGURATION }, callbackUri: '/callback', - generateStateFunction: function (request) { + generateStateFunction: function () { return Promise.reject(new Error('generate state failed')) }, checkStateFunction: () => true, @@ -2644,7 +2644,7 @@ t.test('options.generateStateFunction', t => { }, callbackUri: '/callback', startRedirectPath: '/gh', - generateStateFunction: function (request) { + generateStateFunction: function () { return Promise.reject(new Error('generate state failed')) }, checkStateFunction: () => true, @@ -2716,7 +2716,7 @@ t.test('options.checkStateFunction', t => { scope: ['notifications'] }) - fastify.get('/', function (request, reply) { + fastify.get('/', function (request) { return this.githubOAuth2.getAccessTokenFromAuthorizationCodeFlow(request) .then(result => { // attempts to refresh the token @@ -2760,7 +2760,7 @@ t.test('options.checkStateFunction', t => { scope: ['notifications'] }) - fastify.get('/', function (request, reply) { + fastify.get('/', function (request) { return this.githubOAuth2.getAccessTokenFromAuthorizationCodeFlow(request) .then(result => { // attempts to refresh the token @@ -2804,7 +2804,7 @@ t.test('options.checkStateFunction', t => { scope: ['notifications'] }) - fastify.get('/', function (request, reply) { + fastify.get('/', function (request) { return this.githubOAuth2.getAccessTokenFromAuthorizationCodeFlow(request) .then(result => { // attempts to refresh the token