Alex has pointed out two glaring annoyances to me which have been preventing him from completing his work on the receive file ticket. He wants to write a native test for receiving a file, but:
There is no longer a functional integration for the CLI and frontend
Setting the api endpoint using CLI commands almost always fails
These changes exist to address these issues.
Refactored wasm function complete_device_registration -> approve_device_api_key (approveDeviceApiKey)
Since the loss of the device API key registration route in Next.js, connecting the CLI with the frontend has remained broken in the background while other tickets have taken priority.
Internally, the new version of this command calls CreateDeviceApiKey, using the PEM of the PublicKey associated with the device, which is likewise passed in a URL-encoded base64 string to the new /register-device/:spki endpoint on core. After this call succeeds, it calls EndRegwait using the fingerprint that CreateDeviceApiKey returned, which should match that which is already on the event bus assuming everything has gone smoothly up until this point.
Restructured RunnableCommand, GlobalConfig, and OmniBucket functions to simplify the lifetimes of data associated with an individual CLI run.
The previous version of this trait implementation required &mut handles on the GlobalConfig and Client.
Even though everything should have been working as expected, I believe this tripped up the borrow checker and lead to issues with the wrong versions of these structs being serialized when the run_internal call was completed.
This resulted in the very frustrating outcome of having some CLI commands successfully update the global config.json state, while other failed to entirely (notably the API endpoint command).
This change fixes that bug.
This also has the added benefit of allowing for far more succinct code across the board in the CLI submodule.
GlobalConfig functions which self-modify also save to disk now. The need to do so independently of updating this data structure was causing ambiguity in the source of truth.
Description
Alex has pointed out two glaring annoyances to me which have been preventing him from completing his work on the receive file ticket. He wants to write a native test for receiving a file, but:
These changes exist to address these issues.
complete_device_registration
->approve_device_api_key
(approveDeviceApiKey
)CreateDeviceApiKey
, using the PEM of the PublicKey associated with the device, which is likewise passed in a URL-encoded base64 string to the new/register-device/:spki
endpoint on core. After this call succeeds, it callsEndRegwait
using the fingerprint thatCreateDeviceApiKey
returned, which should match that which is already on the event bus assuming everything has gone smoothly up until this point.RunnableCommand
,GlobalConfig
, andOmniBucket
functions to simplify the lifetimes of data associated with an individual CLI run.&mut
handles on theGlobalConfig
andClient
.run_internal
call was completed.GlobalConfig
functions which self-modify also save to disk now. The need to do so independently of updating this data structure was causing ambiguity in the source of truth.Link to issue
https://linear.app/banyan/issue/ENG-470/unblocking-alex
Type of change