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 first-class support for dataType (PrimarySrp, ImportedSrp, ImportedPrivateKey) and migrates legacy secrets to the new format.

  • Controller: addNewSecretData now requires dataType: EncAccountDataType (BREAKING); SecretType is derived internally. New runMigrations and setMigrationVersion; persists migrationVersion and handles legacy items via updateSecretDataItem/batchUpdateSecretDataItems.
  • SecretMetadata: Adds storage-level fields (itemId, dataType, createdAt, storageVersion); new compare, compareByTimestamp, and matchesType; fromRawMetadata now requires storage metadata; removes parseSecretsFromMetadataStore, fromBatch, and sort (BREAKING).
  • Sorting/validation: Fixes TIMEUUID ordering via timestamp extraction; fetchAllSecretData returns storage metadata, sorts with PrimarySrp first, and validates primary SRP type.
  • Utils/exports: Adds getTimestampFromTimeuuid, compareTimeuuid, getSecretTypeFromDataType; re-exports EncAccountDataType.
  • Minor: bump @metamask/utils to ^11.9.0.

Written by Cursor Bugbot for commit b78c9af. 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.

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.

3 participants