Skip to content

Conversation

@pmathew92
Copy link
Contributor

@pmathew92 pmathew92 commented Jun 2, 2025

Changes

This PR adds:

  • A new API client for the My Account API, including its own exception type MyAccountException.
  • A sub-client for the authentication methods endpoints.
    • A method for requesting a passkey enrollment challenge.
    • A method for enrolling a newly created passkey.

Testing

  • This change adds unit test coverage

  • This change adds integration test coverage

  • This change has been tested on the latest version of the platform/language or why not

Checklist

@pmathew92 pmathew92 requested a review from a team as a code owner June 2, 2025 19:45
private val gson: Gson
) {

public val clientId: String
Copy link
Contributor

Choose a reason for hiding this comment

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

What is this used for?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not required. removed

* ```
*
* Then, call ``enroll()`` with the created passkey credential and the challenge to complete
* the enrollment
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* the enrollment
* the enrollment.

*/
@Throws(IOException::class)
public fun fromJson(reader: Reader): T
public fun fromJson(reader: Reader, headers: Map<String, List<String>>): T
Copy link
Contributor

Choose a reason for hiding this comment

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

Would this be a breaking change?

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe an overload with a default implementation (so it doesn't break current conformances) would be enough?
That is, leaving the current interface method as-is –and adding a new one that takes both a reader and a headers map, and that has a default implementation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Made this an optional parameter ,so this wouldn't break any existing usage .

@SerializedName("type")
val type: String,
@SerializedName("usage")
val usage: String,
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't seem to be a field present in the OAS scheme.

Copy link
Contributor

Choose a reason for hiding this comment

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

Nevermind, this was added recently. I'll have to add it to the iOS implementation.

Copy link
Contributor

@Widcket Widcket Jun 2, 2025

Choose a reason for hiding this comment

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

I'd suggest not including it as of now, given how the comment in the PR that added it says "This will probably change in future PRs but I'm fine merging as-is.".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed

}

@Test
public fun `passkeyEnrollmentChallenge should include correct parameters`() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we also include a test case that asserts that, by default, no params are being sent other than "type": "passkey"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added

}
mockAPI.takeRequest()
assertThat(error, Matchers.notNullValue())
assertThat(error?.message, Matchers.`is`("Authentication ID not found"))
Copy link
Contributor

@Widcket Widcket Jun 3, 2025

Choose a reason for hiding this comment

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

This should be Authentication method ID not found. This is relevant because the error message is developer-facing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated


@RunWith(RobolectricTestRunner::class)
@Config(manifest = Config.NONE)
public class MyAccountAPIClientTest {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we include test cases for when the My Account API returns an error?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added cases returning error

@pmathew92 pmathew92 merged commit be54de8 into main Jun 3, 2025
7 checks passed
@pmathew92 pmathew92 deleted the SDK-5544 branch June 3, 2025 18:28
@pmathew92 pmathew92 mentioned this pull request Jun 3, 2025
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.

3 participants