Throwing that the TypeError: Failed to execute 'create' on 'CredentialsContainer': The provided value is not of type '(ArrayBuffer or ArrayBufferView)'
Getting this when i run the code for FIDO2 registration. TypeError: Failed to execute 'create' on 'CredentialsContainer': The provided value is not of type '(ArrayBuffer or ArrayBufferView)'
here is the code fragment
var credentialsContainer = window.navigator; credentialsContainer.credentials.create({ publicKey: challengeBuffer.Response }) .then(credResp => { // convert response to base64url var credResponse = preregResponseToBase64(credResp); console.log("comin Here=="+credResponse); //invokeRegistrationApi(credResponse); }) .catch(error => { alert("Something went wrong. "+error); });
Please help stuck at this point .Thanks
@ankushpatel120
According to the error it appears that the challenge you are passing into the 'create' call is not of type ArrayBuffer.
To check the type of the challenge please add the following line above your code block and recompile your code:
console.log(challengeBuffer);
Check the browser console log by pressing f12 and switching to the 'console' tab. If the challenge is properly formatted it should look like:
challenge: ArrayBuffer byteLength: 16
If you are basing your implementation off of our sample code here are some suggestions on where the issue might be occurring:
- preregToBuffer function: https://github.com/StrongKey/fido2/blob/73ab29299c0e2a73df24c99e8cf489e9500f1ad5/sampleapps/java/basic/server/src/main/webapp/js/fido2demo.js#L395
- base64 decode function: https://github.com/StrongKey/fido2/blob/73ab29299c0e2a73df24c99e8cf489e9500f1ad5/sampleapps/java/basic/server/src/main/webapp/js/base64url.js#L33