Created
October 8, 2019 10:59
-
-
Save yackermann/105cec029ea353be021525288707bee0 to your computer and use it in GitHub Desktop.
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
let performGetAssertion = (getAssertionRequest) => { | |
getAssertionRequest.challenge = base64url.decode(getAssertionRequest.challenge); | |
if(getAssertionRequest.allowCredentials) { //If RK scenario | |
for(let allowCred of getAssertionRequest.allowCredentials) { | |
allowCred.id = base64url.decode(allowCred.id); | |
} | |
} | |
return getAssertionRequest | |
} | |
let preformatMakeCredReq = (makeCredentialRequest) => { | |
makeCredentialRequest.challenge = base64url.decode(makeCredentialRequest.challenge); | |
makeCredentialRequest.user.id = base64url.decode(makeCredentialRequest.user.id); | |
if(makeCredentialRequest.excludeCredentials) { | |
for(let excludeCred of makeCredentialRequest.excludeCredentials) { | |
excludeCred.id = base64url.decode(excludeCred.id); | |
} | |
} | |
return makeCredentialRequest | |
} | |
let publicKeyCredentialToJSON = (pubKeyCred) => { | |
if(pubKeyCred instanceof Array) { | |
let arr = []; | |
for(let i of pubKeyCred) | |
arr.push(publicKeyCredentialToJSON(i)); | |
return arr | |
} | |
if(pubKeyCred instanceof ArrayBuffer) { | |
return base64url.encode(pubKeyCred) | |
} | |
if(pubKeyCred instanceof Object) { | |
let obj = {}; | |
for (let key in pubKeyCred) { | |
obj[key] = publicKeyCredentialToJSON(pubKeyCred[key]) | |
} | |
return obj | |
} | |
return pubKeyCred | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment