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

Update register response with transports field #80

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

mat100payette
Copy link

PR for issue #79.

Made this PR very quickly and couldn't find contribution guidelines. I did modify the auto-gen'd file by hand too. Please let me know how to proceed with this to make it clean and ensure it doesn't break anything.

Thanks!

@incorbador incorbador self-requested a review October 14, 2024 09:05
Copy link
Contributor

@incorbador incorbador left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR. I have added 3 points that we have to address to make the change working. Changes like these are quite hard right now because we 1) have no automatic tests and 2) the code for code generation is not yet documented so sorry for that :)

To test your changes I would recommend the following:

  • install melos (https://pub.dev/packages/melos) => very helpful if you work with mono repos
  • run melos bootstrap => this will allow you to use your local changes in the example of the passkeys package
  • run the passkeys example => packages/passkeys/passkeys/example/lib/main.dart

FYI: We are planning to improve the passkeys package quite a bit as it is missing quite some fields from the webauthn specification now. We aim to do that in the upcoming two weeks. I will make sure to document also how to test and add a CONTRIBUTING.md. Ideally, we'll than add a few tests then :)

.setRawId(json.getString("rawId"))
.setClientDataJSON(response.getString("clientDataJSON"))
.setAttestationObject(response.getString("attestationObject"))
.setTransports(json.getJSONArray("transports").toList()).build());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two comments here:

  • You need to regenerate passkeys_android/Messages.java => you can do that by running dart run pigeon --input pigeons/messages.dart from the passkeys_android directory
  • JSONArray does not have a toList() method AFIAK => we would probably need something like this:
JSONArray transports = response.getJSONArray("transports");
List<String> typedTransports = new ArrayList<>();
for (int i = 0; i < transports.length(); i++) {
    typedTransports.add(transports.getString(i));
}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okok good. I added the suggestion in the Java/Swift code, however my environment isn't fully set for Java/Gradle and Swift so I dont have intellisense (I only develop for Web lately). Please double check if possible.

@@ -117,6 +118,9 @@ class RegisterResponse {

/// The attestation object
final String attestationObject;

/// The supported transports for the authenticator
final List<String> transports;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For pigeon (the library we use to generate the glue code between Flutter and native code) every generic type has to be nullable => we have to use final List<String?> transports here and update line 90 in passkeys_android.dart like this r.transports.whereType<String>().toList().

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

});

final String id;
final String rawId;
final String clientDataJSON;
final String attestationObject;
final List<String> transports;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar as with passkeys_android we have to use List<String?> here => you also have to set this new transport field in RegisterController.swift then.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, although please check the Swift code if possible.

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

Successfully merging this pull request may close these issues.

2 participants