feat(kyc-controller): restore existing session for vendor - #10289
Conversation
…atus-polling' into jl/kyc-controller-recover-existing-session-for-vendor
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ 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 be070de. Configure here.
| state.statusMessage = 'KYC already completed.'; | ||
| }); | ||
| return; | ||
| } |
There was a problem hiding this comment.
Session reuse ignores vendor boundary
High Severity
When a sessionId is already on state, initialize skips the vendor-specific latest-session lookup and can finish at done from a persisted approved sessionStatus for a different vendor. sessionId is not vendor-scoped and activeVendor is not persisted. #createUkycSession also reuses that sessionId when the requested vendor has no session, so a MoonPay session can be attached to an Iron flow.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit be070de. Configure here.


Explanation
References
Checklist
Note
High Risk
Multiple breaking changes to KYC state shape, persistence, status semantics, and SumSub launch rules affect identity flows and downstream consumers that read
sessionStatusorKycSumSubStatus.Overview
Adds
KycService.getLatestSessionStatusForVendor(GET /sessions/latest/status/{vendor}), returning the same status payload asgetSessionStatusornullon HTTP 404.KycControlleruses that lookup duringinitialize(when state has nosessionId) and before creating a UKYC session instartSumSub/ the consents path, so at most one session per vendor is reused instead of creating another. An existing session’s status is stored for anyfinalStatus; when it is alreadyapproved, the flow finishes atdoneand SumSub is not launched.Breaking behavior changes: session outcomes are driven by
sessionStatus.finalStatusonly (new|pending|approved|rejected|retry);kycStatusis stored but ignored.sessionStatusis now persisted and cleared together withsessionIdviaclearUkycSession.vendorProcessingis removed fromKycSumSubStatus—a relay-approved / vendor-pending combo no longer blocks the SDK.completedis no longer treated as success (onlyapproved).API validation tightens
finalStatusto an enum and adds optionalidon status responses for resume. Docs, changelog, exports, and tests cover hydration, reset races, and reuse paths.Reviewed by Cursor Bugbot for commit be070de. Bugbot is set up for automated code reviews on this repo. Configure here.