Skip to content

feat: loadKeyShare use getJson - #631

Merged
matthiasgeihs merged 8 commits into
mg/mpc-keyringfrom
cw/loadKeyShare-getJson-v1
Sep 4, 2026
Merged

feat: loadKeyShare use getJson #631
matthiasgeihs merged 8 commits into
mg/mpc-keyringfrom
cw/loadKeyShare-getJson-v1

Conversation

@ieow

@ieow ieow commented Sep 4, 2026

Copy link
Copy Markdown

Summary

  • Add a shared parseJsonResponse helper in packages/keyring-eth-mpc/src/cloud.ts to centralize JSON parsing and non-OK error handling for cloud API responses.
  • Introduce getJson for Bearer-authenticated GET requests and refactor postJson to reuse parseJsonResponse.
  • Update loadKeyShareBackup to call getJson with 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.ts adds parseJsonResponse for shared non-OK handling and JSON/empty-body parsing, introduces getJson for Bearer-authenticated GETs, and routes postJson through the same parser (generic renamed to Result). loadKeyShareBackup now calls getJson on /load-key-share-backup instead of postJson with an empty body.

cloud.test.ts asserts the backup load uses GET with Authorization: Bearer and no POST body.

Reviewed by Cursor Bugbot for commit 2690e54. Bugbot is set up for automated code reviews on this repo. Configure here.

ieow added 2 commits September 4, 2026 17:42
…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.
@ieow ieow changed the title Refactor cloud API to introduce getJson function for GET requests and 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. feat: loadKeyShare use getJson Sep 4, 2026
@ieow ieow mentioned this pull request Sep 4, 2026
2 tasks
ieow added 4 commits September 4, 2026 17:59
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.
@ieow
ieow marked this pull request as ready for review September 4, 2026 10:24
@ieow
ieow requested a review from a team as a code owner September 4, 2026 10:24
Base automatically changed from cw/header-token-v2 to mg/mpc-keyring September 4, 2026 10:45
matthiasgeihs and others added 2 commits September 4, 2026 12:52
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>
@matthiasgeihs
matthiasgeihs merged commit ab3f2a0 into mg/mpc-keyring Sep 4, 2026
15 of 16 checks passed
@matthiasgeihs
matthiasgeihs deleted the cw/loadKeyShare-getJson-v1 branch September 4, 2026 10:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants