Skip to content

Commit

Permalink
Merge pull request #111 from energywebfoundation/force-deploy
Browse files Browse the repository at this point in the history
feat(AuthTokenVerifier): add some brackets
  • Loading branch information
jrhender authored Sep 23, 2021
2 parents 37edda6 + 900399c commit aa98200
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lib/AuthTokenVerifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ export class AuthTokenVerifier {
private isAuthorized = async (claimedToken: string): Promise<boolean> => {
//read publickey field in DID document
const didPubKeys = this.didDocument.publicKey
if (didPubKeys.length === 0)
if (didPubKeys.length === 0) {
return false
}

const keys = new Keys({ privateKey: this.privateKey })
const jwtSigner = new JWT(keys)
Expand Down Expand Up @@ -76,8 +77,9 @@ export class AuthTokenVerifier {
* @returns whether or not the key is an authentication key
*/
private isAuthenticationKey = (publicKey: IPublicKey, documentAuthField: (string | IAuthentication)[]) => {
if (documentAuthField.length === 0 && publicKey !== undefined)
if (documentAuthField.length === 0 && publicKey !== undefined) {
return this.isSigAuth(publicKey["type"])
}
const authenticationKeys = documentAuthField.map(auth => {
return (this.areLinked(auth["publicKey"], publicKey["id"]))
})
Expand All @@ -86,10 +88,12 @@ export class AuthTokenVerifier {

//used to check if publicKey field in authentication refers to the publicKey ID in publicKey field
private areLinked = (authId: string, pubKeyID: string) => {
if (authId === pubKeyID)
if (authId === pubKeyID) {
return true
if (authId.includes("#"))
}
if (authId.includes("#")) {
return pubKeyID.split("#")[0] == authId.split("#")[0]
}
return false
}

Expand Down

0 comments on commit aa98200

Please sign in to comment.