diff --git a/container/shim/src/fetchers/lassie.js b/container/shim/src/fetchers/lassie.js index 8bb74df9..6d928c10 100644 --- a/container/shim/src/fetchers/lassie.js +++ b/container/shim/src/fetchers/lassie.js @@ -227,10 +227,10 @@ function createLassieURL(req, isRawFormat) { } const knownPeers = getKnownPeers(req); - const knownPeersLassieUrl = generatePeersLassieUrl(knownPeers) + const knownPeersLassieUrl = generatePeersLassieUrl(knownPeers); if (knownPeersLassieUrl) { - lassieUrl.searchParams.set("providers", knownPeersLassieUrl) + lassieUrl.searchParams.set("providers", knownPeersLassieUrl); } return lassieUrl; @@ -308,25 +308,24 @@ async function getRequestedBlockFromCar(streamIn, streamOut, cidObj, filename) { } function generatePeersLassieUrl(knownPeers) { - - const peerUrls = [] + const peerUrls = []; if (knownPeers) { - const knownPeerList = [] + const knownPeerList = []; Object.values(knownPeers).forEach((peerList) => { - knownPeerList.push(...peerList) - }) + knownPeerList.push(...peerList); + }); knownPeerList.forEach((peer, idx) => { - const { peerID, multiaddr, protocol } = peer + const { peerID, multiaddr, protocol } = peer; if (!peerID || !multiaddr || !protocol) { - return + return; } - const peerUrl = multiaddr.startsWith('http') ? multiaddr : `${multiaddr}/p2p/${peerID}+${protocol}` - peerUrls.push(peerUrl) - }) + const peerUrl = multiaddr.startsWith("http") ? multiaddr : `${multiaddr}/p2p/${peerID}+${protocol}`; + peerUrls.push(peerUrl); + }); } - const urlString = peerUrls.join(',') - return urlString + const urlString = peerUrls.join(","); + return urlString; } async function queueMetricsReport(newMetric) { diff --git a/container/shim/src/utils/jwt.js b/container/shim/src/utils/jwt.js index 5c342698..d9613356 100644 --- a/container/shim/src/utils/jwt.js +++ b/container/shim/src/utils/jwt.js @@ -1,24 +1,23 @@ -import jwt from "jsonwebtoken"; +import jwt from "jsonwebtoken"; export function findJWT(req) { - const jwtQuery = req.variables.arg_jwt; + const jwtQuery = req.variables.arg_jwt; - let jwtHeader = ""; - const authHeader = req.variables.http_authorization; - if (authHeader) { - jwtHeader = authHeader.replace("Bearer ", ""); - } + let jwtHeader = ""; + const authHeader = req.variables.http_authorization; + if (authHeader) { + jwtHeader = authHeader.replace("Bearer ", ""); + } - return jwtQuery || jwtHeader; + return jwtQuery || jwtHeader; } - export function getKnownPeers(req) { - const reqJwt = findJWT(req) + const reqJwt = findJWT(req); if (reqJwt) { - const jwtObject = jwt.decode(reqJwt) - const knownPeers = jwtObject.knownPeers - return knownPeers + const jwtObject = jwt.decode(reqJwt); + const knownPeers = jwtObject.knownPeers; + return knownPeers; } - return null -} \ No newline at end of file + return null; +}