Skip to content

Conversation

@huggingbot
Copy link
Member

@huggingbot huggingbot commented Dec 2, 2025

Explanation

The metadata service now supports a dataType column for categorizing secret data (PrimarySrp, ImportedSrp, ImportedPrivateKey). This enables clients to distinguish between different types of backed-up secrets

Changes include:

  • Add dataType parameter to insert operations
  • Add updateSecretDataItem and batchUpdateSecretDataItems for updating existing items
  • Update fetchAllSecretData to return storage metadata (itemId, dataType) alongside secret data
  • Refactor SecretMetadata to separate local metadata from storage-level metadata

References

https://consensyssoftware.atlassian.net/browse/SL-350

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

Adds dataType and storage metadata support with migrations. Introduces breaking API changes.

  • Implement EncAccountDataType end-to-end: addNewSecretData now requires dataType; payload still writes type for backward compatibility
  • New storage metadata on SecretMetadata: itemId, dataType, createdAt (TIMEUUID), storageVersion; plus compare, compareByTimestamp, and matchesType
  • Update fetch path to return/storage-align items, prioritize PrimarySrp, and sort via TIMEUUID timestamps; validate first item is primary SRP
  • Add runMigrations (with internal dataType migration) and setMigrationVersion; persist migrationVersion and SeedlessOnboardingMigrationVersion enum
  • Replace removed APIs: drop parseSecretsFromMetadataStore, fromBatch, sort, and version getter; fromRawMetadata now requires storageMetadata
  • Add TIMEUUID utilities and mapping from EncAccountDataType to SecretType; re-export EncAccountDataType
  • Bump @metamask/toprf-secure-backup to ^1.0.0

Written by Cursor Bugbot for commit 7184599. This will update automatically on new commits. Configure here.

- Add dataType parameter to createToprfKeyAndBackupSeedPhrase and addNewSecretData
- Add updateSecretDataItem and batchUpdateSecretDataItems methods
- Update fetchAllSecretData to return SecretDataItemWithMetadata[]
…etadata

- Add itemId, dataType, createdAt properties to SecretMetadata class
- Remove SecretDataItemWithMetadata wrapper type
- Update fetchAllSecretData to return SecretMetadata[] directly
- Add tests for storage metadata properties
…EUUID sorting

TIMEUUID strings are not lexicographically sortable. Replace localeCompare
with compareTimeuuid utility that extracts and compares actual timestamps.
@huggingbot huggingbot marked this pull request as ready for review January 5, 2026 09:53
@huggingbot huggingbot requested review from a team as code owners January 5, 2026 09:53
@huggingbot
Copy link
Member Author

huggingbot commented Jan 6, 2026

May I know are there any major difference between #storageVersion and #version?
If not we can remove either one of them.

removed version entirely and kept storageVersion here. This should work for old clients too because we're not using version in our logic at all

@huggingbot
Copy link
Member Author

do we need to also update SocialBackupsMetadata?

@huggingbot
Copy link
Member Author

Should we move this logic to SecretMetadata class? wdyt?

fixed here

lwin-kyaw
lwin-kyaw previously approved these changes Jan 6, 2026
@lwin-kyaw lwin-kyaw dismissed their stale review January 6, 2026 12:59

Misclicked.

@socket-security
Copy link

socket-security bot commented Jan 15, 2026

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updated@​metamask/​toprf-secure-backup@​0.11.0 ⏵ 1.0.09910088 +195 -1100

View full report

fix: handle edge case in SecretMetadata.compare when both items are PrimarySrp

fix: add tests for data corruption scenarios and inconsistent storageVersion
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants