|
|
|
@ -1,5 +1,5 @@ |
|
|
|
import { getQsParam } from './common'; |
|
|
|
import { getQsParam } from './common'; |
|
|
|
import { b64Decode, buildDataString } from './common-webauthn'; |
|
|
|
import { b64Decode, buildDataString, parseWebauthnJson } from './common-webauthn'; |
|
|
|
|
|
|
|
|
|
|
|
// tslint:disable-next-line
|
|
|
|
// tslint:disable-next-line
|
|
|
|
require('./webauthn.scss'); |
|
|
|
require('./webauthn.scss'); |
|
|
|
@ -63,7 +63,7 @@ function start() { |
|
|
|
let json: any; |
|
|
|
let json: any; |
|
|
|
try { |
|
|
|
try { |
|
|
|
const jsonString = b64Decode(data); |
|
|
|
const jsonString = b64Decode(data); |
|
|
|
json = JSON.parse(jsonString); |
|
|
|
json = parseWebauthnJson(jsonString); |
|
|
|
} |
|
|
|
} |
|
|
|
catch (e) { |
|
|
|
catch (e) { |
|
|
|
error('Cannot parse data.'); |
|
|
|
error('Cannot parse data.'); |
|
|
|
@ -74,15 +74,6 @@ function start() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async function initWebAuthn(obj: any) { |
|
|
|
async function initWebAuthn(obj: any) { |
|
|
|
const challenge = obj.challenge.replace(/-/g, '+').replace(/_/g, '/'); |
|
|
|
|
|
|
|
obj.challenge = Uint8Array.from(atob(challenge), c => c.charCodeAt(0)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// fix escaping. Change this to coerce
|
|
|
|
|
|
|
|
obj.allowCredentials.forEach((listItem: any) => { |
|
|
|
|
|
|
|
const fixedId = listItem.id.replace(/\_/g, '/').replace(/\-/g, '+'); |
|
|
|
|
|
|
|
listItem.id = Uint8Array.from(atob(fixedId), c => c.charCodeAt(0)); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|
const assertedCredential = await navigator.credentials.get({ publicKey: obj }) as PublicKeyCredential; |
|
|
|
const assertedCredential = await navigator.credentials.get({ publicKey: obj }) as PublicKeyCredential; |
|
|
|
|
|
|
|
|
|
|
|
|