@metamask-previews/account-tree-controller 8.0.0-preview-4f4c98e → 8.0.0-preview-eb263b0ee
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +0 -1
- package/dist/AccountTreeController-method-action-types.cjs +7 -0
- package/dist/AccountTreeController-method-action-types.cjs.map +1 -0
- package/dist/{AccountTreeController-method-action-types.d.ts → AccountTreeController-method-action-types.d.cts} +2 -2
- package/dist/AccountTreeController-method-action-types.d.cts.map +1 -0
- package/dist/AccountTreeController-method-action-types.d.mts +256 -0
- package/dist/AccountTreeController-method-action-types.d.mts.map +1 -0
- package/dist/{AccountTreeController-method-action-types.js → AccountTreeController-method-action-types.mjs} +1 -1
- package/dist/AccountTreeController-method-action-types.mjs.map +1 -0
- package/dist/AccountTreeController.cjs +1247 -0
- package/dist/AccountTreeController.cjs.map +1 -0
- package/dist/{AccountTreeController.d.ts → AccountTreeController.d.cts} +17 -17
- package/dist/AccountTreeController.d.cts.map +1 -0
- package/dist/AccountTreeController.d.mts +269 -0
- package/dist/AccountTreeController.d.mts.map +1 -0
- package/dist/{AccountTreeController.js → AccountTreeController.mjs} +15 -15
- package/dist/AccountTreeController.mjs.map +1 -0
- package/dist/backup-and-sync/analytics/index.cjs +19 -0
- package/dist/backup-and-sync/analytics/index.cjs.map +1 -0
- package/dist/backup-and-sync/analytics/index.d.cts +3 -0
- package/dist/backup-and-sync/analytics/index.d.cts.map +1 -0
- package/dist/backup-and-sync/analytics/index.d.mts +3 -0
- package/dist/backup-and-sync/analytics/index.d.mts.map +1 -0
- package/dist/backup-and-sync/analytics/index.mjs +3 -0
- package/dist/backup-and-sync/analytics/index.mjs.map +1 -0
- package/dist/backup-and-sync/analytics/segment.cjs +38 -0
- package/dist/backup-and-sync/analytics/segment.cjs.map +1 -0
- package/dist/backup-and-sync/analytics/{segment.d.ts → segment.d.cts} +10 -10
- package/dist/backup-and-sync/analytics/segment.d.cts.map +1 -0
- package/dist/backup-and-sync/analytics/segment.d.mts +37 -0
- package/dist/backup-and-sync/analytics/segment.d.mts.map +1 -0
- package/dist/backup-and-sync/analytics/{segment.js → segment.mjs} +1 -1
- package/dist/backup-and-sync/analytics/segment.mjs.map +1 -0
- package/dist/backup-and-sync/analytics/traces.cjs +24 -0
- package/dist/backup-and-sync/analytics/traces.cjs.map +1 -0
- package/dist/backup-and-sync/analytics/{traces.d.ts → traces.d.cts} +3 -3
- package/dist/backup-and-sync/analytics/traces.d.cts.map +1 -0
- package/dist/backup-and-sync/analytics/traces.d.mts +16 -0
- package/dist/backup-and-sync/analytics/traces.d.mts.map +1 -0
- package/dist/backup-and-sync/analytics/{traces.js → traces.mjs} +1 -1
- package/dist/backup-and-sync/analytics/traces.mjs.map +1 -0
- package/dist/backup-and-sync/authentication/index.cjs +18 -0
- package/dist/backup-and-sync/authentication/index.cjs.map +1 -0
- package/dist/backup-and-sync/authentication/index.d.cts +2 -0
- package/dist/backup-and-sync/authentication/index.d.cts.map +1 -0
- package/dist/backup-and-sync/authentication/index.d.mts +2 -0
- package/dist/backup-and-sync/authentication/index.d.mts.map +1 -0
- package/dist/backup-and-sync/authentication/index.mjs +2 -0
- package/dist/backup-and-sync/authentication/index.mjs.map +1 -0
- package/dist/backup-and-sync/authentication/utils.cjs +23 -0
- package/dist/backup-and-sync/authentication/utils.cjs.map +1 -0
- package/dist/backup-and-sync/authentication/{utils.d.ts → utils.d.cts} +3 -3
- package/dist/backup-and-sync/authentication/utils.d.cts.map +1 -0
- package/dist/backup-and-sync/authentication/utils.d.mts +12 -0
- package/dist/backup-and-sync/authentication/utils.d.mts.map +1 -0
- package/dist/backup-and-sync/authentication/{utils.js → utils.mjs} +2 -2
- package/dist/backup-and-sync/authentication/utils.mjs.map +1 -0
- package/dist/backup-and-sync/service/atomic-sync-queue.cjs +123 -0
- package/dist/backup-and-sync/service/atomic-sync-queue.cjs.map +1 -0
- package/dist/backup-and-sync/service/{atomic-sync-queue.d.ts → atomic-sync-queue.d.cts} +1 -1
- package/dist/backup-and-sync/service/atomic-sync-queue.d.cts.map +1 -0
- package/dist/backup-and-sync/service/atomic-sync-queue.d.mts +43 -0
- package/dist/backup-and-sync/service/atomic-sync-queue.d.mts.map +1 -0
- package/dist/backup-and-sync/service/{atomic-sync-queue.js → atomic-sync-queue.mjs} +3 -3
- package/dist/backup-and-sync/service/atomic-sync-queue.mjs.map +1 -0
- package/dist/backup-and-sync/service/index.cjs +403 -0
- package/dist/backup-and-sync/service/index.cjs.map +1 -0
- package/dist/backup-and-sync/service/{index.d.ts → index.d.cts} +4 -4
- package/dist/backup-and-sync/service/index.d.cts.map +1 -0
- package/dist/backup-and-sync/service/index.d.mts +84 -0
- package/dist/backup-and-sync/service/index.d.mts.map +1 -0
- package/dist/backup-and-sync/service/{index.js → index.mjs} +9 -9
- package/dist/backup-and-sync/service/index.mjs.map +1 -0
- package/dist/backup-and-sync/syncing/group.cjs +190 -0
- package/dist/backup-and-sync/syncing/group.cjs.map +1 -0
- package/dist/backup-and-sync/syncing/{group.d.ts → group.d.cts} +6 -6
- package/dist/backup-and-sync/syncing/group.d.cts.map +1 -0
- package/dist/backup-and-sync/syncing/group.d.mts +48 -0
- package/dist/backup-and-sync/syncing/group.d.mts.map +1 -0
- package/dist/backup-and-sync/syncing/{group.js → group.mjs} +9 -9
- package/dist/backup-and-sync/syncing/group.mjs.map +1 -0
- package/dist/backup-and-sync/syncing/index.cjs +21 -0
- package/dist/backup-and-sync/syncing/index.cjs.map +1 -0
- package/dist/backup-and-sync/syncing/index.d.cts +5 -0
- package/dist/backup-and-sync/syncing/index.d.cts.map +1 -0
- package/dist/backup-and-sync/syncing/index.d.mts +5 -0
- package/dist/backup-and-sync/syncing/index.d.mts.map +1 -0
- package/dist/backup-and-sync/syncing/index.mjs +5 -0
- package/dist/backup-and-sync/syncing/index.mjs.map +1 -0
- package/dist/backup-and-sync/syncing/legacy.cjs +74 -0
- package/dist/backup-and-sync/syncing/legacy.cjs.map +1 -0
- package/dist/backup-and-sync/syncing/{legacy.d.ts → legacy.d.cts} +3 -3
- package/dist/backup-and-sync/syncing/legacy.d.cts.map +1 -0
- package/dist/backup-and-sync/syncing/legacy.d.mts +15 -0
- package/dist/backup-and-sync/syncing/legacy.d.mts.map +1 -0
- package/dist/backup-and-sync/syncing/{legacy.js → legacy.mjs} +8 -8
- package/dist/backup-and-sync/syncing/legacy.mjs.map +1 -0
- package/dist/backup-and-sync/syncing/metadata.cjs +56 -0
- package/dist/backup-and-sync/syncing/metadata.cjs.map +1 -0
- package/dist/backup-and-sync/syncing/{metadata.d.ts → metadata.d.cts} +4 -4
- package/dist/backup-and-sync/syncing/metadata.d.cts.map +1 -0
- package/dist/backup-and-sync/syncing/metadata.d.mts +39 -0
- package/dist/backup-and-sync/syncing/metadata.d.mts.map +1 -0
- package/dist/backup-and-sync/syncing/{metadata.js → metadata.mjs} +9 -2
- package/dist/backup-and-sync/syncing/metadata.mjs.map +1 -0
- package/dist/backup-and-sync/syncing/wallet.cjs +64 -0
- package/dist/backup-and-sync/syncing/wallet.cjs.map +1 -0
- package/dist/backup-and-sync/syncing/{wallet.d.ts → wallet.d.cts} +4 -4
- package/dist/backup-and-sync/syncing/wallet.d.cts.map +1 -0
- package/dist/backup-and-sync/syncing/wallet.d.mts +23 -0
- package/dist/backup-and-sync/syncing/wallet.d.mts.map +1 -0
- package/dist/backup-and-sync/syncing/{wallet.js → wallet.mjs} +6 -6
- package/dist/backup-and-sync/syncing/wallet.mjs.map +1 -0
- package/dist/backup-and-sync/types.cjs +41 -0
- package/dist/backup-and-sync/types.cjs.map +1 -0
- package/dist/backup-and-sync/{types.d.ts → types.d.cts} +12 -12
- package/dist/backup-and-sync/types.d.cts.map +1 -0
- package/dist/backup-and-sync/types.d.mts +131 -0
- package/dist/backup-and-sync/types.d.mts.map +1 -0
- package/dist/backup-and-sync/{types.js → types.mjs} +2 -2
- package/dist/backup-and-sync/types.mjs.map +1 -0
- package/dist/backup-and-sync/user-storage/constants.cjs +8 -0
- package/dist/backup-and-sync/user-storage/constants.cjs.map +1 -0
- package/dist/backup-and-sync/user-storage/{constants.d.ts → constants.d.cts} +1 -1
- package/dist/backup-and-sync/user-storage/constants.d.cts.map +1 -0
- package/dist/backup-and-sync/user-storage/constants.d.mts +5 -0
- package/dist/backup-and-sync/user-storage/constants.d.mts.map +1 -0
- package/dist/backup-and-sync/user-storage/{constants.js → constants.mjs} +1 -1
- package/dist/backup-and-sync/user-storage/constants.mjs.map +1 -0
- package/dist/backup-and-sync/user-storage/format-utils.cjs +115 -0
- package/dist/backup-and-sync/user-storage/format-utils.cjs.map +1 -0
- package/dist/backup-and-sync/user-storage/{format-utils.d.ts → format-utils.d.cts} +4 -4
- package/dist/backup-and-sync/user-storage/format-utils.d.cts.map +1 -0
- package/dist/backup-and-sync/user-storage/format-utils.d.mts +54 -0
- package/dist/backup-and-sync/user-storage/format-utils.d.mts.map +1 -0
- package/dist/backup-and-sync/user-storage/{format-utils.js → format-utils.mjs} +6 -6
- package/dist/backup-and-sync/user-storage/format-utils.mjs.map +1 -0
- package/dist/backup-and-sync/user-storage/index.cjs +21 -0
- package/dist/backup-and-sync/user-storage/index.cjs.map +1 -0
- package/dist/backup-and-sync/user-storage/index.d.cts +5 -0
- package/dist/backup-and-sync/user-storage/index.d.cts.map +1 -0
- package/dist/backup-and-sync/user-storage/index.d.mts +5 -0
- package/dist/backup-and-sync/user-storage/index.d.mts.map +1 -0
- package/dist/backup-and-sync/user-storage/index.mjs +5 -0
- package/dist/backup-and-sync/user-storage/index.mjs.map +1 -0
- package/dist/backup-and-sync/user-storage/network-operations.cjs +193 -0
- package/dist/backup-and-sync/user-storage/network-operations.cjs.map +1 -0
- package/dist/backup-and-sync/user-storage/{network-operations.d.ts → network-operations.d.cts} +4 -4
- package/dist/backup-and-sync/user-storage/network-operations.d.cts.map +1 -0
- package/dist/backup-and-sync/user-storage/network-operations.d.mts +80 -0
- package/dist/backup-and-sync/user-storage/network-operations.d.mts.map +1 -0
- package/dist/backup-and-sync/user-storage/{network-operations.js → network-operations.mjs} +7 -7
- package/dist/backup-and-sync/user-storage/network-operations.mjs.map +1 -0
- package/dist/backup-and-sync/user-storage/network-utils.cjs +33 -0
- package/dist/backup-and-sync/user-storage/network-utils.cjs.map +1 -0
- package/dist/backup-and-sync/user-storage/{network-utils.d.ts → network-utils.d.cts} +1 -1
- package/dist/backup-and-sync/user-storage/network-utils.d.cts.map +1 -0
- package/dist/backup-and-sync/user-storage/network-utils.d.mts +10 -0
- package/dist/backup-and-sync/user-storage/network-utils.d.mts.map +1 -0
- package/dist/backup-and-sync/user-storage/{network-utils.js → network-utils.mjs} +1 -1
- package/dist/backup-and-sync/user-storage/network-utils.mjs.map +1 -0
- package/dist/backup-and-sync/user-storage/validation.cjs +76 -0
- package/dist/backup-and-sync/user-storage/validation.cjs.map +1 -0
- package/dist/backup-and-sync/user-storage/{validation.d.ts → validation.d.cts} +2 -2
- package/dist/backup-and-sync/user-storage/validation.d.cts.map +1 -0
- package/dist/backup-and-sync/user-storage/validation.d.mts +23 -0
- package/dist/backup-and-sync/user-storage/validation.d.mts.map +1 -0
- package/dist/backup-and-sync/user-storage/{validation.js → validation.mjs} +3 -3
- package/dist/backup-and-sync/user-storage/validation.mjs.map +1 -0
- package/dist/backup-and-sync/utils/controller.cjs +88 -0
- package/dist/backup-and-sync/utils/controller.cjs.map +1 -0
- package/dist/backup-and-sync/utils/{controller.d.ts → controller.d.cts} +6 -6
- package/dist/backup-and-sync/utils/controller.d.cts.map +1 -0
- package/dist/backup-and-sync/utils/controller.d.mts +57 -0
- package/dist/backup-and-sync/utils/controller.d.mts.map +1 -0
- package/dist/backup-and-sync/utils/{controller.js → controller.mjs} +3 -3
- package/dist/backup-and-sync/utils/controller.mjs.map +1 -0
- package/dist/backup-and-sync/utils/errors.cjs +14 -0
- package/dist/backup-and-sync/utils/errors.cjs.map +1 -0
- package/dist/backup-and-sync/utils/{errors.d.ts → errors.d.cts} +1 -1
- package/dist/backup-and-sync/utils/errors.d.cts.map +1 -0
- package/dist/backup-and-sync/utils/errors.d.mts +8 -0
- package/dist/backup-and-sync/utils/errors.d.mts.map +1 -0
- package/dist/backup-and-sync/utils/{errors.js → errors.mjs} +1 -1
- package/dist/backup-and-sync/utils/errors.mjs.map +1 -0
- package/dist/backup-and-sync/utils/index.cjs +23 -0
- package/dist/backup-and-sync/utils/index.cjs.map +1 -0
- package/dist/backup-and-sync/utils/index.d.cts +4 -0
- package/dist/backup-and-sync/utils/index.d.cts.map +1 -0
- package/dist/backup-and-sync/utils/index.d.mts +4 -0
- package/dist/backup-and-sync/utils/index.d.mts.map +1 -0
- package/dist/backup-and-sync/utils/index.mjs +4 -0
- package/dist/backup-and-sync/utils/index.mjs.map +1 -0
- package/dist/backup-and-sync/utils/mutation-tracker.cjs +29 -0
- package/dist/backup-and-sync/utils/mutation-tracker.cjs.map +1 -0
- package/dist/backup-and-sync/utils/{mutation-tracker.d.ts → mutation-tracker.d.cts} +2 -2
- package/dist/backup-and-sync/utils/mutation-tracker.d.cts.map +1 -0
- package/dist/backup-and-sync/utils/mutation-tracker.d.mts +9 -0
- package/dist/backup-and-sync/utils/mutation-tracker.d.mts.map +1 -0
- package/dist/backup-and-sync/utils/{mutation-tracker.js → mutation-tracker.mjs} +1 -1
- package/dist/backup-and-sync/utils/mutation-tracker.mjs.map +1 -0
- package/dist/group.cjs +60 -0
- package/dist/group.cjs.map +1 -0
- package/dist/{group.d.ts → group.d.cts} +8 -8
- package/dist/group.d.cts.map +1 -0
- package/dist/group.d.mts +97 -0
- package/dist/group.d.mts.map +1 -0
- package/dist/{group.js → group.mjs} +2 -2
- package/dist/group.mjs.map +1 -0
- package/dist/index.cjs +21 -0
- package/dist/index.cjs.map +1 -0
- package/dist/{index.d.ts → index.d.cts} +13 -13
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +13 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +7 -0
- package/dist/index.mjs.map +1 -0
- package/dist/logger.cjs +7 -0
- package/dist/logger.cjs.map +1 -0
- package/dist/{logger.d.ts → logger.d.cts} +2 -1
- package/dist/logger.d.cts.map +1 -0
- package/dist/logger.d.mts +4 -0
- package/dist/logger.d.mts.map +1 -0
- package/dist/{logger.js → logger.mjs} +2 -2
- package/dist/logger.mjs.map +1 -0
- package/dist/rule.cjs +32 -0
- package/dist/rule.cjs.map +1 -0
- package/dist/{rule.d.ts → rule.d.cts} +7 -7
- package/dist/rule.d.cts.map +1 -0
- package/dist/rule.d.mts +83 -0
- package/dist/rule.d.mts.map +1 -0
- package/dist/{rule.js → rule.mjs} +1 -1
- package/dist/rule.mjs.map +1 -0
- package/dist/rules/entropy.cjs +78 -0
- package/dist/rules/entropy.cjs.map +1 -0
- package/dist/rules/{entropy.d.ts → entropy.d.cts} +7 -7
- package/dist/rules/entropy.d.cts.map +1 -0
- package/dist/rules/entropy.d.mts +16 -0
- package/dist/rules/entropy.d.mts.map +1 -0
- package/dist/rules/{entropy.js → entropy.mjs} +5 -5
- package/dist/rules/entropy.mjs.map +1 -0
- package/dist/rules/keyring.cjs +151 -0
- package/dist/rules/keyring.cjs.map +1 -0
- package/dist/rules/{keyring.d.ts → keyring.d.cts} +10 -10
- package/dist/rules/keyring.d.cts.map +1 -0
- package/dist/rules/keyring.d.mts +32 -0
- package/dist/rules/keyring.d.mts.map +1 -0
- package/dist/rules/{keyring.js → keyring.mjs} +7 -7
- package/dist/rules/keyring.mjs.map +1 -0
- package/dist/rules/snap.cjs +80 -0
- package/dist/rules/snap.cjs.map +1 -0
- package/dist/rules/{snap.d.ts → snap.d.cts} +6 -6
- package/dist/rules/snap.d.cts.map +1 -0
- package/dist/rules/snap.d.mts +14 -0
- package/dist/rules/snap.d.mts.map +1 -0
- package/dist/rules/{snap.js → snap.mjs} +8 -8
- package/dist/rules/snap.mjs.map +1 -0
- package/dist/state/export.cjs +230 -0
- package/dist/state/export.cjs.map +1 -0
- package/dist/state/{export.d.ts → export.d.cts} +6 -6
- package/dist/state/export.d.cts.map +1 -0
- package/dist/state/export.d.mts +40 -0
- package/dist/state/export.d.mts.map +1 -0
- package/dist/state/{export.js → export.mjs} +9 -8
- package/dist/state/export.mjs.map +1 -0
- package/dist/state/id-map.cjs +65 -0
- package/dist/state/id-map.cjs.map +1 -0
- package/dist/state/{id-map.d.ts → id-map.d.cts} +3 -3
- package/dist/state/id-map.d.cts.map +1 -0
- package/dist/state/id-map.d.mts +41 -0
- package/dist/state/id-map.d.mts.map +1 -0
- package/dist/state/{id-map.js → id-map.mjs} +2 -2
- package/dist/state/id-map.mjs.map +1 -0
- package/dist/state/import.cjs +285 -0
- package/dist/state/import.cjs.map +1 -0
- package/dist/state/{import.d.ts → import.d.cts} +4 -4
- package/dist/state/import.d.cts.map +1 -0
- package/dist/state/import.d.mts +29 -0
- package/dist/state/import.d.mts.map +1 -0
- package/dist/state/{import.js → import.mjs} +9 -8
- package/dist/state/import.mjs.map +1 -0
- package/dist/state/payload.cjs +169 -0
- package/dist/state/payload.cjs.map +1 -0
- package/dist/state/{payload.d.ts → payload.d.cts} +31 -31
- package/dist/state/payload.d.cts.map +1 -0
- package/dist/state/payload.d.mts +294 -0
- package/dist/state/payload.d.mts.map +1 -0
- package/dist/state/{payload.js → payload.mjs} +4 -4
- package/dist/state/payload.mjs.map +1 -0
- package/dist/state/snapshot.cjs +202 -0
- package/dist/state/snapshot.cjs.map +1 -0
- package/dist/state/{snapshot.d.ts → snapshot.d.cts} +3 -3
- package/dist/state/snapshot.d.cts.map +1 -0
- package/dist/state/snapshot.d.mts +120 -0
- package/dist/state/snapshot.d.mts.map +1 -0
- package/dist/state/{snapshot.js → snapshot.mjs} +3 -3
- package/dist/state/snapshot.mjs.map +1 -0
- package/dist/state/utils.cjs +68 -0
- package/dist/state/utils.cjs.map +1 -0
- package/dist/state/{utils.d.ts → utils.d.cts} +3 -3
- package/dist/state/utils.d.cts.map +1 -0
- package/dist/state/utils.d.mts +49 -0
- package/dist/state/utils.d.mts.map +1 -0
- package/dist/state/{utils.js → utils.mjs} +2 -2
- package/dist/state/utils.mjs.map +1 -0
- package/dist/type-utils.cjs +3 -0
- package/dist/type-utils.cjs.map +1 -0
- package/dist/{type-utils.d.ts → type-utils.d.cts} +1 -1
- package/dist/type-utils.d.cts.map +1 -0
- package/dist/type-utils.d.mts +18 -0
- package/dist/type-utils.d.mts.map +1 -0
- package/dist/type-utils.mjs +2 -0
- package/dist/type-utils.mjs.map +1 -0
- package/dist/types.cjs +3 -0
- package/dist/types.cjs.map +1 -0
- package/dist/{types.d.ts → types.d.cts} +16 -16
- package/dist/types.d.cts.map +1 -0
- package/dist/types.d.mts +120 -0
- package/dist/types.d.mts.map +1 -0
- package/dist/types.mjs +2 -0
- package/dist/types.mjs.map +1 -0
- package/dist/wallet.cjs +3 -0
- package/dist/wallet.cjs.map +1 -0
- package/dist/{wallet.d.ts → wallet.d.cts} +9 -9
- package/dist/wallet.d.cts.map +1 -0
- package/dist/wallet.d.mts +99 -0
- package/dist/wallet.d.mts.map +1 -0
- package/dist/wallet.mjs +2 -0
- package/dist/wallet.mjs.map +1 -0
- package/package.json +17 -13
- package/dist/AccountTreeController-method-action-types.d.ts.map +0 -1
- package/dist/AccountTreeController-method-action-types.js.map +0 -1
- package/dist/AccountTreeController.d.ts.map +0 -1
- package/dist/AccountTreeController.js.map +0 -1
- package/dist/backup-and-sync/analytics/index.d.ts +0 -3
- package/dist/backup-and-sync/analytics/index.d.ts.map +0 -1
- package/dist/backup-and-sync/analytics/index.js +0 -3
- package/dist/backup-and-sync/analytics/index.js.map +0 -1
- package/dist/backup-and-sync/analytics/segment.d.ts.map +0 -1
- package/dist/backup-and-sync/analytics/segment.js.map +0 -1
- package/dist/backup-and-sync/analytics/traces.d.ts.map +0 -1
- package/dist/backup-and-sync/analytics/traces.js.map +0 -1
- package/dist/backup-and-sync/authentication/index.d.ts +0 -2
- package/dist/backup-and-sync/authentication/index.d.ts.map +0 -1
- package/dist/backup-and-sync/authentication/index.js +0 -2
- package/dist/backup-and-sync/authentication/index.js.map +0 -1
- package/dist/backup-and-sync/authentication/utils.d.ts.map +0 -1
- package/dist/backup-and-sync/authentication/utils.js.map +0 -1
- package/dist/backup-and-sync/service/atomic-sync-queue.d.ts.map +0 -1
- package/dist/backup-and-sync/service/atomic-sync-queue.js.map +0 -1
- package/dist/backup-and-sync/service/index.d.ts.map +0 -1
- package/dist/backup-and-sync/service/index.js.map +0 -1
- package/dist/backup-and-sync/syncing/group.d.ts.map +0 -1
- package/dist/backup-and-sync/syncing/group.js.map +0 -1
- package/dist/backup-and-sync/syncing/index.d.ts +0 -5
- package/dist/backup-and-sync/syncing/index.d.ts.map +0 -1
- package/dist/backup-and-sync/syncing/index.js +0 -5
- package/dist/backup-and-sync/syncing/index.js.map +0 -1
- package/dist/backup-and-sync/syncing/legacy.d.ts.map +0 -1
- package/dist/backup-and-sync/syncing/legacy.js.map +0 -1
- package/dist/backup-and-sync/syncing/metadata.d.ts.map +0 -1
- package/dist/backup-and-sync/syncing/metadata.js.map +0 -1
- package/dist/backup-and-sync/syncing/wallet.d.ts.map +0 -1
- package/dist/backup-and-sync/syncing/wallet.js.map +0 -1
- package/dist/backup-and-sync/types.d.ts.map +0 -1
- package/dist/backup-and-sync/types.js.map +0 -1
- package/dist/backup-and-sync/user-storage/constants.d.ts.map +0 -1
- package/dist/backup-and-sync/user-storage/constants.js.map +0 -1
- package/dist/backup-and-sync/user-storage/format-utils.d.ts.map +0 -1
- package/dist/backup-and-sync/user-storage/format-utils.js.map +0 -1
- package/dist/backup-and-sync/user-storage/index.d.ts +0 -5
- package/dist/backup-and-sync/user-storage/index.d.ts.map +0 -1
- package/dist/backup-and-sync/user-storage/index.js +0 -5
- package/dist/backup-and-sync/user-storage/index.js.map +0 -1
- package/dist/backup-and-sync/user-storage/network-operations.d.ts.map +0 -1
- package/dist/backup-and-sync/user-storage/network-operations.js.map +0 -1
- package/dist/backup-and-sync/user-storage/network-utils.d.ts.map +0 -1
- package/dist/backup-and-sync/user-storage/network-utils.js.map +0 -1
- package/dist/backup-and-sync/user-storage/validation.d.ts.map +0 -1
- package/dist/backup-and-sync/user-storage/validation.js.map +0 -1
- package/dist/backup-and-sync/utils/controller.d.ts.map +0 -1
- package/dist/backup-and-sync/utils/controller.js.map +0 -1
- package/dist/backup-and-sync/utils/errors.d.ts.map +0 -1
- package/dist/backup-and-sync/utils/errors.js.map +0 -1
- package/dist/backup-and-sync/utils/index.d.ts +0 -4
- package/dist/backup-and-sync/utils/index.d.ts.map +0 -1
- package/dist/backup-and-sync/utils/index.js +0 -4
- package/dist/backup-and-sync/utils/index.js.map +0 -1
- package/dist/backup-and-sync/utils/mutation-tracker.d.ts.map +0 -1
- package/dist/backup-and-sync/utils/mutation-tracker.js.map +0 -1
- package/dist/group.d.ts.map +0 -1
- package/dist/group.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -7
- package/dist/index.js.map +0 -1
- package/dist/logger.d.ts.map +0 -1
- package/dist/logger.js.map +0 -1
- package/dist/rule.d.ts.map +0 -1
- package/dist/rule.js.map +0 -1
- package/dist/rules/entropy.d.ts.map +0 -1
- package/dist/rules/entropy.js.map +0 -1
- package/dist/rules/keyring.d.ts.map +0 -1
- package/dist/rules/keyring.js.map +0 -1
- package/dist/rules/snap.d.ts.map +0 -1
- package/dist/rules/snap.js.map +0 -1
- package/dist/state/export.d.ts.map +0 -1
- package/dist/state/export.js.map +0 -1
- package/dist/state/id-map.d.ts.map +0 -1
- package/dist/state/id-map.js.map +0 -1
- package/dist/state/import.d.ts.map +0 -1
- package/dist/state/import.js.map +0 -1
- package/dist/state/payload.d.ts.map +0 -1
- package/dist/state/payload.js.map +0 -1
- package/dist/state/snapshot.d.ts.map +0 -1
- package/dist/state/snapshot.js.map +0 -1
- package/dist/state/utils.d.ts.map +0 -1
- package/dist/state/utils.js.map +0 -1
- package/dist/type-utils.d.ts.map +0 -1
- package/dist/type-utils.js +0 -2
- package/dist/type-utils.js.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -2
- package/dist/types.js.map +0 -1
- package/dist/wallet.d.ts.map +0 -1
- package/dist/wallet.js +0 -2
- package/dist/wallet.js.map +0 -1
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAllLegacyUserStorageAccounts = exports.pushGroupToUserStorageBatch = exports.pushGroupToUserStorage = exports.getGroupFromUserStorage = exports.getAllGroupsFromUserStorage = exports.pushWalletToUserStorage = exports.getWalletFromUserStorage = void 0;
|
|
4
|
+
const profile_sync_controller_1 = require("@metamask/profile-sync-controller");
|
|
5
|
+
const logger_js_1 = require("../../logger.cjs");
|
|
6
|
+
const errors_js_1 = require("../utils/errors.cjs");
|
|
7
|
+
const constants_js_1 = require("./constants.cjs");
|
|
8
|
+
const format_utils_js_1 = require("./format-utils.cjs");
|
|
9
|
+
const network_utils_js_1 = require("./network-utils.cjs");
|
|
10
|
+
/**
|
|
11
|
+
* Retrieves the wallet from user storage.
|
|
12
|
+
*
|
|
13
|
+
* @param context - The backup and sync context.
|
|
14
|
+
* @param entropySourceId - The entropy source ID.
|
|
15
|
+
* @returns The wallet from user storage or null if not found or invalid.
|
|
16
|
+
* @throws When network operations fail after maximum retry attempts.
|
|
17
|
+
* @throws When messenger calls to UserStorageController fail due to authentication errors, encryption/decryption failures, or network issues.
|
|
18
|
+
*/
|
|
19
|
+
const getWalletFromUserStorage = async (context, entropySourceId) => {
|
|
20
|
+
return (0, network_utils_js_1.executeWithRetry)(async () => {
|
|
21
|
+
const walletData = await context.messenger.call('UserStorageController:performGetStorage', `${constants_js_1.USER_STORAGE_WALLETS_FEATURE_KEY}.${constants_js_1.USER_STORAGE_WALLETS_FEATURE_ENTRY_KEY}`, entropySourceId);
|
|
22
|
+
if (!walletData) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
try {
|
|
26
|
+
(0, logger_js_1.backupAndSyncLogger)(`Retrieved wallet data from user storage: ${JSON.stringify(walletData)}`);
|
|
27
|
+
return (0, format_utils_js_1.parseWalletFromUserStorageResponse)(walletData);
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
(0, logger_js_1.backupAndSyncLogger)(`Failed to parse wallet data from user storage: ${(0, errors_js_1.toErrorMessage)(error)}`);
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
exports.getWalletFromUserStorage = getWalletFromUserStorage;
|
|
36
|
+
/**
|
|
37
|
+
* Pushes the wallet to user storage.
|
|
38
|
+
*
|
|
39
|
+
* @param context - The backup and sync context.
|
|
40
|
+
* @param wallet - The wallet to push to user storage.
|
|
41
|
+
* @returns A promise that resolves when the operation is complete.
|
|
42
|
+
* @throws When network operations fail after maximum retry attempts.
|
|
43
|
+
* @throws When messenger calls to UserStorageController fail due to authentication errors, encryption/decryption failures, or network issues.
|
|
44
|
+
* @throws When JSON.stringify fails on the formatted wallet data.
|
|
45
|
+
*/
|
|
46
|
+
const pushWalletToUserStorage = async (context, wallet) => {
|
|
47
|
+
return (0, network_utils_js_1.executeWithRetry)(async () => {
|
|
48
|
+
const formattedWallet = (0, format_utils_js_1.formatWalletForUserStorageUsage)(context, wallet);
|
|
49
|
+
const stringifiedWallet = JSON.stringify(formattedWallet);
|
|
50
|
+
const entropySourceId = wallet.metadata.entropy.id;
|
|
51
|
+
(0, logger_js_1.backupAndSyncLogger)(`Pushing wallet to user storage: ${stringifiedWallet}`);
|
|
52
|
+
const result = await context.messenger.call('UserStorageController:performSetStorage', `${constants_js_1.USER_STORAGE_WALLETS_FEATURE_KEY}.${constants_js_1.USER_STORAGE_WALLETS_FEATURE_ENTRY_KEY}`, stringifiedWallet, entropySourceId);
|
|
53
|
+
context.mutationTracker?.setRemoteWrite(true);
|
|
54
|
+
return result;
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
exports.pushWalletToUserStorage = pushWalletToUserStorage;
|
|
58
|
+
/**
|
|
59
|
+
* Retrieves all groups from user storage.
|
|
60
|
+
*
|
|
61
|
+
* @param context - The backup and sync context.
|
|
62
|
+
* @param entropySourceId - The entropy source ID.
|
|
63
|
+
* @returns An array of groups from user storage.
|
|
64
|
+
* @throws When network operations fail after maximum retry attempts.
|
|
65
|
+
* @throws When messenger calls to UserStorageController fail due to authentication errors, encryption/decryption failures, or network issues.
|
|
66
|
+
*/
|
|
67
|
+
const getAllGroupsFromUserStorage = async (context, entropySourceId) => {
|
|
68
|
+
return (0, network_utils_js_1.executeWithRetry)(async () => {
|
|
69
|
+
const groupData = await context.messenger.call('UserStorageController:performGetStorageAllFeatureEntries', `${constants_js_1.USER_STORAGE_GROUPS_FEATURE_KEY}`, entropySourceId);
|
|
70
|
+
if (!groupData) {
|
|
71
|
+
return [];
|
|
72
|
+
}
|
|
73
|
+
const allGroups = groupData
|
|
74
|
+
.map((stringifiedGroup) => {
|
|
75
|
+
try {
|
|
76
|
+
return (0, format_utils_js_1.parseGroupFromUserStorageResponse)(stringifiedGroup);
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
(0, logger_js_1.backupAndSyncLogger)(`Failed to parse group data from user storage: ${(0, errors_js_1.toErrorMessage)(error)}`);
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
})
|
|
83
|
+
.filter((group) => group !== null);
|
|
84
|
+
(0, logger_js_1.backupAndSyncLogger)(`Retrieved groups from user storage: ${JSON.stringify(allGroups)}`);
|
|
85
|
+
return allGroups;
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
exports.getAllGroupsFromUserStorage = getAllGroupsFromUserStorage;
|
|
89
|
+
/**
|
|
90
|
+
* Retrieves a single group from user storage by group index.
|
|
91
|
+
*
|
|
92
|
+
* @param context - The backup and sync context.
|
|
93
|
+
* @param entropySourceId - The entropy source ID.
|
|
94
|
+
* @param groupIndex - The group index to retrieve.
|
|
95
|
+
* @returns The group from user storage or null if not found or invalid.
|
|
96
|
+
* @throws When network operations fail after maximum retry attempts.
|
|
97
|
+
* @throws When messenger calls to UserStorageController fail due to authentication errors, encryption/decryption failures, or network issues.
|
|
98
|
+
*/
|
|
99
|
+
const getGroupFromUserStorage = async (context, entropySourceId, groupIndex) => {
|
|
100
|
+
return (0, network_utils_js_1.executeWithRetry)(async () => {
|
|
101
|
+
const groupData = await context.messenger.call('UserStorageController:performGetStorage', `${constants_js_1.USER_STORAGE_GROUPS_FEATURE_KEY}.${groupIndex}`, entropySourceId);
|
|
102
|
+
if (!groupData) {
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
try {
|
|
106
|
+
return (0, format_utils_js_1.parseGroupFromUserStorageResponse)(groupData);
|
|
107
|
+
}
|
|
108
|
+
catch (error) {
|
|
109
|
+
(0, logger_js_1.backupAndSyncLogger)(`Failed to parse group data from user storage: ${(0, errors_js_1.toErrorMessage)(error)}`);
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
};
|
|
114
|
+
exports.getGroupFromUserStorage = getGroupFromUserStorage;
|
|
115
|
+
/**
|
|
116
|
+
* Pushes a group to user storage.
|
|
117
|
+
*
|
|
118
|
+
* @param context - The backup and sync context.
|
|
119
|
+
* @param group - The group to push to user storage.
|
|
120
|
+
* @param entropySourceId - The entropy source ID.
|
|
121
|
+
* @returns A promise that resolves when the operation is complete.
|
|
122
|
+
* @throws When network operations fail after maximum retry attempts.
|
|
123
|
+
* @throws When messenger calls to UserStorageController fail due to authentication errors, encryption/decryption failures, or network issues.
|
|
124
|
+
* @throws When JSON.stringify fails on the formatted group data.
|
|
125
|
+
*/
|
|
126
|
+
const pushGroupToUserStorage = async (context, group, entropySourceId) => {
|
|
127
|
+
return (0, network_utils_js_1.executeWithRetry)(async () => {
|
|
128
|
+
const formattedGroup = (0, format_utils_js_1.formatGroupForUserStorageUsage)(context, group);
|
|
129
|
+
const stringifiedGroup = JSON.stringify(formattedGroup);
|
|
130
|
+
(0, logger_js_1.backupAndSyncLogger)(`Pushing group to user storage: ${stringifiedGroup}`);
|
|
131
|
+
const result = await context.messenger.call('UserStorageController:performSetStorage', `${constants_js_1.USER_STORAGE_GROUPS_FEATURE_KEY}.${formattedGroup.groupIndex}`, stringifiedGroup, entropySourceId);
|
|
132
|
+
context.mutationTracker?.setRemoteWrite(true);
|
|
133
|
+
return result;
|
|
134
|
+
});
|
|
135
|
+
};
|
|
136
|
+
exports.pushGroupToUserStorage = pushGroupToUserStorage;
|
|
137
|
+
/**
|
|
138
|
+
* Pushes a batch of groups to user storage.
|
|
139
|
+
*
|
|
140
|
+
* @param context - The backup and sync context.
|
|
141
|
+
* @param groups - The groups to push to user storage.
|
|
142
|
+
* @param entropySourceId - The entropy source ID.
|
|
143
|
+
* @returns A promise that resolves when the operation is complete.
|
|
144
|
+
* @throws When network operations fail after maximum retry attempts.
|
|
145
|
+
* @throws When messenger calls to UserStorageController fail due to authentication errors, encryption/decryption failures, or network issues.
|
|
146
|
+
* @throws When JSON.stringify fails on any of the formatted group data.
|
|
147
|
+
*/
|
|
148
|
+
const pushGroupToUserStorageBatch = async (context, groups, entropySourceId) => {
|
|
149
|
+
return (0, network_utils_js_1.executeWithRetry)(async () => {
|
|
150
|
+
const formattedGroups = groups.map((group) => (0, format_utils_js_1.formatGroupForUserStorageUsage)(context, group));
|
|
151
|
+
const entries = formattedGroups.map((group) => [
|
|
152
|
+
String(group.groupIndex),
|
|
153
|
+
JSON.stringify(group),
|
|
154
|
+
]);
|
|
155
|
+
(0, logger_js_1.backupAndSyncLogger)(`Pushing groups to user storage: ${entries.map(([_, value]) => value).join(', ')}`);
|
|
156
|
+
const result = await context.messenger.call('UserStorageController:performBatchSetStorage', constants_js_1.USER_STORAGE_GROUPS_FEATURE_KEY, entries, entropySourceId);
|
|
157
|
+
context.mutationTracker?.setRemoteWrite(true);
|
|
158
|
+
return result;
|
|
159
|
+
});
|
|
160
|
+
};
|
|
161
|
+
exports.pushGroupToUserStorageBatch = pushGroupToUserStorageBatch;
|
|
162
|
+
/**
|
|
163
|
+
* Retrieves legacy user storage accounts for a specific entropy source ID.
|
|
164
|
+
*
|
|
165
|
+
* @param context - The backup and sync context.
|
|
166
|
+
* @param entropySourceId - The entropy source ID to retrieve data for.
|
|
167
|
+
* @returns A promise that resolves with the legacy user storage accounts.
|
|
168
|
+
* @throws When network operations fail after maximum retry attempts.
|
|
169
|
+
* @throws When messenger calls to UserStorageController fail due to authentication errors, encryption/decryption failures, or network issues.
|
|
170
|
+
*/
|
|
171
|
+
const getAllLegacyUserStorageAccounts = async (context, entropySourceId) => {
|
|
172
|
+
return (0, network_utils_js_1.executeWithRetry)(async () => {
|
|
173
|
+
const accountsData = await context.messenger.call('UserStorageController:performGetStorageAllFeatureEntries', profile_sync_controller_1.SDK.USER_STORAGE_FEATURE_NAMES.accounts, entropySourceId);
|
|
174
|
+
if (!accountsData) {
|
|
175
|
+
return [];
|
|
176
|
+
}
|
|
177
|
+
const allAccounts = accountsData
|
|
178
|
+
.map((stringifiedAccount) => {
|
|
179
|
+
try {
|
|
180
|
+
return (0, format_utils_js_1.parseLegacyAccountFromUserStorageResponse)(stringifiedAccount);
|
|
181
|
+
}
|
|
182
|
+
catch (error) {
|
|
183
|
+
(0, logger_js_1.backupAndSyncLogger)(`Failed to parse legacy account data from user storage: ${(0, errors_js_1.toErrorMessage)(error)}`);
|
|
184
|
+
return null;
|
|
185
|
+
}
|
|
186
|
+
})
|
|
187
|
+
.filter((account) => account !== null);
|
|
188
|
+
(0, logger_js_1.backupAndSyncLogger)(`Retrieved legacy accounts from user storage: ${JSON.stringify(allAccounts)}`);
|
|
189
|
+
return allAccounts;
|
|
190
|
+
});
|
|
191
|
+
};
|
|
192
|
+
exports.getAllLegacyUserStorageAccounts = getAllLegacyUserStorageAccounts;
|
|
193
|
+
//# sourceMappingURL=network-operations.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"network-operations.cjs","sourceRoot":"","sources":["../../../src/backup-and-sync/user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C,KAAK,IAAI,EAAE;QACjC,MAAM,YAAY,GAAG,MAAM,OAAO,CAAC,SAAS,CAAC,IAAI,CAC/C,0DAA0D,EAC1D,6BAAG,CAAC,0BAA0B,CAAC,QAAQ,EACvC,eAAe,CAChB,CAAC;QAEF,IAAI,CAAC,YAAY,EAAE,CAAC;YAClB,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,MAAM,WAAW,GAAG,YAAY;aAC7B,GAAG,CAAC,CAAC,kBAAkB,EAAE,EAAE;YAC1B,IAAI,CAAC;gBACH,OAAO,IAAA,2DAAyC,EAAC,kBAAkB,CAAC,CAAC;YACvE,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,IAAA,+BAAmB,EACjB,0DAA0D,IAAA,0BAAc,EAAC,KAAK,CAAC,EAAE,CAClF,CAAC;gBACF,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC,CAAC;aACD,MAAM,CACL,CAAC,OAAO,EAA6C,EAAE,CACrD,OAAO,KAAK,IAAI,CACnB,CAAC;QAEJ,IAAA,+BAAmB,EACjB,gDAAgD,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,EAAE,CAC9E,CAAC;QAEF,OAAO,WAAW,CAAC;IACrB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AArCW,QAAA,+BAA+B,mCAqC1C","sourcesContent":["import { SDK } from '@metamask/profile-sync-controller';\n\nimport type { AccountGroupMultichainAccountObject } from '../../group.js';\nimport { backupAndSyncLogger } from '../../logger.js';\nimport type { AccountWalletEntropyObject } from '../../wallet.js';\nimport type {\n BackupAndSyncContext,\n LegacyUserStorageSyncedAccount,\n UserStorageSyncedWallet,\n UserStorageSyncedWalletGroup,\n} from '../types.js';\nimport { toErrorMessage } from '../utils/errors.js';\nimport {\n USER_STORAGE_GROUPS_FEATURE_KEY,\n USER_STORAGE_WALLETS_FEATURE_ENTRY_KEY,\n USER_STORAGE_WALLETS_FEATURE_KEY,\n} from './constants.js';\nimport {\n formatWalletForUserStorageUsage,\n formatGroupForUserStorageUsage,\n parseWalletFromUserStorageResponse,\n parseGroupFromUserStorageResponse,\n parseLegacyAccountFromUserStorageResponse,\n} from './format-utils.js';\nimport { executeWithRetry } from './network-utils.js';\n\n/**\n * Retrieves the wallet from user storage.\n *\n * @param context - The backup and sync context.\n * @param entropySourceId - The entropy source ID.\n * @returns The wallet from user storage or null if not found or invalid.\n * @throws When network operations fail after maximum retry attempts.\n * @throws When messenger calls to UserStorageController fail due to authentication errors, encryption/decryption failures, or network issues.\n */\nexport const getWalletFromUserStorage = async (\n context: BackupAndSyncContext,\n entropySourceId: string,\n): Promise<UserStorageSyncedWallet | null> => {\n return executeWithRetry(async () => {\n const walletData = await context.messenger.call(\n 'UserStorageController:performGetStorage',\n `${USER_STORAGE_WALLETS_FEATURE_KEY}.${USER_STORAGE_WALLETS_FEATURE_ENTRY_KEY}`,\n entropySourceId,\n );\n if (!walletData) {\n return null;\n }\n\n try {\n backupAndSyncLogger(\n `Retrieved wallet data from user storage: ${JSON.stringify(walletData)}`,\n );\n return parseWalletFromUserStorageResponse(walletData);\n } catch (error) {\n backupAndSyncLogger(\n `Failed to parse wallet data from user storage: ${toErrorMessage(error)}`,\n );\n return null;\n }\n });\n};\n\n/**\n * Pushes the wallet to user storage.\n *\n * @param context - The backup and sync context.\n * @param wallet - The wallet to push to user storage.\n * @returns A promise that resolves when the operation is complete.\n * @throws When network operations fail after maximum retry attempts.\n * @throws When messenger calls to UserStorageController fail due to authentication errors, encryption/decryption failures, or network issues.\n * @throws When JSON.stringify fails on the formatted wallet data.\n */\nexport const pushWalletToUserStorage = async (\n context: BackupAndSyncContext,\n wallet: AccountWalletEntropyObject,\n): Promise<void> => {\n return executeWithRetry(async () => {\n const formattedWallet = formatWalletForUserStorageUsage(context, wallet);\n const stringifiedWallet = JSON.stringify(formattedWallet);\n const entropySourceId = wallet.metadata.entropy.id;\n\n backupAndSyncLogger(`Pushing wallet to user storage: ${stringifiedWallet}`);\n\n const result = await context.messenger.call(\n 'UserStorageController:performSetStorage',\n `${USER_STORAGE_WALLETS_FEATURE_KEY}.${USER_STORAGE_WALLETS_FEATURE_ENTRY_KEY}`,\n stringifiedWallet,\n entropySourceId,\n );\n context.mutationTracker?.setRemoteWrite(true);\n return result;\n });\n};\n\n/**\n * Retrieves all groups from user storage.\n *\n * @param context - The backup and sync context.\n * @param entropySourceId - The entropy source ID.\n * @returns An array of groups from user storage.\n * @throws When network operations fail after maximum retry attempts.\n * @throws When messenger calls to UserStorageController fail due to authentication errors, encryption/decryption failures, or network issues.\n */\nexport const getAllGroupsFromUserStorage = async (\n context: BackupAndSyncContext,\n entropySourceId: string,\n): Promise<UserStorageSyncedWalletGroup[]> => {\n return executeWithRetry(async () => {\n const groupData = await context.messenger.call(\n 'UserStorageController:performGetStorageAllFeatureEntries',\n `${USER_STORAGE_GROUPS_FEATURE_KEY}`,\n entropySourceId,\n );\n if (!groupData) {\n return [];\n }\n\n const allGroups = groupData\n .map((stringifiedGroup) => {\n try {\n return parseGroupFromUserStorageResponse(stringifiedGroup);\n } catch (error) {\n backupAndSyncLogger(\n `Failed to parse group data from user storage: ${toErrorMessage(error)}`,\n );\n return null;\n }\n })\n .filter((group): group is UserStorageSyncedWalletGroup => group !== null);\n\n backupAndSyncLogger(\n `Retrieved groups from user storage: ${JSON.stringify(allGroups)}`,\n );\n\n return allGroups;\n });\n};\n\n/**\n * Retrieves a single group from user storage by group index.\n *\n * @param context - The backup and sync context.\n * @param entropySourceId - The entropy source ID.\n * @param groupIndex - The group index to retrieve.\n * @returns The group from user storage or null if not found or invalid.\n * @throws When network operations fail after maximum retry attempts.\n * @throws When messenger calls to UserStorageController fail due to authentication errors, encryption/decryption failures, or network issues.\n */\nexport const getGroupFromUserStorage = async (\n context: BackupAndSyncContext,\n entropySourceId: string,\n groupIndex: number,\n): Promise<UserStorageSyncedWalletGroup | null> => {\n return executeWithRetry(async () => {\n const groupData = await context.messenger.call(\n 'UserStorageController:performGetStorage',\n `${USER_STORAGE_GROUPS_FEATURE_KEY}.${groupIndex}`,\n entropySourceId,\n );\n if (!groupData) {\n return null;\n }\n\n try {\n return parseGroupFromUserStorageResponse(groupData);\n } catch (error) {\n backupAndSyncLogger(\n `Failed to parse group data from user storage: ${toErrorMessage(error)}`,\n );\n return null;\n }\n });\n};\n\n/**\n * Pushes a group to user storage.\n *\n * @param context - The backup and sync context.\n * @param group - The group to push to user storage.\n * @param entropySourceId - The entropy source ID.\n * @returns A promise that resolves when the operation is complete.\n * @throws When network operations fail after maximum retry attempts.\n * @throws When messenger calls to UserStorageController fail due to authentication errors, encryption/decryption failures, or network issues.\n * @throws When JSON.stringify fails on the formatted group data.\n */\nexport const pushGroupToUserStorage = async (\n context: BackupAndSyncContext,\n group: AccountGroupMultichainAccountObject,\n entropySourceId: string,\n): Promise<void> => {\n return executeWithRetry(async () => {\n const formattedGroup = formatGroupForUserStorageUsage(context, group);\n const stringifiedGroup = JSON.stringify(formattedGroup);\n\n backupAndSyncLogger(`Pushing group to user storage: ${stringifiedGroup}`);\n\n const result = await context.messenger.call(\n 'UserStorageController:performSetStorage',\n `${USER_STORAGE_GROUPS_FEATURE_KEY}.${formattedGroup.groupIndex}`,\n stringifiedGroup,\n entropySourceId,\n );\n context.mutationTracker?.setRemoteWrite(true);\n return result;\n });\n};\n\n/**\n * Pushes a batch of groups to user storage.\n *\n * @param context - The backup and sync context.\n * @param groups - The groups to push to user storage.\n * @param entropySourceId - The entropy source ID.\n * @returns A promise that resolves when the operation is complete.\n * @throws When network operations fail after maximum retry attempts.\n * @throws When messenger calls to UserStorageController fail due to authentication errors, encryption/decryption failures, or network issues.\n * @throws When JSON.stringify fails on any of the formatted group data.\n */\nexport const pushGroupToUserStorageBatch = async (\n context: BackupAndSyncContext,\n groups: AccountGroupMultichainAccountObject[],\n entropySourceId: string,\n): Promise<void> => {\n return executeWithRetry(async () => {\n const formattedGroups = groups.map((group) =>\n formatGroupForUserStorageUsage(context, group),\n );\n\n const entries: [string, string][] = formattedGroups.map((group) => [\n String(group.groupIndex),\n JSON.stringify(group),\n ]);\n\n backupAndSyncLogger(\n `Pushing groups to user storage: ${entries.map(([_, value]) => value).join(', ')}`,\n );\n\n const result = await context.messenger.call(\n 'UserStorageController:performBatchSetStorage',\n USER_STORAGE_GROUPS_FEATURE_KEY,\n entries,\n entropySourceId,\n );\n context.mutationTracker?.setRemoteWrite(true);\n return result;\n });\n};\n\n/**\n * Retrieves legacy user storage accounts for a specific entropy source ID.\n *\n * @param context - The backup and sync context.\n * @param entropySourceId - The entropy source ID to retrieve data for.\n * @returns A promise that resolves with the legacy user storage accounts.\n * @throws When network operations fail after maximum retry attempts.\n * @throws When messenger calls to UserStorageController fail due to authentication errors, encryption/decryption failures, or network issues.\n */\nexport const getAllLegacyUserStorageAccounts = async (\n context: BackupAndSyncContext,\n entropySourceId: string,\n): Promise<LegacyUserStorageSyncedAccount[]> => {\n return executeWithRetry(async () => {\n const accountsData = await context.messenger.call(\n 'UserStorageController:performGetStorageAllFeatureEntries',\n SDK.USER_STORAGE_FEATURE_NAMES.accounts,\n entropySourceId,\n );\n\n if (!accountsData) {\n return [];\n }\n\n const allAccounts = accountsData\n .map((stringifiedAccount) => {\n try {\n return parseLegacyAccountFromUserStorageResponse(stringifiedAccount);\n } catch (error) {\n backupAndSyncLogger(\n `Failed to parse legacy account data from user storage: ${toErrorMessage(error)}`,\n );\n return null;\n }\n })\n .filter(\n (account): account is LegacyUserStorageSyncedAccount =>\n account !== null,\n );\n\n backupAndSyncLogger(\n `Retrieved legacy accounts from user storage: ${JSON.stringify(allAccounts)}`,\n );\n\n return allAccounts;\n });\n};\n"]}
|
package/dist/backup-and-sync/user-storage/{network-operations.d.ts → network-operations.d.cts}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { AccountGroupMultichainAccountObject } from
|
|
2
|
-
import type { AccountWalletEntropyObject } from
|
|
3
|
-
import type { BackupAndSyncContext, LegacyUserStorageSyncedAccount, UserStorageSyncedWallet, UserStorageSyncedWalletGroup } from
|
|
1
|
+
import type { AccountGroupMultichainAccountObject } from "../../group.cjs";
|
|
2
|
+
import type { AccountWalletEntropyObject } from "../../wallet.cjs";
|
|
3
|
+
import type { BackupAndSyncContext, LegacyUserStorageSyncedAccount, UserStorageSyncedWallet, UserStorageSyncedWalletGroup } from "../types.cjs";
|
|
4
4
|
/**
|
|
5
5
|
* Retrieves the wallet from user storage.
|
|
6
6
|
*
|
|
@@ -77,4 +77,4 @@ export declare const pushGroupToUserStorageBatch: (context: BackupAndSyncContext
|
|
|
77
77
|
* @throws When messenger calls to UserStorageController fail due to authentication errors, encryption/decryption failures, or network issues.
|
|
78
78
|
*/
|
|
79
79
|
export declare const getAllLegacyUserStorageAccounts: (context: BackupAndSyncContext, entropySourceId: string) => Promise<LegacyUserStorageSyncedAccount[]>;
|
|
80
|
-
//# sourceMappingURL=network-operations.d.
|
|
80
|
+
//# sourceMappingURL=network-operations.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"network-operations.d.cts","sourceRoot":"","sources":["../../../src/backup-and-sync/user-storage/network-operations.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mCAAmC,EAAE,wBAAuB;AAE1E,OAAO,KAAK,EAAE,0BAA0B,EAAE,yBAAwB;AAClE,OAAO,KAAK,EACV,oBAAoB,EACpB,8BAA8B,EAC9B,uBAAuB,EACvB,4BAA4B,EAC7B,qBAAoB;AAgBrB;;;;;;;;GAQG;AACH,eAAO,MAAM,wBAAwB,YAC1B,oBAAoB,mBACZ,MAAM,KACtB,QAAQ,uBAAuB,GAAG,IAAI,CAuBxC,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,uBAAuB,YACzB,oBAAoB,UACrB,0BAA0B,KACjC,QAAQ,IAAI,CAiBd,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,2BAA2B,YAC7B,oBAAoB,mBACZ,MAAM,KACtB,QAAQ,4BAA4B,EAAE,CA8BxC,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,uBAAuB,YACzB,oBAAoB,mBACZ,MAAM,cACX,MAAM,KACjB,QAAQ,4BAA4B,GAAG,IAAI,CAoB7C,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,sBAAsB,YACxB,oBAAoB,SACtB,mCAAmC,mBACzB,MAAM,KACtB,QAAQ,IAAI,CAgBd,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,2BAA2B,YAC7B,oBAAoB,UACrB,mCAAmC,EAAE,mBAC5B,MAAM,KACtB,QAAQ,IAAI,CAwBd,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,+BAA+B,YACjC,oBAAoB,mBACZ,MAAM,KACtB,QAAQ,8BAA8B,EAAE,CAkC1C,CAAC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { AccountGroupMultichainAccountObject } from "../../group.mjs";
|
|
2
|
+
import type { AccountWalletEntropyObject } from "../../wallet.mjs";
|
|
3
|
+
import type { BackupAndSyncContext, LegacyUserStorageSyncedAccount, UserStorageSyncedWallet, UserStorageSyncedWalletGroup } from "../types.mjs";
|
|
4
|
+
/**
|
|
5
|
+
* Retrieves the wallet from user storage.
|
|
6
|
+
*
|
|
7
|
+
* @param context - The backup and sync context.
|
|
8
|
+
* @param entropySourceId - The entropy source ID.
|
|
9
|
+
* @returns The wallet from user storage or null if not found or invalid.
|
|
10
|
+
* @throws When network operations fail after maximum retry attempts.
|
|
11
|
+
* @throws When messenger calls to UserStorageController fail due to authentication errors, encryption/decryption failures, or network issues.
|
|
12
|
+
*/
|
|
13
|
+
export declare const getWalletFromUserStorage: (context: BackupAndSyncContext, entropySourceId: string) => Promise<UserStorageSyncedWallet | null>;
|
|
14
|
+
/**
|
|
15
|
+
* Pushes the wallet to user storage.
|
|
16
|
+
*
|
|
17
|
+
* @param context - The backup and sync context.
|
|
18
|
+
* @param wallet - The wallet to push to user storage.
|
|
19
|
+
* @returns A promise that resolves when the operation is complete.
|
|
20
|
+
* @throws When network operations fail after maximum retry attempts.
|
|
21
|
+
* @throws When messenger calls to UserStorageController fail due to authentication errors, encryption/decryption failures, or network issues.
|
|
22
|
+
* @throws When JSON.stringify fails on the formatted wallet data.
|
|
23
|
+
*/
|
|
24
|
+
export declare const pushWalletToUserStorage: (context: BackupAndSyncContext, wallet: AccountWalletEntropyObject) => Promise<void>;
|
|
25
|
+
/**
|
|
26
|
+
* Retrieves all groups from user storage.
|
|
27
|
+
*
|
|
28
|
+
* @param context - The backup and sync context.
|
|
29
|
+
* @param entropySourceId - The entropy source ID.
|
|
30
|
+
* @returns An array of groups from user storage.
|
|
31
|
+
* @throws When network operations fail after maximum retry attempts.
|
|
32
|
+
* @throws When messenger calls to UserStorageController fail due to authentication errors, encryption/decryption failures, or network issues.
|
|
33
|
+
*/
|
|
34
|
+
export declare const getAllGroupsFromUserStorage: (context: BackupAndSyncContext, entropySourceId: string) => Promise<UserStorageSyncedWalletGroup[]>;
|
|
35
|
+
/**
|
|
36
|
+
* Retrieves a single group from user storage by group index.
|
|
37
|
+
*
|
|
38
|
+
* @param context - The backup and sync context.
|
|
39
|
+
* @param entropySourceId - The entropy source ID.
|
|
40
|
+
* @param groupIndex - The group index to retrieve.
|
|
41
|
+
* @returns The group from user storage or null if not found or invalid.
|
|
42
|
+
* @throws When network operations fail after maximum retry attempts.
|
|
43
|
+
* @throws When messenger calls to UserStorageController fail due to authentication errors, encryption/decryption failures, or network issues.
|
|
44
|
+
*/
|
|
45
|
+
export declare const getGroupFromUserStorage: (context: BackupAndSyncContext, entropySourceId: string, groupIndex: number) => Promise<UserStorageSyncedWalletGroup | null>;
|
|
46
|
+
/**
|
|
47
|
+
* Pushes a group to user storage.
|
|
48
|
+
*
|
|
49
|
+
* @param context - The backup and sync context.
|
|
50
|
+
* @param group - The group to push to user storage.
|
|
51
|
+
* @param entropySourceId - The entropy source ID.
|
|
52
|
+
* @returns A promise that resolves when the operation is complete.
|
|
53
|
+
* @throws When network operations fail after maximum retry attempts.
|
|
54
|
+
* @throws When messenger calls to UserStorageController fail due to authentication errors, encryption/decryption failures, or network issues.
|
|
55
|
+
* @throws When JSON.stringify fails on the formatted group data.
|
|
56
|
+
*/
|
|
57
|
+
export declare const pushGroupToUserStorage: (context: BackupAndSyncContext, group: AccountGroupMultichainAccountObject, entropySourceId: string) => Promise<void>;
|
|
58
|
+
/**
|
|
59
|
+
* Pushes a batch of groups to user storage.
|
|
60
|
+
*
|
|
61
|
+
* @param context - The backup and sync context.
|
|
62
|
+
* @param groups - The groups to push to user storage.
|
|
63
|
+
* @param entropySourceId - The entropy source ID.
|
|
64
|
+
* @returns A promise that resolves when the operation is complete.
|
|
65
|
+
* @throws When network operations fail after maximum retry attempts.
|
|
66
|
+
* @throws When messenger calls to UserStorageController fail due to authentication errors, encryption/decryption failures, or network issues.
|
|
67
|
+
* @throws When JSON.stringify fails on any of the formatted group data.
|
|
68
|
+
*/
|
|
69
|
+
export declare const pushGroupToUserStorageBatch: (context: BackupAndSyncContext, groups: AccountGroupMultichainAccountObject[], entropySourceId: string) => Promise<void>;
|
|
70
|
+
/**
|
|
71
|
+
* Retrieves legacy user storage accounts for a specific entropy source ID.
|
|
72
|
+
*
|
|
73
|
+
* @param context - The backup and sync context.
|
|
74
|
+
* @param entropySourceId - The entropy source ID to retrieve data for.
|
|
75
|
+
* @returns A promise that resolves with the legacy user storage accounts.
|
|
76
|
+
* @throws When network operations fail after maximum retry attempts.
|
|
77
|
+
* @throws When messenger calls to UserStorageController fail due to authentication errors, encryption/decryption failures, or network issues.
|
|
78
|
+
*/
|
|
79
|
+
export declare const getAllLegacyUserStorageAccounts: (context: BackupAndSyncContext, entropySourceId: string) => Promise<LegacyUserStorageSyncedAccount[]>;
|
|
80
|
+
//# sourceMappingURL=network-operations.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"network-operations.d.mts","sourceRoot":"","sources":["../../../src/backup-and-sync/user-storage/network-operations.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mCAAmC,EAAE,wBAAuB;AAE1E,OAAO,KAAK,EAAE,0BAA0B,EAAE,yBAAwB;AAClE,OAAO,KAAK,EACV,oBAAoB,EACpB,8BAA8B,EAC9B,uBAAuB,EACvB,4BAA4B,EAC7B,qBAAoB;AAgBrB;;;;;;;;GAQG;AACH,eAAO,MAAM,wBAAwB,YAC1B,oBAAoB,mBACZ,MAAM,KACtB,QAAQ,uBAAuB,GAAG,IAAI,CAuBxC,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,uBAAuB,YACzB,oBAAoB,UACrB,0BAA0B,KACjC,QAAQ,IAAI,CAiBd,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,2BAA2B,YAC7B,oBAAoB,mBACZ,MAAM,KACtB,QAAQ,4BAA4B,EAAE,CA8BxC,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,uBAAuB,YACzB,oBAAoB,mBACZ,MAAM,cACX,MAAM,KACjB,QAAQ,4BAA4B,GAAG,IAAI,CAoB7C,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,sBAAsB,YACxB,oBAAoB,SACtB,mCAAmC,mBACzB,MAAM,KACtB,QAAQ,IAAI,CAgBd,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,2BAA2B,YAC7B,oBAAoB,UACrB,mCAAmC,EAAE,mBAC5B,MAAM,KACtB,QAAQ,IAAI,CAwBd,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,+BAA+B,YACjC,oBAAoB,mBACZ,MAAM,KACtB,QAAQ,8BAA8B,EAAE,CAkC1C,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { SDK } from
|
|
2
|
-
import { backupAndSyncLogger } from
|
|
3
|
-
import { toErrorMessage } from
|
|
4
|
-
import { USER_STORAGE_GROUPS_FEATURE_KEY, USER_STORAGE_WALLETS_FEATURE_ENTRY_KEY, USER_STORAGE_WALLETS_FEATURE_KEY
|
|
5
|
-
import { formatWalletForUserStorageUsage, formatGroupForUserStorageUsage, parseWalletFromUserStorageResponse, parseGroupFromUserStorageResponse, parseLegacyAccountFromUserStorageResponse
|
|
6
|
-
import { executeWithRetry } from
|
|
1
|
+
import { SDK } from "@metamask/profile-sync-controller";
|
|
2
|
+
import { backupAndSyncLogger } from "../../logger.mjs";
|
|
3
|
+
import { toErrorMessage } from "../utils/errors.mjs";
|
|
4
|
+
import { USER_STORAGE_GROUPS_FEATURE_KEY, USER_STORAGE_WALLETS_FEATURE_ENTRY_KEY, USER_STORAGE_WALLETS_FEATURE_KEY } from "./constants.mjs";
|
|
5
|
+
import { formatWalletForUserStorageUsage, formatGroupForUserStorageUsage, parseWalletFromUserStorageResponse, parseGroupFromUserStorageResponse, parseLegacyAccountFromUserStorageResponse } from "./format-utils.mjs";
|
|
6
|
+
import { executeWithRetry } from "./network-utils.mjs";
|
|
7
7
|
/**
|
|
8
8
|
* Retrieves the wallet from user storage.
|
|
9
9
|
*
|
|
@@ -180,4 +180,4 @@ export const getAllLegacyUserStorageAccounts = async (context, entropySourceId)
|
|
|
180
180
|
return allAccounts;
|
|
181
181
|
});
|
|
182
182
|
};
|
|
183
|
-
//# sourceMappingURL=network-operations.
|
|
183
|
+
//# sourceMappingURL=network-operations.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"network-operations.mjs","sourceRoot":"","sources":["../../../src/backup-and-sync/user-storage/network-operations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,0CAA0C;AAGxD,OAAO,EAAE,mBAAmB,EAAE,yBAAwB;AAQtD,OAAO,EAAE,cAAc,EAAE,4BAA2B;AACpD,OAAO,EACL,+BAA+B,EAC/B,sCAAsC,EACtC,gCAAgC,EACjC,wBAAuB;AACxB,OAAO,EACL,+BAA+B,EAC/B,8BAA8B,EAC9B,kCAAkC,EAClC,iCAAiC,E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E,EAAE;YAC1B,IAAI,CAAC;gBACH,OAAO,yCAAyC,CAAC,kBAAkB,CAAC,CAAC;YACvE,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,mBAAmB,CACjB,0DAA0D,cAAc,CAAC,KAAK,CAAC,EAAE,CAClF,CAAC;gBACF,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC,CAAC;aACD,MAAM,CACL,CAAC,OAAO,EAA6C,EAAE,CACrD,OAAO,KAAK,IAAI,CACnB,CAAC;QAEJ,mBAAmB,CACjB,gDAAgD,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,EAAE,CAC9E,CAAC;QAEF,OAAO,WAAW,CAAC;IACrB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC","sourcesContent":["import { SDK } from '@metamask/profile-sync-controller';\n\nimport type { AccountGroupMultichainAccountObject } from '../../group.js';\nimport { backupAndSyncLogger } from '../../logger.js';\nimport type { AccountWalletEntropyObject } from '../../wallet.js';\nimport type {\n BackupAndSyncContext,\n LegacyUserStorageSyncedAccount,\n UserStorageSyncedWallet,\n UserStorageSyncedWalletGroup,\n} from '../types.js';\nimport { toErrorMessage } from '../utils/errors.js';\nimport {\n USER_STORAGE_GROUPS_FEATURE_KEY,\n USER_STORAGE_WALLETS_FEATURE_ENTRY_KEY,\n USER_STORAGE_WALLETS_FEATURE_KEY,\n} from './constants.js';\nimport {\n formatWalletForUserStorageUsage,\n formatGroupForUserStorageUsage,\n parseWalletFromUserStorageResponse,\n parseGroupFromUserStorageResponse,\n parseLegacyAccountFromUserStorageResponse,\n} from './format-utils.js';\nimport { executeWithRetry } from './network-utils.js';\n\n/**\n * Retrieves the wallet from user storage.\n *\n * @param context - The backup and sync context.\n * @param entropySourceId - The entropy source ID.\n * @returns The wallet from user storage or null if not found or invalid.\n * @throws When network operations fail after maximum retry attempts.\n * @throws When messenger calls to UserStorageController fail due to authentication errors, encryption/decryption failures, or network issues.\n */\nexport const getWalletFromUserStorage = async (\n context: BackupAndSyncContext,\n entropySourceId: string,\n): Promise<UserStorageSyncedWallet | null> => {\n return executeWithRetry(async () => {\n const walletData = await context.messenger.call(\n 'UserStorageController:performGetStorage',\n `${USER_STORAGE_WALLETS_FEATURE_KEY}.${USER_STORAGE_WALLETS_FEATURE_ENTRY_KEY}`,\n entropySourceId,\n );\n if (!walletData) {\n return null;\n }\n\n try {\n backupAndSyncLogger(\n `Retrieved wallet data from user storage: ${JSON.stringify(walletData)}`,\n );\n return parseWalletFromUserStorageResponse(walletData);\n } catch (error) {\n backupAndSyncLogger(\n `Failed to parse wallet data from user storage: ${toErrorMessage(error)}`,\n );\n return null;\n }\n });\n};\n\n/**\n * Pushes the wallet to user storage.\n *\n * @param context - The backup and sync context.\n * @param wallet - The wallet to push to user storage.\n * @returns A promise that resolves when the operation is complete.\n * @throws When network operations fail after maximum retry attempts.\n * @throws When messenger calls to UserStorageController fail due to authentication errors, encryption/decryption failures, or network issues.\n * @throws When JSON.stringify fails on the formatted wallet data.\n */\nexport const pushWalletToUserStorage = async (\n context: BackupAndSyncContext,\n wallet: AccountWalletEntropyObject,\n): Promise<void> => {\n return executeWithRetry(async () => {\n const formattedWallet = formatWalletForUserStorageUsage(context, wallet);\n const stringifiedWallet = JSON.stringify(formattedWallet);\n const entropySourceId = wallet.metadata.entropy.id;\n\n backupAndSyncLogger(`Pushing wallet to user storage: ${stringifiedWallet}`);\n\n const result = await context.messenger.call(\n 'UserStorageController:performSetStorage',\n `${USER_STORAGE_WALLETS_FEATURE_KEY}.${USER_STORAGE_WALLETS_FEATURE_ENTRY_KEY}`,\n stringifiedWallet,\n entropySourceId,\n );\n context.mutationTracker?.setRemoteWrite(true);\n return result;\n });\n};\n\n/**\n * Retrieves all groups from user storage.\n *\n * @param context - The backup and sync context.\n * @param entropySourceId - The entropy source ID.\n * @returns An array of groups from user storage.\n * @throws When network operations fail after maximum retry attempts.\n * @throws When messenger calls to UserStorageController fail due to authentication errors, encryption/decryption failures, or network issues.\n */\nexport const getAllGroupsFromUserStorage = async (\n context: BackupAndSyncContext,\n entropySourceId: string,\n): Promise<UserStorageSyncedWalletGroup[]> => {\n return executeWithRetry(async () => {\n const groupData = await context.messenger.call(\n 'UserStorageController:performGetStorageAllFeatureEntries',\n `${USER_STORAGE_GROUPS_FEATURE_KEY}`,\n entropySourceId,\n );\n if (!groupData) {\n return [];\n }\n\n const allGroups = groupData\n .map((stringifiedGroup) => {\n try {\n return parseGroupFromUserStorageResponse(stringifiedGroup);\n } catch (error) {\n backupAndSyncLogger(\n `Failed to parse group data from user storage: ${toErrorMessage(error)}`,\n );\n return null;\n }\n })\n .filter((group): group is UserStorageSyncedWalletGroup => group !== null);\n\n backupAndSyncLogger(\n `Retrieved groups from user storage: ${JSON.stringify(allGroups)}`,\n );\n\n return allGroups;\n });\n};\n\n/**\n * Retrieves a single group from user storage by group index.\n *\n * @param context - The backup and sync context.\n * @param entropySourceId - The entropy source ID.\n * @param groupIndex - The group index to retrieve.\n * @returns The group from user storage or null if not found or invalid.\n * @throws When network operations fail after maximum retry attempts.\n * @throws When messenger calls to UserStorageController fail due to authentication errors, encryption/decryption failures, or network issues.\n */\nexport const getGroupFromUserStorage = async (\n context: BackupAndSyncContext,\n entropySourceId: string,\n groupIndex: number,\n): Promise<UserStorageSyncedWalletGroup | null> => {\n return executeWithRetry(async () => {\n const groupData = await context.messenger.call(\n 'UserStorageController:performGetStorage',\n `${USER_STORAGE_GROUPS_FEATURE_KEY}.${groupIndex}`,\n entropySourceId,\n );\n if (!groupData) {\n return null;\n }\n\n try {\n return parseGroupFromUserStorageResponse(groupData);\n } catch (error) {\n backupAndSyncLogger(\n `Failed to parse group data from user storage: ${toErrorMessage(error)}`,\n );\n return null;\n }\n });\n};\n\n/**\n * Pushes a group to user storage.\n *\n * @param context - The backup and sync context.\n * @param group - The group to push to user storage.\n * @param entropySourceId - The entropy source ID.\n * @returns A promise that resolves when the operation is complete.\n * @throws When network operations fail after maximum retry attempts.\n * @throws When messenger calls to UserStorageController fail due to authentication errors, encryption/decryption failures, or network issues.\n * @throws When JSON.stringify fails on the formatted group data.\n */\nexport const pushGroupToUserStorage = async (\n context: BackupAndSyncContext,\n group: AccountGroupMultichainAccountObject,\n entropySourceId: string,\n): Promise<void> => {\n return executeWithRetry(async () => {\n const formattedGroup = formatGroupForUserStorageUsage(context, group);\n const stringifiedGroup = JSON.stringify(formattedGroup);\n\n backupAndSyncLogger(`Pushing group to user storage: ${stringifiedGroup}`);\n\n const result = await context.messenger.call(\n 'UserStorageController:performSetStorage',\n `${USER_STORAGE_GROUPS_FEATURE_KEY}.${formattedGroup.groupIndex}`,\n stringifiedGroup,\n entropySourceId,\n );\n context.mutationTracker?.setRemoteWrite(true);\n return result;\n });\n};\n\n/**\n * Pushes a batch of groups to user storage.\n *\n * @param context - The backup and sync context.\n * @param groups - The groups to push to user storage.\n * @param entropySourceId - The entropy source ID.\n * @returns A promise that resolves when the operation is complete.\n * @throws When network operations fail after maximum retry attempts.\n * @throws When messenger calls to UserStorageController fail due to authentication errors, encryption/decryption failures, or network issues.\n * @throws When JSON.stringify fails on any of the formatted group data.\n */\nexport const pushGroupToUserStorageBatch = async (\n context: BackupAndSyncContext,\n groups: AccountGroupMultichainAccountObject[],\n entropySourceId: string,\n): Promise<void> => {\n return executeWithRetry(async () => {\n const formattedGroups = groups.map((group) =>\n formatGroupForUserStorageUsage(context, group),\n );\n\n const entries: [string, string][] = formattedGroups.map((group) => [\n String(group.groupIndex),\n JSON.stringify(group),\n ]);\n\n backupAndSyncLogger(\n `Pushing groups to user storage: ${entries.map(([_, value]) => value).join(', ')}`,\n );\n\n const result = await context.messenger.call(\n 'UserStorageController:performBatchSetStorage',\n USER_STORAGE_GROUPS_FEATURE_KEY,\n entries,\n entropySourceId,\n );\n context.mutationTracker?.setRemoteWrite(true);\n return result;\n });\n};\n\n/**\n * Retrieves legacy user storage accounts for a specific entropy source ID.\n *\n * @param context - The backup and sync context.\n * @param entropySourceId - The entropy source ID to retrieve data for.\n * @returns A promise that resolves with the legacy user storage accounts.\n * @throws When network operations fail after maximum retry attempts.\n * @throws When messenger calls to UserStorageController fail due to authentication errors, encryption/decryption failures, or network issues.\n */\nexport const getAllLegacyUserStorageAccounts = async (\n context: BackupAndSyncContext,\n entropySourceId: string,\n): Promise<LegacyUserStorageSyncedAccount[]> => {\n return executeWithRetry(async () => {\n const accountsData = await context.messenger.call(\n 'UserStorageController:performGetStorageAllFeatureEntries',\n SDK.USER_STORAGE_FEATURE_NAMES.accounts,\n entropySourceId,\n );\n\n if (!accountsData) {\n return [];\n }\n\n const allAccounts = accountsData\n .map((stringifiedAccount) => {\n try {\n return parseLegacyAccountFromUserStorageResponse(stringifiedAccount);\n } catch (error) {\n backupAndSyncLogger(\n `Failed to parse legacy account data from user storage: ${toErrorMessage(error)}`,\n );\n return null;\n }\n })\n .filter(\n (account): account is LegacyUserStorageSyncedAccount =>\n account !== null,\n );\n\n backupAndSyncLogger(\n `Retrieved legacy accounts from user storage: ${JSON.stringify(allAccounts)}`,\n );\n\n return allAccounts;\n });\n};\n"]}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.executeWithRetry = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Executes a network operation with retry logic for transient failures.
|
|
6
|
+
*
|
|
7
|
+
* @param operation - The async operation to execute.
|
|
8
|
+
* @param maxRetries - Maximum number of retry attempts.
|
|
9
|
+
* @param baseDelayMs - Base delay between retries in milliseconds.
|
|
10
|
+
* @returns Promise that resolves with the operation result.
|
|
11
|
+
*/
|
|
12
|
+
async function executeWithRetry(operation, maxRetries = 3, baseDelayMs = 1000) {
|
|
13
|
+
let lastError = new Error('Unknown error');
|
|
14
|
+
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
15
|
+
try {
|
|
16
|
+
return await operation();
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
lastError = error instanceof Error ? error : new Error(String(error));
|
|
20
|
+
if (attempt === maxRetries) {
|
|
21
|
+
break; // Exit loop after final attempt
|
|
22
|
+
}
|
|
23
|
+
// Calculate exponential backoff delay
|
|
24
|
+
const delayMs = baseDelayMs * Math.pow(2, attempt);
|
|
25
|
+
// Wait before retry
|
|
26
|
+
await new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
// This will only be reached if all attempts failed
|
|
30
|
+
throw lastError;
|
|
31
|
+
}
|
|
32
|
+
exports.executeWithRetry = executeWithRetry;
|
|
33
|
+
//# sourceMappingURL=network-utils.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"network-utils.cjs","sourceRoot":"","sources":["../../../src/backup-and-sync/user-storage/network-utils.ts"],"names":[],"mappings":";;;AAAA;;;;;;;GAOG;AACI,KAAK,UAAU,gBAAgB,CACpC,SAA2B,EAC3B,UAAU,GAAG,CAAC,EACd,WAAW,GAAG,IAAI;IAElB,IAAI,SAAS,GAAU,IAAI,KAAK,CAAC,eAAe,CAAC,CAAC;IAElD,KAAK,IAAI,OAAO,GAAG,CAAC,EAAE,OAAO,IAAI,UAAU,EAAE,OAAO,EAAE,EAAE,CAAC;QACvD,IAAI,CAAC;YACH,OAAO,MAAM,SAAS,EAAE,CAAC;QAC3B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,SAAS,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;YAEtE,IAAI,OAAO,KAAK,UAAU,EAAE,CAAC;gBAC3B,MAAM,CAAC,gCAAgC;YACzC,CAAC;YAED,sCAAsC;YACtC,MAAM,OAAO,GAAG,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;YAEnD,oBAAoB;YACpB,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;QAC/D,CAAC;IACH,CAAC;IAED,mDAAmD;IACnD,MAAM,SAAS,CAAC;AAClB,CAAC;AA3BD,4CA2BC","sourcesContent":["/**\n * Executes a network operation with retry logic for transient failures.\n *\n * @param operation - The async operation to execute.\n * @param maxRetries - Maximum number of retry attempts.\n * @param baseDelayMs - Base delay between retries in milliseconds.\n * @returns Promise that resolves with the operation result.\n */\nexport async function executeWithRetry<T>(\n operation: () => Promise<T>,\n maxRetries = 3,\n baseDelayMs = 1000,\n): Promise<T> {\n let lastError: Error = new Error('Unknown error');\n\n for (let attempt = 0; attempt <= maxRetries; attempt++) {\n try {\n return await operation();\n } catch (error) {\n lastError = error instanceof Error ? error : new Error(String(error));\n\n if (attempt === maxRetries) {\n break; // Exit loop after final attempt\n }\n\n // Calculate exponential backoff delay\n const delayMs = baseDelayMs * Math.pow(2, attempt);\n\n // Wait before retry\n await new Promise((resolve) => setTimeout(resolve, delayMs));\n }\n }\n\n // This will only be reached if all attempts failed\n throw lastError;\n}\n"]}
|
|
@@ -7,4 +7,4 @@
|
|
|
7
7
|
* @returns Promise that resolves with the operation result.
|
|
8
8
|
*/
|
|
9
9
|
export declare function executeWithRetry<T>(operation: () => Promise<T>, maxRetries?: number, baseDelayMs?: number): Promise<T>;
|
|
10
|
-
//# sourceMappingURL=network-utils.d.
|
|
10
|
+
//# sourceMappingURL=network-utils.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"network-utils.d.cts","sourceRoot":"","sources":["../../../src/backup-and-sync/user-storage/network-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,wBAAsB,gBAAgB,CAAC,CAAC,EACtC,SAAS,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EAC3B,UAAU,SAAI,EACd,WAAW,SAAO,GACjB,OAAO,CAAC,CAAC,CAAC,CAuBZ"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Executes a network operation with retry logic for transient failures.
|
|
3
|
+
*
|
|
4
|
+
* @param operation - The async operation to execute.
|
|
5
|
+
* @param maxRetries - Maximum number of retry attempts.
|
|
6
|
+
* @param baseDelayMs - Base delay between retries in milliseconds.
|
|
7
|
+
* @returns Promise that resolves with the operation result.
|
|
8
|
+
*/
|
|
9
|
+
export declare function executeWithRetry<T>(operation: () => Promise<T>, maxRetries?: number, baseDelayMs?: number): Promise<T>;
|
|
10
|
+
//# sourceMappingURL=network-utils.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"network-utils.d.mts","sourceRoot":"","sources":["../../../src/backup-and-sync/user-storage/network-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,wBAAsB,gBAAgB,CAAC,CAAC,EACtC,SAAS,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EAC3B,UAAU,SAAI,EACd,WAAW,SAAO,GACjB,OAAO,CAAC,CAAC,CAAC,CAuBZ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"network-utils.mjs","sourceRoot":"","sources":["../../../src/backup-and-sync/user-storage/network-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,SAA2B,EAC3B,UAAU,GAAG,CAAC,EACd,WAAW,GAAG,IAAI;IAElB,IAAI,SAAS,GAAU,IAAI,KAAK,CAAC,eAAe,CAAC,CAAC;IAElD,KAAK,IAAI,OAAO,GAAG,CAAC,EAAE,OAAO,IAAI,UAAU,EAAE,OAAO,EAAE,EAAE,CAAC;QACvD,IAAI,CAAC;YACH,OAAO,MAAM,SAAS,EAAE,CAAC;QAC3B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,SAAS,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;YAEtE,IAAI,OAAO,KAAK,UAAU,EAAE,CAAC;gBAC3B,MAAM,CAAC,gCAAgC;YACzC,CAAC;YAED,sCAAsC;YACtC,MAAM,OAAO,GAAG,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;YAEnD,oBAAoB;YACpB,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;QAC/D,CAAC;IACH,CAAC;IAED,mDAAmD;IACnD,MAAM,SAAS,CAAC;AAClB,CAAC","sourcesContent":["/**\n * Executes a network operation with retry logic for transient failures.\n *\n * @param operation - The async operation to execute.\n * @param maxRetries - Maximum number of retry attempts.\n * @param baseDelayMs - Base delay between retries in milliseconds.\n * @returns Promise that resolves with the operation result.\n */\nexport async function executeWithRetry<T>(\n operation: () => Promise<T>,\n maxRetries = 3,\n baseDelayMs = 1000,\n): Promise<T> {\n let lastError: Error = new Error('Unknown error');\n\n for (let attempt = 0; attempt <= maxRetries; attempt++) {\n try {\n return await operation();\n } catch (error) {\n lastError = error instanceof Error ? error : new Error(String(error));\n\n if (attempt === maxRetries) {\n break; // Exit loop after final attempt\n }\n\n // Calculate exponential backoff delay\n const delayMs = baseDelayMs * Math.pow(2, attempt);\n\n // Wait before retry\n await new Promise((resolve) => setTimeout(resolve, delayMs));\n }\n }\n\n // This will only be reached if all attempts failed\n throw lastError;\n}\n"]}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.assertValidLegacyUserStorageAccount = exports.assertValidUserStorageGroup = exports.assertValidUserStorageWallet = void 0;
|
|
4
|
+
const superstruct_1 = require("@metamask/superstruct");
|
|
5
|
+
const types_js_1 = require("../types.cjs");
|
|
6
|
+
/**
|
|
7
|
+
* Formats validation error messages for user storage data.
|
|
8
|
+
*
|
|
9
|
+
* @param error - The StructError thrown during validation.
|
|
10
|
+
* @returns A formatted string of validation error messages.
|
|
11
|
+
*/
|
|
12
|
+
const formatValidationErrorMessages = (error) => {
|
|
13
|
+
const validationFailures = error
|
|
14
|
+
.failures()
|
|
15
|
+
.map(({ path, message }) => `[${path.join('.')}] ${message}`)
|
|
16
|
+
.join(', ');
|
|
17
|
+
return `Invalid user storage data: ${validationFailures}`;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Validates and asserts user storage wallet data, throwing detailed errors if invalid.
|
|
21
|
+
*
|
|
22
|
+
* @param walletData - The wallet data from user storage to validate.
|
|
23
|
+
* @throws StructError if the wallet data is invalid.
|
|
24
|
+
*/
|
|
25
|
+
function assertValidUserStorageWallet(walletData) {
|
|
26
|
+
try {
|
|
27
|
+
(0, superstruct_1.assert)(walletData, types_js_1.UserStorageSyncedWalletSchema);
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
if (error instanceof superstruct_1.StructError) {
|
|
31
|
+
throw new Error(`Invalid user storage wallet data: ${formatValidationErrorMessages(error)}`);
|
|
32
|
+
}
|
|
33
|
+
/* istanbul ignore next */
|
|
34
|
+
throw error;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.assertValidUserStorageWallet = assertValidUserStorageWallet;
|
|
38
|
+
/**
|
|
39
|
+
* Validates and asserts user storage group data, throwing detailed errors if invalid.
|
|
40
|
+
*
|
|
41
|
+
* @param groupData - The group data from user storage to validate.
|
|
42
|
+
* @throws StructError if the group data is invalid.
|
|
43
|
+
*/
|
|
44
|
+
function assertValidUserStorageGroup(groupData) {
|
|
45
|
+
try {
|
|
46
|
+
(0, superstruct_1.assert)(groupData, types_js_1.UserStorageSyncedWalletGroupSchema);
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
if (error instanceof superstruct_1.StructError) {
|
|
50
|
+
throw new Error(`Invalid user storage group data: ${formatValidationErrorMessages(error)}`);
|
|
51
|
+
}
|
|
52
|
+
/* istanbul ignore next */
|
|
53
|
+
throw error;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.assertValidUserStorageGroup = assertValidUserStorageGroup;
|
|
57
|
+
/**
|
|
58
|
+
* Validates and asserts legacy user storage account data, throwing detailed errors if invalid.
|
|
59
|
+
*
|
|
60
|
+
* @param accountData - The account data from user storage to validate.
|
|
61
|
+
* @throws StructError if the account data is invalid.
|
|
62
|
+
*/
|
|
63
|
+
function assertValidLegacyUserStorageAccount(accountData) {
|
|
64
|
+
try {
|
|
65
|
+
(0, superstruct_1.assert)(accountData, types_js_1.LegacyUserStorageSyncedAccountSchema);
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
if (error instanceof superstruct_1.StructError) {
|
|
69
|
+
throw new Error(`Invalid legacy user storage account data: ${formatValidationErrorMessages(error)}`);
|
|
70
|
+
}
|
|
71
|
+
/* istanbul ignore next */
|
|
72
|
+
throw error;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
exports.assertValidLegacyUserStorageAccount = assertValidLegacyUserStorageAccount;
|
|
76
|
+
//# sourceMappingURL=validation.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.cjs","sourceRoot":"","sources":["../../../src/backup-and-sync/user-storage/validation.ts"],"names":[],"mappings":";;;AAAA,uDAA4D;AAO5D,2CAIqB;AAErB;;;;;GAKG;AACH,MAAM,6BAA6B,GAAG,CAAC,KAAkB,EAAE,EAAE;IAC3D,MAAM,kBAAkB,GAAG,KAAK;SAC7B,QAAQ,EAAE;SACV,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,OAAO,EAAE,CAAC;SAC5D,IAAI,CAAC,IAAI,CAAC,CAAC;IACd,OAAO,8BAA8B,kBAAkB,EAAE,CAAC;AAC5D,CAAC,CAAC;AAEF;;;;;GAKG;AACH,SAAgB,4BAA4B,CAC1C,UAAmB;IAEnB,IAAI,CAAC;QACH,IAAA,oBAAM,EAAC,UAAU,EAAE,wCAA6B,CAAC,CAAC;IACpD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,yBAAW,EAAE,CAAC;YACjC,MAAM,IAAI,KAAK,CACb,qCAAqC,6BAA6B,CAAC,KAAK,CAAC,EAAE,CAC5E,CAAC;QACJ,CAAC;QACD,0BAA0B;QAC1B,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC;AAdD,oEAcC;AAED;;;;;GAKG;AACH,SAAgB,2BAA2B,CACzC,SAAkB;IAElB,IAAI,CAAC;QACH,IAAA,oBAAM,EAAC,SAAS,EAAE,6CAAkC,CAAC,CAAC;IACxD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,yBAAW,EAAE,CAAC;YACjC,MAAM,IAAI,KAAK,CACb,oCAAoC,6BAA6B,CAAC,KAAK,CAAC,EAAE,CAC3E,CAAC;QACJ,CAAC;QACD,0BAA0B;QAC1B,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC;AAdD,kEAcC;AAED;;;;;GAKG;AACH,SAAgB,mCAAmC,CACjD,WAAoB;IAEpB,IAAI,CAAC;QACH,IAAA,oBAAM,EAAC,WAAW,EAAE,+CAAoC,CAAC,CAAC;IAC5D,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,yBAAW,EAAE,CAAC;YACjC,MAAM,IAAI,KAAK,CACb,6CAA6C,6BAA6B,CAAC,KAAK,CAAC,EAAE,CACpF,CAAC;QACJ,CAAC;QACD,0BAA0B;QAC1B,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC;AAdD,kFAcC","sourcesContent":["import { assert, StructError } from '@metamask/superstruct';\n\nimport type {\n LegacyUserStorageSyncedAccount,\n UserStorageSyncedWallet,\n UserStorageSyncedWalletGroup,\n} from '../types.js';\nimport {\n UserStorageSyncedWalletSchema,\n UserStorageSyncedWalletGroupSchema,\n LegacyUserStorageSyncedAccountSchema,\n} from '../types.js';\n\n/**\n * Formats validation error messages for user storage data.\n *\n * @param error - The StructError thrown during validation.\n * @returns A formatted string of validation error messages.\n */\nconst formatValidationErrorMessages = (error: StructError) => {\n const validationFailures = error\n .failures()\n .map(({ path, message }) => `[${path.join('.')}] ${message}`)\n .join(', ');\n return `Invalid user storage data: ${validationFailures}`;\n};\n\n/**\n * Validates and asserts user storage wallet data, throwing detailed errors if invalid.\n *\n * @param walletData - The wallet data from user storage to validate.\n * @throws StructError if the wallet data is invalid.\n */\nexport function assertValidUserStorageWallet(\n walletData: unknown,\n): asserts walletData is UserStorageSyncedWallet {\n try {\n assert(walletData, UserStorageSyncedWalletSchema);\n } catch (error) {\n if (error instanceof StructError) {\n throw new Error(\n `Invalid user storage wallet data: ${formatValidationErrorMessages(error)}`,\n );\n }\n /* istanbul ignore next */\n throw error;\n }\n}\n\n/**\n * Validates and asserts user storage group data, throwing detailed errors if invalid.\n *\n * @param groupData - The group data from user storage to validate.\n * @throws StructError if the group data is invalid.\n */\nexport function assertValidUserStorageGroup(\n groupData: unknown,\n): asserts groupData is UserStorageSyncedWalletGroup {\n try {\n assert(groupData, UserStorageSyncedWalletGroupSchema);\n } catch (error) {\n if (error instanceof StructError) {\n throw new Error(\n `Invalid user storage group data: ${formatValidationErrorMessages(error)}`,\n );\n }\n /* istanbul ignore next */\n throw error;\n }\n}\n\n/**\n * Validates and asserts legacy user storage account data, throwing detailed errors if invalid.\n *\n * @param accountData - The account data from user storage to validate.\n * @throws StructError if the account data is invalid.\n */\nexport function assertValidLegacyUserStorageAccount(\n accountData: unknown,\n): asserts accountData is LegacyUserStorageSyncedAccount {\n try {\n assert(accountData, LegacyUserStorageSyncedAccountSchema);\n } catch (error) {\n if (error instanceof StructError) {\n throw new Error(\n `Invalid legacy user storage account data: ${formatValidationErrorMessages(error)}`,\n );\n }\n /* istanbul ignore next */\n throw error;\n }\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { LegacyUserStorageSyncedAccount, UserStorageSyncedWallet, UserStorageSyncedWalletGroup } from
|
|
1
|
+
import type { LegacyUserStorageSyncedAccount, UserStorageSyncedWallet, UserStorageSyncedWalletGroup } from "../types.cjs";
|
|
2
2
|
/**
|
|
3
3
|
* Validates and asserts user storage wallet data, throwing detailed errors if invalid.
|
|
4
4
|
*
|
|
@@ -20,4 +20,4 @@ export declare function assertValidUserStorageGroup(groupData: unknown): asserts
|
|
|
20
20
|
* @throws StructError if the account data is invalid.
|
|
21
21
|
*/
|
|
22
22
|
export declare function assertValidLegacyUserStorageAccount(accountData: unknown): asserts accountData is LegacyUserStorageSyncedAccount;
|
|
23
|
-
//# sourceMappingURL=validation.d.
|
|
23
|
+
//# sourceMappingURL=validation.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.d.cts","sourceRoot":"","sources":["../../../src/backup-and-sync/user-storage/validation.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,8BAA8B,EAC9B,uBAAuB,EACvB,4BAA4B,EAC7B,qBAAoB;AAqBrB;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAC1C,UAAU,EAAE,OAAO,GAClB,OAAO,CAAC,UAAU,IAAI,uBAAuB,CAY/C;AAED;;;;;GAKG;AACH,wBAAgB,2BAA2B,CACzC,SAAS,EAAE,OAAO,GACjB,OAAO,CAAC,SAAS,IAAI,4BAA4B,CAYnD;AAED;;;;;GAKG;AACH,wBAAgB,mCAAmC,CACjD,WAAW,EAAE,OAAO,GACnB,OAAO,CAAC,WAAW,IAAI,8BAA8B,CAYvD"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { LegacyUserStorageSyncedAccount, UserStorageSyncedWallet, UserStorageSyncedWalletGroup } from "../types.mjs";
|
|
2
|
+
/**
|
|
3
|
+
* Validates and asserts user storage wallet data, throwing detailed errors if invalid.
|
|
4
|
+
*
|
|
5
|
+
* @param walletData - The wallet data from user storage to validate.
|
|
6
|
+
* @throws StructError if the wallet data is invalid.
|
|
7
|
+
*/
|
|
8
|
+
export declare function assertValidUserStorageWallet(walletData: unknown): asserts walletData is UserStorageSyncedWallet;
|
|
9
|
+
/**
|
|
10
|
+
* Validates and asserts user storage group data, throwing detailed errors if invalid.
|
|
11
|
+
*
|
|
12
|
+
* @param groupData - The group data from user storage to validate.
|
|
13
|
+
* @throws StructError if the group data is invalid.
|
|
14
|
+
*/
|
|
15
|
+
export declare function assertValidUserStorageGroup(groupData: unknown): asserts groupData is UserStorageSyncedWalletGroup;
|
|
16
|
+
/**
|
|
17
|
+
* Validates and asserts legacy user storage account data, throwing detailed errors if invalid.
|
|
18
|
+
*
|
|
19
|
+
* @param accountData - The account data from user storage to validate.
|
|
20
|
+
* @throws StructError if the account data is invalid.
|
|
21
|
+
*/
|
|
22
|
+
export declare function assertValidLegacyUserStorageAccount(accountData: unknown): asserts accountData is LegacyUserStorageSyncedAccount;
|
|
23
|
+
//# sourceMappingURL=validation.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.d.mts","sourceRoot":"","sources":["../../../src/backup-and-sync/user-storage/validation.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,8BAA8B,EAC9B,uBAAuB,EACvB,4BAA4B,EAC7B,qBAAoB;AAqBrB;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAC1C,UAAU,EAAE,OAAO,GAClB,OAAO,CAAC,UAAU,IAAI,uBAAuB,CAY/C;AAED;;;;;GAKG;AACH,wBAAgB,2BAA2B,CACzC,SAAS,EAAE,OAAO,GACjB,OAAO,CAAC,SAAS,IAAI,4BAA4B,CAYnD;AAED;;;;;GAKG;AACH,wBAAgB,mCAAmC,CACjD,WAAW,EAAE,OAAO,GACnB,OAAO,CAAC,WAAW,IAAI,8BAA8B,CAYvD"}
|