SDK: update useAccountUpdateRecovery to use AuthContextV2 adapter - #1376
Conversation
The recovery fix was correct and closed one of four instances of the same bug. Every field on AuthContext is optional, broadcast? included, so AuthContextV2 satisfies it structurally: the type checker sees nothing, auth?.broadcast is silently undefined at runtime, and each site fails only when a user reaches it. That is why this arrived as a Sentry issue rather than a build failure, and why fixing one said nothing about the rest. The web app passes V2 everywhere via getSdkAuthContext, so all of these are reachable today: - useAccountRevokePosting, from manage-authorities.tsx. Same hard throw as the recovery one, on the same permissions page. - useSignOperationByKeychain, from transaction-signer.tsx. Same hard throw. - broadcastJson, from follow-controls.tsx. Different shape: auth.broadcast is the first branch of a fallback chain rather than a requirement, so a Keychain user with a HiveSigner token still worked and one without a stored posting key and no token hit "cannot broadcast w/o posting key or token". broadcastJson gets its adapter branch LAST rather than first. Every branch above it already serves the sessions that reach it, and reordering would change which method signs for people it currently works for; placed last it only claims cases that were previously errors. Left alone deliberately: the two auth.broadcast checks in use-broadcast-mutation sit under case 'custom', where an explicitly supplied broadcaster is the point. Once callers stop passing V1, AuthContext.broadcast has no users left and can go, which would make the next occurrence a compile error instead of a runtime one.
|
Reviewed this and pushed The original fix is correct. I checked the parts that could be wrong: It closed one of four. The same
Why nothing caught them. Every field on One deliberate asymmetry. Left alone on purpose: the two Verified: SDK 678 tests pass, and the web app typechecks clean against the changed signatures, which is the check that matters since all four callers are in Worth a follow-up once callers stop passing V1: |
This PR fixes the "Error: [SDK][Accounts] – missing keychain broadcaster" that occurred when attempting to update a recovery account using Keychain.
Root Cause:
The
useAccountUpdateRecoverymutation in the SDK was expecting anAuthContextobject with a directbroadcastmethod for Keychain operations. However, thegetSdkAuthContextutility in the web app provides anAuthContextV2object, which uses anadapterproperty containingbroadcastWithKeychain.This mismatch led to
auth?.broadcastbeing undefined, causing the error.Solution:
Updated
packages/sdk/src/modules/accounts/mutations/use-account-update-recovery.tsto:authparameter type fromAuthContexttoAuthContextV2.auth.adapter.broadcastWithKeychaininstead of the deprecatedauth.broadcast.This aligns the
useAccountUpdateRecoverymutation with the modernAuthContextV2interface used across other SDK mutations, ensuring Keychain operations function correctly.Fixes ECENCY-NEXT-13WV