Skip to content

Commit

Permalink
deps: FY25Q2 dependency updates 🌲
Browse files Browse the repository at this point in the history
  • Loading branch information
stdavis committed Oct 3, 2024
1 parent ce42efc commit 3a3305f
Show file tree
Hide file tree
Showing 3 changed files with 545 additions and 353 deletions.
22 changes: 11 additions & 11 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import cors from 'cors';
import debug from 'debug';
import express from 'express';
import admin from 'firebase-admin';
import functions from 'firebase-functions';
import logger from 'firebase-functions/logger';
import got from 'got';
import { createProxyMiddleware } from 'http-proxy-middleware';
import { fixRequestBody } from './fix-request-body.js';
Expand Down Expand Up @@ -34,12 +34,12 @@ export default function init({ app, mappings, host, claimsCheck, proxyOptions, v
const data = snapshot.data();

if (snapshot.exists && !isTokenExpired(data.expires)) {
functions.logger.debug('returning cached token');
logger.debug('returning cached token');

return data.token;
}

functions.logger.debug('requesting new token');
logger.debug('requesting new token');
try {
const response = await got
.post(`${host}/arcgis/tokens/generateToken`, {
Expand All @@ -58,7 +58,7 @@ export default function init({ app, mappings, host, claimsCheck, proxyOptions, v

return response.token;
} catch (error) {
functions.logger.error(error);
error(error);

throw error;
}
Expand All @@ -72,7 +72,7 @@ export default function init({ app, mappings, host, claimsCheck, proxyOptions, v

return applyToken(mappedPath, await getToken(credentials));
},
logger: functions.logger,
logger: logger,
on: {
proxyReq: (proxyRequest, request) => {
proxyRequest.removeHeader('authorization');
Expand All @@ -81,14 +81,14 @@ export default function init({ app, mappings, host, claimsCheck, proxyOptions, v
fixRequestBody(proxyRequest, request);

if (verbose) {
functions.logger.debug('outgoing request to target server', {
logger.debug('outgoing request to target server', {
method: proxyRequest.method,
path: proxyRequest.path,
headers: proxyRequest.getHeaders(),
body: proxyRequest.body,
});

functions.logger.debug('incoming request', {
logger.debug('incoming request', {
method: request.method,
path: request.path,
headers: request.headers,
Expand All @@ -98,7 +98,7 @@ export default function init({ app, mappings, host, claimsCheck, proxyOptions, v
},
proxyRes: (proxyResponse) => {
if (verbose) {
functions.logger.debug('response from target server', {
logger.debug('response from target server', {
method: proxyResponse.method,
path: proxyResponse.path,
headers: proxyResponse.headers,
Expand All @@ -107,7 +107,7 @@ export default function init({ app, mappings, host, claimsCheck, proxyOptions, v
}
},
error: (error) => {
functions.logger.error(error);
error(error);
},
},
...proxyOptions,
Expand All @@ -118,7 +118,7 @@ export default function init({ app, mappings, host, claimsCheck, proxyOptions, v
const errorMessage = `No Firebase access token was passed as a Bearer token in the Authorization header.
Make sure you authorize your request by providing the following HTTP header:
Authorization: Bearer <Firebase Access Token>`;
functions.logger.error(errorMessage);
error(errorMessage);

return response.status(403).send(errorMessage);
}
Expand All @@ -137,7 +137,7 @@ export default function init({ app, mappings, host, claimsCheck, proxyOptions, v
return response.status(403).send('Unauthorized: claims check failed');
} catch (error) {
const errorMessage = 'Error while verifying Firebase access token';
functions.logger.error(errorMessage, error);
error(errorMessage, error);

return response.status(403).send(errorMessage);
}
Expand Down
Loading

0 comments on commit 3a3305f

Please sign in to comment.