Repository navigation
feat(sdk-api,sdk-core): cooperatively yield during password rotation - #10322
Open
noegutierrez5 wants to merge 1 commit into
Open
noegutierrez5 wants to merge 1 commit into
noegutierrez5 wants to merge 1 commit into
Conversation
Add an opt-in `yieldEvery` boundary to every password-rotation loop: - BitGoAPI.changePassword, sdk-api v1 keychains, sdk-core legacy v2, and sdk-core safeId mode accept `yieldEvery?: number`, validated as a positive safe integer at each independently callable public entry. - After every N listed keychain records (updated, skipped, and missing-envelope alike), the loop yields to a new macrotask so the host event loop can process I/O, worker messages, or repaints between bounded stretches of keychain crypto. Omitted/undefined preserves the existing behavior exactly (no timer is ever allocated). - Safe mode stays progress-silent but honors the same record boundary, so the option is never silently ignored on safeId rotations. - Make requestPatch worker-safe: set User-Agent only when XMLHttpRequest is unavailable (Node), not merely when `window` is unavailable. Dedicated workers expose XHR but not window and must never attempt to set User-Agent. WCN-2084
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.
Tip: disable this comment in your organization's Code Review settings.
Contributor
Contributor
|
|
This branch has not been deployed
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
Adds an opt-in cooperative-yielding boundary to account-password rotation (WCN-2084).
BitGoAPI.changePassword()runs the v1 (SJCL) and v2 (Argon2) keychain loops in long, synchronous-event-loop stretches. Progress UI exists, but the callbacks are only observed between those stretches; a large enterprise can still lock the browser tab. Running the rotation in a dedicated worker (retail work in bitgo-retail PR #10191) removes the lockup, and this SDK change makes each worker event-loop turn process a bounded number of keychains.Changes
ChangePasswordOptions(sdk-api) andUpdatePasswordOptions(sdk-core) gainyieldEvery?: number.undefinedpreserves current behavior exactly; invalid values (0, negatives, fractions,NaN, unsafe integers, non-numbers) are rejected at every independently callable public entry withyieldEvery must be a positive safe integer.BitGoAPI.changePasswordvalidates and forwardsyieldEveryto the sdk-api v1 keychains call and the sdk-core coin keychains call.Keychains.updatePasswordKeychains.updatePasswordupdateSafePassword(still progress-silent, but the boundary applies so the option is never silently ignored)requestPatchsetsUser-Agentonly whenXMLHttpRequestis unavailable (Node), instead of whenwindowis unavailable. Dedicated workers expose XHR withoutwindow; the old detection made worker requests attempt to setUser-Agent, which browsers reject.Tests
yieldEvery: 1(deterministic FIFO timer ordering).yieldEveryvalues reject at each public entry before any rotation/network work.yieldEvery: undefinedand preserves behavior.User-Agentdetection: Node sets it; browser (window + XHR) does not; dedicated-worker runtime (no window, XHR present) does not.Verification
yarn workspace @bitgo/sdk-core buildandyarn workspace @bitgo/sdk-api buildpass.yarn workspace @bitgo/sdk-api unit-test 'test/unit/bitgoAPI.ts' 'test/unit/v1/keychains.ts'→ 318 passing.yarn workspace @bitgo/sdk-core unit-test --grep 'Keychains\b'→ 47 passing.lintandcheck-fmtpass for both workspaces.Ticket: WCN-2084