Skip to content

feat(kyc-controller): expose ensureLocalUserSecret for reducing startSession execution time by precreating the localUserSecret - #11099

Merged
jiexi merged 7 commits into
mainfrom
jl/KYC-68/kyc-controller-early-localUserSecret-generation
Oct 29, 2026
Merged

jiexi merged 7 commits into
mainfrom
jl/KYC-68/kyc-controller-early-localUserSecret-generation

Conversation

@jiexi

@jiexi jiexi commented Oct 26, 2026 •

Copy link
Copy Markdown
Member

Currently 17% startSession() execution time is from the localUserSecret creation process. This PR exposes a new ensureLocalUserSecret method which can be called (and not necessarily awaited) earlier in onboarding flow before calling startSession to create a new session.

Fixes: https://consensyssoftware.atlassian.net/browse/KYC-68


Note

Medium Risk
Touches UKYC cryptographic material and Encrypted User Storage writes, but reuses existing secret creation logic without changing startSession fallback behavior.

Overview
Adds KycController.ensureLocalUserSecret and the KycController:ensureLocalUserSecret messenger action so onboarding can create and persist the UKYC local_user_secret in Encrypted User Storage before startSession, moving entropy generation and the storage write off the session-creation path (intended to cut startSession latency).

The method is idempotent (no-op when a valid secret already exists), does not return the secret, and leaves controller state unchanged. startSession still uses the same getOrCreateLocalUserSecret path if this was never called or failed. Docs on startSession now recommend calling ensureLocalUserSecret after the user commits to onboard.

Exports KycControllerEnsureLocalUserSecretAction, updates the changelog, and adds unit tests (create/store, reuse, concurrent calls, startSession read-only follow-up, storage errors, messenger wiring).

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

@jiexi
jiexi requested review from a team as code owners October 26, 2026 22:44
@jiexi
jiexi temporarily deployed to default-branch October 26, 2026 22:44 — with GitHub Actions Inactive
@jiexi jiexi changed the title add a new ensureLocalUserSecret feat(kyc-controller): expose ensureLocalUserSecret for reducing startSession execution time by precreating the localUserSecret Oct 26, 2026
jiexi and others added 3 commits October 26, 2026 15:50
Co-authored-by: Cursor <cursoragent@cursor.com>
The prepare job calls the compare API, which is currently rate limited, so
lint and test never start. Compute the merge base with git in that case, and
read the pull request head ref from the event for changelog diff checks.

Co-authored-by: Cursor <cursoragent@cursor.com>
Akaryatrh
Akaryatrh previously approved these changes Oct 27, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why are these file changed needed?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

they shouldn't be. I have no idea why Cursor did this. I'll revert

ci: fall back when GitHub API rate limits block merge-base lookup

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

jiexi and others added 2 commits October 27, 2026 17:39
…ler-early-localUserSecret-generation

Co-authored-by: Cursor <cursoragent@cursor.com>

# Conflicts:
#	packages/kyc-controller/CHANGELOG.md
#	packages/kyc-controller/src/KycController.test.ts
…et-generation

Co-authored-by: Cursor <cursoragent@cursor.com>

@Akaryatrh Akaryatrh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@jiexi
jiexi added this pull request to the merge queue Oct 29, 2026
Merged via the queue into main with commit 7805660 Oct 29, 2026
46 checks passed
@jiexi
jiexi deleted the jl/KYC-68/kyc-controller-early-localUserSecret-generation branch October 29, 2026 18:35
This was referenced Oct 29, 2026
@Akaryatrh Akaryatrh mentioned this pull request Nov 2, 2026
1 of 4 tasks
Naz-Ovh pushed a commit to 0x-fork/metamask-core that referenced this pull request Nov 4, 2026
## Explanation

Scoped release so clients can pick up MetaMask#11158 and MetaMask#11099. Monorepo
release **1378.0.0** because
[Release/1377.0.0](MetaMask#11203) is
already open.

- **`@metamask/kyc-controller` 0.13.0 → 0.14.0** (minor). Both changes
are additive, so they stay in one minor.
- `KycService.getDataShares` and `KycController.getDataShares` list the
vendors a customer's verified identity data has been shared with
(MetaMask#11158). Both are messenger actions. No new controller state, and no
change to existing methods.
- `KycController.ensureLocalUserSecret` creates and stores the UKYC
`local_user_secret` when one does not already exist (MetaMask#11099).
`startSession` still creates the secret when this method has not been
called. The secret is not returned.

No workspace package depends on `kyc-controller`, so nothing else is
published. Other packages with unreleased changes are deferred.

## References

- Ships MetaMask#11158
- Ships MetaMask#11099
- Unblocks MetaMask/metamask-mobile#38381

## Checklist

- [x] I've updated the test suite for new or updated code as appropriate
- [x] I've updated documentation (JSDoc, Markdown, etc.) for new or
updated code as appropriate
- [x] I've communicated my changes to consumers by [updating changelogs
for packages I've
changed](https://github.com/MetaMask/core/tree/main/docs/processes/updating-changelogs.md)
- [ ] I've introduced [breaking
changes](https://github.com/MetaMask/core/tree/main/docs/processes/breaking-changes.md)
in this PR and have prepared draft pull requests for clients and
consumer packages to resolve them

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Low Risk**
> The diff is version and changelog metadata only; functional changes
were merged in earlier PRs and are not modified here.
> 
> **Overview**
> This is a **scoped release PR** that bumps the monorepo to
**1378.0.0** and publishes **`@metamask/kyc-controller` 0.13.0 →
0.14.0**, with the package changelog cut from `[Unreleased]` into
**`[0.14.0]`** (compare links updated accordingly). No application
source files change in this diff—only `package.json` versions and
`CHANGELOG.md`.
> 
> The **0.14.0** notes document additive KYC work clients can pick up
after publish, including **`getDataShares`** on the service and
controller (messenger actions, no new persisted state),
**`ensureLocalUserSecret`** to create/store the UKYC `local_user_secret`
before session start when desired, optional **`currentStep`** on session
status (plus related **`finalStatus`** mapping when step is `kyc`), and
the associated exports/types called out in the changelog.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
b880f85. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: jiexi <jiexiluan@gmail.com>
Naz-Ovh pushed a commit to 0x-fork/metamask-core that referenced this pull request Nov 4, 2026
## Explanation

Reverts MetaMask#11205 (`Release 1378.0.0`), which was merged before its
predecessor
[Release/1377.0.0](MetaMask#11203) had been
released. The release numbering assumed 1377 would land first, so this
release has to come off `main`.

The revert restores:

- Root version `1378.0.0` → `1376.0.0`
- `@metamask/kyc-controller` `0.14.0` → `0.13.0`
- The `ensureLocalUserSecret` (MetaMask#11099), `getDataShares` (MetaMask#11158) and
`currentStep` (MetaMask#11094) entries move back under `[Unreleased]`

Nothing was published. The `main` run for the merge failed on an
unrelated `rate-limit-controller` test, so the `Publish release` job was
skipped. No tags were created, and npm still lists
`@metamask/kyc-controller` at `0.13.0`.

## References

- Reverts MetaMask#11205

## Checklist

- [x] I've updated the test suite for new or updated code as appropriate
- [x] I've updated documentation (JSDoc, Markdown, etc.) for new or
updated code as appropriate
- [x] I've communicated my changes to consumers by [updating changelogs
for packages I've
changed](https://github.com/MetaMask/core/tree/main/docs/processes/updating-changelogs.md)
- [ ] I've introduced [breaking
changes](https://github.com/MetaMask/core/tree/main/docs/processes/breaking-changes.md)
in this PR and have prepared draft pull requests for clients and
consumer packages to resolve them

Made with [Cursor](https://cursor.com)

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Low Risk**
> Version and changelog-only revert with no code changes; aligns `main`
with unpublished release state.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
9311ab8. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
Naz-Ovh pushed a commit to 0x-fork/metamask-core that referenced this pull request Nov 4, 2026
## Explanation

Release **1380.0.0**. This PR bumps `@metamask/kyc-controller` from
`0.13.0` to `0.14.0` (minor). The unreleased changelog adds public API:
optional `currentStep` on `KycSessionStatus`,
`KycController.ensureLocalUserSecret`, and `getDataShares` on both the
service and the controller, plus their exported types. It also maps a
session that reports `finalStatus: pending` with `currentStep: kyc` back
to `finalStatus: new`, which restores the previous meaning of `pending`
(only after SumSub is fully submitted). That behavior change is not
marked breaking. The root monorepo version is bumped to `1380.0.0`.

No other package in this repo depends on `@metamask/kyc-controller`, so
no other packages are included. Dev-only commits since `0.13.0` (the
`nock` bump and a test import change) are left out of the changelog.

## References

- Ships [MetaMask#11094](MetaMask#11094),
[MetaMask#11099](MetaMask#11099), and
[MetaMask#11158](MetaMask#11158)
- Previous merged release:
[MetaMask#11210](MetaMask#11210)

## Checklist

- [ ] I've updated the test suite for new or updated code as appropriate
(N/A: version bump and changelog only)
- [ ] I've updated documentation (JSDoc, Markdown, etc.) for new or
updated code as appropriate (N/A)
- [x] I've communicated my changes to consumers by [updating changelogs
for packages I've
changed](https://github.com/MetaMask/core/tree/main/docs/processes/updating-changelogs.md)
- [ ] I've introduced [breaking
changes](https://github.com/MetaMask/core/tree/main/docs/processes/breaking-changes.md)
in this PR and have prepared draft pull requests for clients and
consumer packages to resolve them (N/A: no breaking changes)

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Low Risk**
> Version and changelog-only release with no new runtime changes in this
PR; consumer impact comes from the already-merged kyc-controller APIs
and status mapping described in the changelog.
> 
> **Overview**
> This PR cuts **release 1380.0.0** for the core monorepo by bumping the
root version from `1379.0.0` to **1380.0.0**
> 
> It publishes **`@metamask/kyc-controller` `0.14.0`**, moving the
existing Unreleased changelog into a **`[0.14.0]`** section and updating
compare links. There is **no application code in the diff**—only version
and changelog housekeeping.
> 
> The **0.14.0** notes document what consumers get from earlier merged
work: optional **`currentStep`** on **`KycSessionStatus`**,
**`ensureLocalUserSecret`**, **`getDataShares`** on the service and
controller, related exports, and a **behavior tweak** that maps API
**`pending` + `currentStep: kyc`** back to **`finalStatus: new`** so
partially submitted flows are not treated like post–SumSub pending.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
1727a26. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

Signed-off-by: Sébastien Van Eyck <sebastien.vaneyck@consensys.net>
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.

2 participants