Repository navigation
feat: device API client for pair, device/me and events - #6
Merged
Merged
Conversation
Closes the client side of #3: typed results for 401 (re-pair, no retry), 429 with Retry-After, error codes, malformed responses and network failures. Redirects are never followed so the bearer token only goes to the configured server; the base URL must be plain https.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #3
What
HTTP client for the three device-facing routes in the backend's
docs/wire-format.md, built on OkHttp + kotlinx.serialization.pair(),me(),sendEvents()return a typedApiResult:Success,Unauthenticated,RateLimited(retryAfterSeconds),ApiError(status, code),MalformedResponse,NetworkError.Unauthenticated(re-pair, no retry). A 401 on/pairisinvalid_pairing_codeand comes back asApiError.MalformedResponse.label/domainare left out when absent.DeviceToken:toString()is alwaysDeviceToken(***), and the plaintext is reachable only viaauthorizationHeaderValue().Security-relevant
INTERNETpermission. New dependencies: OkHttp 5.5.0, kotlinx.serialization 1.11.0 (plus mockwebserver3/okhttp-tls for tests).gradle/verification-metadata.xmlwas regenerated, and all checks pass with a coldGRADLE_USER_HOME.https, without credentials, query or fragment.toString()cannot leak them. The client does not log anything.domain, as inwire-format.md.Tests
The tests run against MockWebServer over TLS with a certificate generated at runtime. Test tokens and pairing codes are generated at runtime as well.