Граф коммитов

499 Коммитов

Автор SHA1 Сообщение Дата
lougeniac64 79df7fe34a Refactored sendEventToDevice to return closeTabs result 2024-10-30 23:28:50 +00:00
Ben Dean-Kawamura eb1f268654 Build improvements with UniFFI library mode
Bumped UniFFI to 0.28.2

Added a tool to run uniffi-bindgen in library mode.  It can input either
a specific library path or the megazord crate name.

Use that simplify several build scripts -- especially the generate docs
ones.  The best part of this is that we no longer have to maintain
hand-written modulemaps, which makes adding a new component harder than
it needs to be.

Split out the uniffi-bindgen commands from `build-xcframework.sh`.  This
way you can run them standalone and see the results, even if you don't
have XCode setup.

One change is that
automation/swift-components-docs/generate-swift-project.sh now uses
`megazord_ios` rather than `megazord`.  I think this should result in
slightly more accurate docs, since historically some components in the
Android megazord aren't in the iOS one (Although, I think they match at
the present).
2024-10-17 17:59:42 +00:00
Ben Dean-Kawamura 7625a2cecc Switch to UniFFI library mode
This removes the need for a lot configuration in our `uniffi.toml`
files.
2024-09-18 20:31:35 +00:00
Bastian Gruber b8b598caf6 fix: add proper Rust doc comments to UDL files 2024-09-16 07:42:17 +00:00
Mark Hammond c3def30308 Back out "Support for a new "close all inactive tabs" command."
This backs out commit 579d17846c.
2024-08-28 20:19:45 +00:00
Mark Hammond 579d17846c Support for a new "close all inactive tabs" command. 2024-08-27 13:52:32 +00:00
Lina Butler 8995a0d108 fxa-client: Replace `DeviceCommandError` with `CloseTabsResult`.
This commit demotes the `TabsNotClosed` error case from a
`DeviceCommandError` variant, to a `CloseTabsResult` variant
specifically for "close tabs".

`FirefoxAccount::close_tabs` only throws `FxaError`s for
account-related errors, as before. Successes and partial successes
are reported via `CloseTabsResult`.
2024-07-16 23:02:00 -07:00
Lina Butler 09a30f37dc fxa-client: Chunk oversized "close tabs" commands.
This commit:

* Introduces a new `DeviceCommandError` type for
  device command-related operations.
* Adds a `DeviceCommandError::TabsNotClosed` error variant, which
  includes the URLs of any tabs that couldn't be sent in a
  "close tabs" command.
* Reworks `FirefoxAccount::close_tabs` to pack URLs that exceed the
  maximum payload size (16 KB by default) into multiple
  device commands.
2024-07-16 23:02:00 -07:00
Lina Butler d4272d9230 all: Fix remaining lint suggestions from Clippy 0.1.79. 2024-07-11 00:03:23 +00:00
Lina Butler 5d0ad19431 all: Add `#[allow(dead_code)]` exemptions to prepare for Rust 1.79.0. 2024-07-11 00:03:23 +00:00
Mark Hammond 3ab90b51f7 Refactor fxa command encryption to avoid duplicated code 2024-06-24 15:07:55 +00:00
Mark Hammond b6094821ad FxaError::Other error should show a description of the other error 2024-06-17 15:41:44 +00:00
Mark Hammond b09581e8e9 [Tabs] Update the pending close schema so it's also a queue of things to send.
* Abstracts the API towards being more general-purpose "tab command" rather than
  being purely about closing individual tabs, with the intention that it's
  easier to add, say, "close all inactive" (because with 100% certainty I
  know this will be a very early request)

* Updates the schema creation code to be less foot-gun-y.

* Renaming a few things so that we consistently use `device_id` for the fxa id
  and `client_id` for the Sync client ID.

* Fixes the case when syncing when the device ID != fxa id.
2024-05-28 19:13:32 +00:00
Alexander Cyon d73a4c7a45 Typos 2024-05-24 20:17:12 +00:00
Lina Butler 55f904c2d2 fxa-client: Omit `ttl` fields from device commands if not set.
c6fdae855c caused Send Tab commands to
be sent with `"ttl": "null"` to the FxA server, since Send Tab
doesn't specify an explicit TTL.

This fixes bug 1895711.
2024-05-08 16:32:56 +00:00
Lina Butler f87a569e36 fxa_client: Add telemetry plumbing for the "close tabs" command. 2024-05-03 07:03:49 +00:00
Lina Butler c6fdae855c fxa_client: Specify a 48-hour TTL for the "close tabs" command. 2024-05-03 07:03:49 +00:00
Lina Butler f2b1d5a132 fxa_client: Add support for the "close tabs" command. 2024-05-03 07:03:49 +00:00
Lina Butler c6550f7557 fxa_client: Generalize incoming and outgoing command telemetry.
This commit refactors the FxA telemetry logic so that it no longer
assumes the only command we report is Send Tab. We'll use this to
report telemetry for the Close Tabs command separately.

This commit also adds default values for `flow_id` and `stream_id`
to the `SendTabPayload` binding, to prepare for its eventual removal.
2024-04-30 04:54:07 +00:00
Ben Dean-Kawamura ad2a484e77 Bug 1887071 - Clear out tokens/keys when starting an oauth flow 2024-03-26 19:48:00 +00:00
Tarik Eshaq f684a2abcb Swiftformat 2024-03-12 19:12:56 +00:00
Tarik Eshaq 359ce692ce Fixes ktlint 2024-03-12 19:12:56 +00:00
Tarik Eshaq 8d26d0d463 Adds tests and changelog 2024-03-12 19:12:56 +00:00
Tarik Eshaq 3ccf6c1c8e Recieves session token from application before oauth 2024-03-12 19:12:56 +00:00
Ben Dean-Kawamura 497daa010f Bug 1884434 - log a breadcrumb when check_internal_state is successful
I also updated the check_public_state breadcrumb code so that we don't
output the successfull breadcrumb after a state mismatch.
2024-03-08 21:30:26 +00:00
Ben Dean-Kawamura a70d9ca7b1 Bug 1883413 - Handle `Disconnect` event from `AuthIssues` state
Also updated the state machine error messages.  This was based on me
trying to read through them and finding the current ones lacking.
2024-03-04 16:47:41 +00:00
Ben Dean-Kawamura 592063cbab Fxa state checker: handle public events that immediately transition to a new state
Handle the case where a public event results in an immediate public
state transition (i.e. the initial state of the internal state machine
is `Complete(new_state)`).  Copied the code that does this from
`handle_internal_event` to `handle_public_event`.

Also reworked a couple of the breadcrumb messages.  In particular, I got
confused because was both the public and internal event handlers sent
out breadcrumbs that look the same.
2024-02-28 21:24:54 +00:00
Ryan VanderMeulen f0fe4a2cdd Use a Gradle version catalog for managing dependencies 2024-02-21 19:07:00 +00:00
Ben Dean-Kawamura 277d2c0224 Bug 1880329 - Tweak handling of failures to complete FxA OAuth
Transition to the `Disconnected` state in this case to match the
behavior of android-components.

I'm not sure which behavior is better or worse, but this one will make
the state machine checker happy.
2024-02-14 18:31:20 +00:00
Ben Dean-Kawamura 471fb69eb6 Fxa - state machine check breadcrumb improvements
Updating the code after seeing the initial reports back:

- Adding some more details
- Use "Ath" instead of "Auth" to avoid sentry filtering the text.
2024-02-02 19:23:46 +00:00
Ben Dean-Kawamura 40516f4bac Adding network/auth retries to the fxa state machine 2024-01-25 22:56:37 +00:00
Ryan VanderMeulen ab01e05def Add namespaces to the various modules 2024-01-22 19:57:26 +00:00
Mark Hammond 3c43e3fb4a Update Rust version to 1.75, MSR to 1.70 2024-01-12 16:17:00 +00:00
Ben Dean-Kawamura 900f91bc56 Updating the refresh token breadcrumb text
This was updated in #6024, but now I'm just seeing `[Filtered]` in the
Sentry reports.  I think the word "token" is causing it to be filtered.
2024-01-03 21:53:23 +00:00
Ben Dean-Kawamura c296176df7 FxA: Update the error simulation code
- Added the `simulate_network_error` method.
- Hooked up the methods to the Android wrapper
- Added the `CallGetProfile` event, which forces a call to
  `get_profile`.  This was the best method I found to check the error
  handling, since `get_profile` requires both a network request and an
  access token.
2023-12-27 19:59:16 +00:00
Ben Dean-Kawamura 0417e91b2a Record the refresh token length in the get devices breadcrumb
My current theory is that this happens when we send FxA an invalid
refresh token.  Maybe this extra data in the breadcrumb will help
identify that. See the bug for details.
2023-12-27 19:09:44 +00:00
Ben Dean-Kawamura 87888d074f Fxa: Improving the state machine logging
- Include more state transition details in the breadcrumbs
- Updating the error handling log messages to include the report class
  if present.  This makes ADB grepping easier.
2023-12-21 18:18:26 +00:00
Ben Dean-Kawamura b491756369 FxA: Expose the process_event method on android 2023-12-20 18:09:00 +00:00
Ben Dean-Kawamura 4aa3855ba2 FxA State machine checker message improvements
When looking through the logs, I found myself wanting a couple things:
  - When a public state transition starts/ends
  - Better messaging when an unexpected state is observed
2023-12-19 22:05:03 +00:00
Mark Hammond 79d24ff85a Use uniffi as a workspace dependency 2023-12-15 18:32:25 +00:00
Ben Dean-Kawamura 48229d0101 Updating the Kotlin getAccessToken docstring 2023-12-13 15:23:24 +00:00
Ben Dean-Kawamura 28c13ef1c9 Adding state machine checking logic
This is temporary functionality to help migrate the state machine logic
from firefox-android/firefox-ios to app-services.

See
https://docs.google.com/document/d/1Us3Y6mjkCEYIqb-BCfRS15IX6jcoWhRkpHMVI0rKukg/edit
for details on this plan.
2023-12-11 15:23:39 +00:00
Ben Dean-Kawamura cc8b3df681 Adding FxA state machine
This implements some of the functionality from the `FxaAccountManager`
classes that exist in `android-components` and in our Swift wrapper
layer.

The goal is move the functionality into Rust so that it's easier to
maintain and also so that other appliations can use it without depending
on `android-components`.

I created a new module directory for this code rather than putting it in
`internal`. This felt better to me since the state machine exists in a
layer above `FirefoxAccount`.

Added a document that describes the state machines.  I wasn't sure where
to put it, but I felt like the best place was inline with the code.
2023-12-11 15:23:39 +00:00
Ben Dean-Kawamura 8c293ebdd5 Record a breadcrumb with the get_devices timestamp
Maybe this will help us figure out https://bugzilla.mozilla.org/show_bug.cgi?id=1866538
2023-12-05 16:38:21 +00:00
Ben Dean-Kawamura aa988cbd57 Define the FxA `DeviceConfig` struct
This was defined in Swift, but I want to use it in Rust too.
2023-12-01 13:54:38 +00:00
Ben Dean-Kawamura 54ec6e1f4b Upgarding UniFFI to `0.25.2`
Mostly mechanical, the one extra step was to add the `serde::derive`
feature to `remote_settings`.  I guess it's not pulling that feature in
from `uniffi` anymore.

oneshot is a new dependency for UniFFI.  It specifies its license in
Cargo.toml but doesn't include the file, so I linked to the official
Apache 2.0 license text.
2023-12-01 13:37:08 +00:00
Ben Dean-Kawamura afa6e730c7 Removed FxA MetricsParams
This allowed consumers to add extra query parameters to oauth flow URLs.
However, it wasn't being used so let's kill it.
2023-11-28 22:22:22 +00:00
Ben Dean-Kawamura 993ab57c7b Record more details for `OriginMismatch`
We're getting a higher rate of these than expected, let's try to figure
out what's happening.
2023-11-23 00:48:33 +00:00
Ben Dean-Kawamura acbb1bef48 Split of some known error cases from `fxa-client-other-error`
NoExistingAuthFlow can happen when users manually navigate through the
oauth flow URLs. Just count the errors in Glean rather than report them
to Sentry.  Use a separate label for the errors, and reserve `fxa_other`
for unexpected errors.

Handle OriginMismatch the same, which can happen when trying to pair two
firefox instances that are configured to use different servers.

BackoffError was similar, but I kept the sentry reporting for this one,
since it seems useful to see the reason for backoff errors.  Going
through the current list of backoff errors lead me to open #5918
2023-11-16 16:03:00 +00:00
Ben Dean-Kawamura 0a53eff4c6 Expose the `get_auth_state()` method on Kotlin 2023-11-14 19:00:48 +00:00