feat: loadKeyShare use getJson - #631
Merged
Merged
Conversation
…s accordingly. This change adds an Authorization header to the postJson function and modifies related functions to pass the token, ensuring secure communication with the MPC backend. Updated tests to verify the presence of the token in requests and validate response structures.
… enhance error handling. Updated loadKeyShareBackup to utilize the new function, ensuring consistent response parsing. Added tests to verify the inclusion of the Bearer token in requests.
Added a new entry to the CHANGELOG noting the change in how the MPC profile token is sent, now using an `Authorization: Bearer` header instead of including it in the JSON request body.
Added an entry to the CHANGELOG noting the change in loading key-share backups using the `GET /load-key-share-backup` endpoint instead of the previous `POST` method.
Keep parseJsonResponse/getJson for GET backup loads, and take the base changelog cleanup for the initial-release notes. Co-authored-by: Cursor <cursoragent@cursor.com>
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.
Summary
parseJsonResponsehelper inpackages/keyring-eth-mpc/src/cloud.tsto centralize JSON parsing and non-OK error handling for cloud API responses.getJsonfor Bearer-authenticated GET requests and refactorpostJsonto reuseparseJsonResponse.loadKeyShareBackupto callgetJsonwith GET instead of POST with an empty body.Note
Medium Risk
Changes the HTTP method for loading encrypted key-share backups; behavior depends on the MPC backend accepting GET on that route.
Overview
Refactors MPC cloud HTTP helpers and fixes how encrypted key-share backups are fetched.
cloud.tsaddsparseJsonResponsefor shared non-OK handling and JSON/empty-body parsing, introducesgetJsonfor Bearer-authenticated GETs, and routespostJsonthrough the same parser (generic renamed toResult).loadKeyShareBackupnow callsgetJsonon/load-key-share-backupinstead ofpostJsonwith an empty body.cloud.test.tsasserts the backup load uses GET withAuthorization: Bearerand no POST body.Reviewed by Cursor Bugbot for commit 2690e54. Bugbot is set up for automated code reviews on this repo. Configure here.