Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type Error: On AttestationConveyancePreference #215

Closed
6Hat opened this issue Apr 13, 2021 · 5 comments
Closed

Type Error: On AttestationConveyancePreference #215

6Hat opened this issue Apr 13, 2021 · 5 comments

Comments

@6Hat
Copy link

6Hat commented Apr 13, 2021

I've been struggling with this for days. In short on line newCredential = await navigator.credentials.create({publicKey: options}); I am getting this error: "exception:TypeError: Failed to execute 'create' on 'CredentialsContainer': The provided value '2' is not a valid enum value of type AttestationConveyancePreference."

The browser is not liking the C# Enum AttestationConveyancePreference... it doen't matter if I set it to None, Indirect, or as in the case a value of '2' Direct. I do some JavaScript coding but it is not my strong suit... I believe it is a type error as according to the docs JavaScript seems to have a String Enum:
enum AttestationConveyancePreference {
"none",
"indirect",
"direct",
"enterprise"
};
My implementation must be wrong somehow as this surely would have been reported previously.... I am trying to convert a couple Asp.Net MVC examples over to a stand alone Blazor Web Assembly client with an API as the back end. So far everything seems to work well except this one line. Any help, thoughts or ideas would be greatly appreciated!

@6Hat
Copy link
Author

6Hat commented Apr 13, 2021

Starting from scratch I completely removed my front end implementation of blazor and left hard coded values and basically came across the same error. My initial thought was that this line:
// 4. Temporarily store options, session/in-memory cache/redis/db
HttpContext.Session.SetString("fido2.attestationOptions", options.ToJson());
Wouldn't be necessary from the server as I thought I could just set attestationOptions in local storage when returned to the client... So I commented the line out... but now I believe not having the session set may be what is causing me issues?

Since I have an Asp.net Web Api back... it is not possible for me to create a session... is there any way around this?

@abergs
Copy link
Collaborator

abergs commented Apr 13, 2021

You would need to store the attestatoinOptions in a secure way (e.g. session) so that you can use them to verify the response you get back from the client.

@6Hat
Copy link
Author

6Hat commented Apr 13, 2021

Ok... I did manage to store everything within the session... I followed the same method as in the example but I put it in the session on the client versus the server. However, even with this I am still getting the same error. See code example:
string url = string.Format("{0}{1}", Endpoints.UsersFidoOptions, userId);
var options = await userRepository.FidoOptions(url);
if (options != null)
{
string json = JsonConvert.SerializeObject(options);
await sessionStorage.SetItemAsync("fido2.attestationOptions", json);
if (options.Status != "ok")
{
// Error Message
}

            try
            {
                await jsRuntime.InvokeVoidAsync("blazorInterop.registerOptions", options);
            }
            catch (JSException e)
            {
                string err = e.Message;
            }

Here is my CredentialCreateOptions object returned from the server... see anything I am missing?
{
"rp":{
"id":"ibcentral",
"name":"IB-Fido2"
},
"user":{
"name":"[email protected]",
"id":"ZnliaW5jQGxpdmUuY29t",
"displayName":"Brian Bobby"
},
"challenge":"AhnFe90qr1FpHlzwMS-hDw",
"pubKeyCredParams":[
{
"type":"public-key",
"alg":-7
},
{
"type":"public-key",
"alg":-257
},
{
"type":"public-key",
"alg":-37
},
{
"type":"public-key",
"alg":-35
},
{
"type":"public-key",
"alg":-258
},
{
"type":"public-key",
"alg":-38
},
{
"type":"public-key",
"alg":-36
},
{
"type":"public-key",
"alg":-259
},
{
"type":"public-key",
"alg":-39
}
],
"timeout":60000,
"attestation":"direct",
"authenticatorSelection":{
"authenticatorAttachment":"cross-platform",
"requireResidentKey":false,
"userVerification":"discouraged"
},
"excludeCredentials":[

],
"extensions":{

},
"status":"ok",
"errorMessage":""
}

@aseigler
Copy link
Collaborator

Pretty sure we put this one to bed via https://stackoverflow.com/a/67139025/15356060.

@6Hat
Copy link
Author

6Hat commented Apr 21, 2021

Yes, thank you... I meant to update it but have been sidetracked trying to finalize this project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants