Skip to content

feat(kyc-controller): Add ukycCapabilityToken refresh - #10692

Merged
jiexi merged 26 commits into
mainfrom
jl/kyc-controller-capability-token-refresh
Oct 9, 2026
Merged

jiexi merged 26 commits into
mainfrom
jl/kyc-controller-capability-token-refresh

Conversation

@jiexi

@jiexi jiexi commented Oct 6, 2026 •

Copy link
Copy Markdown
Member
  • BREAKING: Makes refreshSessionStatus() async
  • Adds ukycCapabilityToken expiry check via SessionStatus.capabilityAuthorizationStatus
  • Refreshes the token/authorization if expired when startSession() or refreshSessionStatus() is called
  • Refreshes the token/authorization if expired during the polling loop
  • Updates RampsController to await refreshSessionStatus()

Note this is purposely not included during polling for simplicity's sake. Note this is not included during polling due to race conditions introduced with clearState() / reset() which can be resolved with a separate explicit call to resume/init. The ukycCapabilityToken lives for 72h which will far exceed the time the wallet is kept alive in the onboarding screens

See: https://consensyssoftware.atlassian.net/browse/KYC-29?atlOrigin=eyJpIjoiODU1NTA2ODg5YjBmNGNkZWE4M2ZmZDVkMWRkZmQzZWEiLCJwIjoiaiJ9

Screen.Recording.2026-10-07.at.11.42.48.AM.mov

Note

High Risk
Changes KYC session resume, cryptographic wrapping-key rotation, and when authorizations are submitted—security-sensitive identity flows with altered startSession and provider-launch assumptions.

Overview
Adds UKYC capability authorization refresh when resuming a session: startSession now loads the latest session status and, when capabilityAuthorizationStatus is new or expired (and KYC is not already approved/rejected), mints a new X25519 keypair, calls KycService.resetWrappingKeys (POST /sessions/{id}/wrapping-keys), and resubmits wrapped secrets via setAuthorizations.

refreshSessionStatus is narrowed to return the persisted session and only start polling for non-terminal statuses—it no longer fetches status or refreshes capability auth. Polling likewise updates status only and does not trigger authorization refresh (tests lock this in). The SumSub provider launch path is simplified to assume authorizations are already valid on state.

The package exports capability/KYC status helpers (needsCapabilityAuthorizationRefresh, related constants), parses optional capabilityAuthorizationStatus on session status responses, and documents the changes in the changelog.

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

@jiexi
jiexi requested review from a team as code owners October 6, 2026 20:19
@jiexi
jiexi deployed to default-branch October 6, 2026 20:19 — with GitHub Actions Active
@jiexi jiexi changed the title jl/kyc controller capability token refresh feat(kyc-controller): Add ukycCapabilityToken refresh on startSession() Oct 6, 2026

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread packages/kyc-controller/src/KycController.ts
@ggprod

ggprod commented Oct 7, 2026

Copy link
Copy Markdown

@metamaskbot update-changelogs

INFRA-4093 test. This checks token exchange for the changelog update on a PR that already changes a changelog. It is not a review request. This PR will be left open.

@metamask-ci

metamask-ci Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

✅ No changelog changes needed.

@jiexi jiexi changed the title feat(kyc-controller): Add ukycCapabilityToken refresh on startSession() feat(kyc-controller): Add ukycCapabilityToken refresh on startSession() and refreshSessionStatus() Oct 7, 2026
@jiexi jiexi changed the title feat(kyc-controller): Add ukycCapabilityToken refresh on startSession() and refreshSessionStatus() feat(kyc-controller): Add ukycCapabilityToken refresh Oct 7, 2026
@jiexi
jiexi requested a review from a team as a code owner October 7, 2026 19:03

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread packages/ramps-controller/src/RampsController.ts Outdated
Co-authored-by: Cursor <cursoragent@cursor.com>

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread packages/kyc-controller/src/KycController.ts Outdated

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread packages/kyc-controller/src/KycController.ts Outdated

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit a92889a. Configure here.

Comment thread packages/kyc-controller/src/KycController.ts Outdated
jiexi and others added 7 commits October 9, 2026 11:21
Co-authored-by: Cursor <cursoragent@cursor.com>
The changelog check only reads a pull request link from the first line, so the wrapped #10692 links were ignored.

Co-authored-by: Cursor <cursoragent@cursor.com>
Signed-off-by: Sébastien Van Eyck <sebastien.vaneyck@consensys.net>
…en-refresh' into jl/kyc-controller-capability-token-refresh

# Conflicts:
#	packages/kyc-controller/CHANGELOG.md
#	packages/kyc-controller/src/KycController.ts
Akaryatrh
Akaryatrh previously approved these changes Oct 9, 2026
The continuation lines were under-indented, which failed lint:misc.

Co-authored-by: Cursor <cursoragent@cursor.com>
@jiexi
jiexi added this pull request to the merge queue Oct 9, 2026
Merged via the queue into main with commit 9c5ffbb Oct 9, 2026
680 of 682 checks passed
@jiexi
jiexi deleted the jl/kyc-controller-capability-token-refresh branch October 9, 2026 22:08
geositta added a commit that referenced this pull request Oct 10, 2026
…movement-failures

* origin/main:
  feat(perps-controller): add shared Perps error tagging for Sentry (#10681)
  feat(kyc-controller): Add ukycCapabilityToken refresh (#10692)
  feat(kyc-controller): Add linear backoff to polling with 10s base (#10764)

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants