-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
27 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
return null; | ||
} |