Yubico / java-webauthn-server

Server-side Web Authentication library for Java https://www.w3.org/TR/webauthn/#rp-operations
Other
457 stars 142 forks source link

The method toCredentialsCreateJson() is undefined #244

Closed MrMaavin closed 1 year ago

MrMaavin commented 1 year ago

I don't know if I missed something but i tired the following code and got the error "The method toCredentialsCreateJson() is undefined for the type PublicKeyCredentialCreationOptions".

PublicKeyCredentialCreationOptions pkcco =
        rp.startRegistration(StartRegistrationOptions.builder().user(findExistingUser("alice").orElseGet(() -> {
          byte[] userHandle = new byte[64];
          random.nextBytes(userHandle);
          return UserIdentity.builder().name("alice").displayName("Alice Hypothetical").id(new ByteArray(userHandle))
              .build();
        })).build());

PublicKeyCredentialCreationOptionsBuilder credentialCreateJson = pkcco.toCredentialsCreateJson();

I use the following dependency:

<dependency>
        <groupId>com.yubico</groupId>
    <artifactId>webauthn-server-core</artifactId>
    <version>1.9.1</version>
</dependency>

What is wrong? Should i provide more Info and if yes what kind of info?

emlun commented 1 year ago

Hi! That feature was introduced in version 1.11.0, so you'll need to upgrade to at least that to use that method. Otherwise you'll need to use a Jackson ObjectMapper or other serialization tool to convert it to JSON.

MrMaavin commented 1 year ago

Hi! That feature was introduced in version 1.11.0, so you'll need to upgrade to at least that to use that method. Otherwise you'll need to use a Jackson ObjectMapper or other serialization tool to convert it to JSON.

Thanks a lot, that helped me. Maybe that can be updated on the Yubico Java webpage.