@metamask-previews/profile-sync-controller 16.0.0-preview-39fa8d37 → 16.0.0-preview-510657d5
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 +7 -0
- package/dist/controllers/authentication/AuthenticationController.cjs +60 -24
- package/dist/controllers/authentication/AuthenticationController.cjs.map +1 -1
- package/dist/controllers/authentication/AuthenticationController.d.cts +6 -4
- package/dist/controllers/authentication/AuthenticationController.d.cts.map +1 -1
- package/dist/controllers/authentication/AuthenticationController.d.mts +6 -4
- package/dist/controllers/authentication/AuthenticationController.d.mts.map +1 -1
- package/dist/controllers/authentication/AuthenticationController.mjs +61 -25
- package/dist/controllers/authentication/AuthenticationController.mjs.map +1 -1
- package/dist/controllers/authentication/auth-snap-requests.cjs +25 -4
- package/dist/controllers/authentication/auth-snap-requests.cjs.map +1 -1
- package/dist/controllers/authentication/auth-snap-requests.d.cts +12 -2
- package/dist/controllers/authentication/auth-snap-requests.d.cts.map +1 -1
- package/dist/controllers/authentication/auth-snap-requests.d.mts +12 -2
- package/dist/controllers/authentication/auth-snap-requests.d.mts.map +1 -1
- package/dist/controllers/authentication/auth-snap-requests.mjs +23 -3
- package/dist/controllers/authentication/auth-snap-requests.mjs.map +1 -1
- package/dist/controllers/authentication/mocks/mockResponses.cjs +36 -3
- package/dist/controllers/authentication/mocks/mockResponses.cjs.map +1 -1
- package/dist/controllers/authentication/mocks/mockResponses.d.cts +7 -5
- package/dist/controllers/authentication/mocks/mockResponses.d.cts.map +1 -1
- package/dist/controllers/authentication/mocks/mockResponses.d.mts +7 -5
- package/dist/controllers/authentication/mocks/mockResponses.d.mts.map +1 -1
- package/dist/controllers/authentication/mocks/mockResponses.mjs +36 -3
- package/dist/controllers/authentication/mocks/mockResponses.mjs.map +1 -1
- package/dist/controllers/user-storage/UserStorageController.cjs +133 -30
- package/dist/controllers/user-storage/UserStorageController.cjs.map +1 -1
- package/dist/controllers/user-storage/UserStorageController.d.cts +62 -10
- package/dist/controllers/user-storage/UserStorageController.d.cts.map +1 -1
- package/dist/controllers/user-storage/UserStorageController.d.mts +62 -10
- package/dist/controllers/user-storage/UserStorageController.d.mts.map +1 -1
- package/dist/controllers/user-storage/UserStorageController.mjs +130 -27
- package/dist/controllers/user-storage/UserStorageController.mjs.map +1 -1
- package/dist/controllers/user-storage/account-syncing/controller-integration.cjs +22 -26
- package/dist/controllers/user-storage/account-syncing/controller-integration.cjs.map +1 -1
- package/dist/controllers/user-storage/account-syncing/controller-integration.d.cts +5 -2
- package/dist/controllers/user-storage/account-syncing/controller-integration.d.cts.map +1 -1
- package/dist/controllers/user-storage/account-syncing/controller-integration.d.mts +5 -2
- package/dist/controllers/user-storage/account-syncing/controller-integration.d.mts.map +1 -1
- package/dist/controllers/user-storage/account-syncing/controller-integration.mjs +23 -27
- package/dist/controllers/user-storage/account-syncing/controller-integration.mjs.map +1 -1
- package/dist/controllers/user-storage/account-syncing/setup-subscriptions.cjs +3 -13
- package/dist/controllers/user-storage/account-syncing/setup-subscriptions.cjs.map +1 -1
- package/dist/controllers/user-storage/account-syncing/setup-subscriptions.d.cts.map +1 -1
- package/dist/controllers/user-storage/account-syncing/setup-subscriptions.d.mts.map +1 -1
- package/dist/controllers/user-storage/account-syncing/setup-subscriptions.mjs +3 -13
- package/dist/controllers/user-storage/account-syncing/setup-subscriptions.mjs.map +1 -1
- package/dist/controllers/user-storage/account-syncing/sync-utils.cjs +16 -7
- package/dist/controllers/user-storage/account-syncing/sync-utils.cjs.map +1 -1
- package/dist/controllers/user-storage/account-syncing/sync-utils.d.cts +6 -2
- package/dist/controllers/user-storage/account-syncing/sync-utils.d.cts.map +1 -1
- package/dist/controllers/user-storage/account-syncing/sync-utils.d.mts +6 -2
- package/dist/controllers/user-storage/account-syncing/sync-utils.d.mts.map +1 -1
- package/dist/controllers/user-storage/account-syncing/sync-utils.mjs +16 -7
- package/dist/controllers/user-storage/account-syncing/sync-utils.mjs.map +1 -1
- package/dist/controllers/user-storage/account-syncing/utils.cjs +1 -42
- package/dist/controllers/user-storage/account-syncing/utils.cjs.map +1 -1
- package/dist/controllers/user-storage/account-syncing/utils.d.cts +1 -18
- package/dist/controllers/user-storage/account-syncing/utils.d.cts.map +1 -1
- package/dist/controllers/user-storage/account-syncing/utils.d.mts +1 -18
- package/dist/controllers/user-storage/account-syncing/utils.d.mts.map +1 -1
- package/dist/controllers/user-storage/account-syncing/utils.mjs +0 -39
- package/dist/controllers/user-storage/account-syncing/utils.mjs.map +1 -1
- package/dist/controllers/user-storage/constants.cjs +1 -0
- package/dist/controllers/user-storage/constants.cjs.map +1 -1
- package/dist/controllers/user-storage/constants.d.cts +1 -0
- package/dist/controllers/user-storage/constants.d.cts.map +1 -1
- package/dist/controllers/user-storage/constants.d.mts +1 -0
- package/dist/controllers/user-storage/constants.d.mts.map +1 -1
- package/dist/controllers/user-storage/constants.mjs +1 -0
- package/dist/controllers/user-storage/constants.mjs.map +1 -1
- package/dist/controllers/user-storage/contact-syncing/constants.cjs +12 -0
- package/dist/controllers/user-storage/contact-syncing/constants.cjs.map +1 -0
- package/dist/controllers/user-storage/contact-syncing/constants.d.cts +9 -0
- package/dist/controllers/user-storage/contact-syncing/constants.d.cts.map +1 -0
- package/dist/controllers/user-storage/contact-syncing/constants.d.mts +9 -0
- package/dist/controllers/user-storage/contact-syncing/constants.d.mts.map +1 -0
- package/dist/controllers/user-storage/contact-syncing/constants.mjs +9 -0
- package/dist/controllers/user-storage/contact-syncing/constants.mjs.map +1 -0
- package/dist/controllers/user-storage/contact-syncing/controller-integration.cjs +299 -0
- package/dist/controllers/user-storage/contact-syncing/controller-integration.cjs.map +1 -0
- package/dist/controllers/user-storage/contact-syncing/controller-integration.d.cts +44 -0
- package/dist/controllers/user-storage/contact-syncing/controller-integration.d.cts.map +1 -0
- package/dist/controllers/user-storage/contact-syncing/controller-integration.d.mts +44 -0
- package/dist/controllers/user-storage/contact-syncing/controller-integration.d.mts.map +1 -0
- package/dist/controllers/user-storage/contact-syncing/controller-integration.mjs +293 -0
- package/dist/controllers/user-storage/contact-syncing/controller-integration.mjs.map +1 -0
- package/dist/controllers/user-storage/contact-syncing/setup-subscriptions.cjs +50 -0
- package/dist/controllers/user-storage/contact-syncing/setup-subscriptions.cjs.map +1 -0
- package/dist/controllers/user-storage/contact-syncing/setup-subscriptions.d.cts +8 -0
- package/dist/controllers/user-storage/contact-syncing/setup-subscriptions.d.cts.map +1 -0
- package/dist/controllers/user-storage/contact-syncing/setup-subscriptions.d.mts +8 -0
- package/dist/controllers/user-storage/contact-syncing/setup-subscriptions.d.mts.map +1 -0
- package/dist/controllers/user-storage/contact-syncing/setup-subscriptions.mjs +46 -0
- package/dist/controllers/user-storage/contact-syncing/setup-subscriptions.mjs.map +1 -0
- package/dist/controllers/user-storage/contact-syncing/sync-utils.cjs +23 -0
- package/dist/controllers/user-storage/contact-syncing/sync-utils.cjs.map +1 -0
- package/dist/controllers/user-storage/contact-syncing/sync-utils.d.cts +9 -0
- package/dist/controllers/user-storage/contact-syncing/sync-utils.d.cts.map +1 -0
- package/dist/controllers/user-storage/contact-syncing/sync-utils.d.mts +9 -0
- package/dist/controllers/user-storage/contact-syncing/sync-utils.d.mts.map +1 -0
- package/dist/controllers/user-storage/contact-syncing/sync-utils.mjs +19 -0
- package/dist/controllers/user-storage/contact-syncing/sync-utils.mjs.map +1 -0
- package/dist/controllers/user-storage/contact-syncing/types.cjs +3 -0
- package/dist/controllers/user-storage/contact-syncing/types.cjs.map +1 -0
- package/dist/controllers/user-storage/contact-syncing/types.d.cts +35 -0
- package/dist/controllers/user-storage/contact-syncing/types.d.cts.map +1 -0
- package/dist/controllers/user-storage/contact-syncing/types.d.mts +35 -0
- package/dist/controllers/user-storage/contact-syncing/types.d.mts.map +1 -0
- package/dist/controllers/user-storage/contact-syncing/types.mjs +2 -0
- package/dist/controllers/user-storage/contact-syncing/types.mjs.map +1 -0
- package/dist/controllers/user-storage/contact-syncing/utils.cjs +66 -0
- package/dist/controllers/user-storage/contact-syncing/utils.cjs.map +1 -0
- package/dist/controllers/user-storage/contact-syncing/utils.d.cts +37 -0
- package/dist/controllers/user-storage/contact-syncing/utils.d.cts.map +1 -0
- package/dist/controllers/user-storage/contact-syncing/utils.d.mts +37 -0
- package/dist/controllers/user-storage/contact-syncing/utils.d.mts.map +1 -0
- package/dist/controllers/user-storage/contact-syncing/utils.mjs +60 -0
- package/dist/controllers/user-storage/contact-syncing/utils.mjs.map +1 -0
- package/dist/sdk/authentication-jwt-bearer/flow-siwe.cjs.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/flow-siwe.d.cts.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/flow-siwe.d.mts.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/flow-siwe.mjs.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/flow-srp.cjs +22 -22
- package/dist/sdk/authentication-jwt-bearer/flow-srp.cjs.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/flow-srp.d.cts +4 -4
- package/dist/sdk/authentication-jwt-bearer/flow-srp.d.cts.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/flow-srp.d.mts +4 -4
- package/dist/sdk/authentication-jwt-bearer/flow-srp.d.mts.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/flow-srp.mjs +22 -22
- package/dist/sdk/authentication-jwt-bearer/flow-srp.mjs.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/services.cjs.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/services.d.cts.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/services.d.mts.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/services.mjs.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/types.cjs.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/types.d.cts +8 -8
- package/dist/sdk/authentication-jwt-bearer/types.d.cts.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/types.d.mts +8 -8
- package/dist/sdk/authentication-jwt-bearer/types.d.mts.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/types.mjs.map +1 -1
- package/dist/sdk/authentication.cjs +8 -11
- package/dist/sdk/authentication.cjs.map +1 -1
- package/dist/sdk/authentication.d.cts +4 -4
- package/dist/sdk/authentication.d.cts.map +1 -1
- package/dist/sdk/authentication.d.mts +4 -4
- package/dist/sdk/authentication.d.mts.map +1 -1
- package/dist/sdk/authentication.mjs +8 -11
- package/dist/sdk/authentication.mjs.map +1 -1
- package/dist/sdk/user-storage.cjs +38 -32
- package/dist/sdk/user-storage.cjs.map +1 -1
- package/dist/sdk/user-storage.d.cts +4 -3
- package/dist/sdk/user-storage.d.cts.map +1 -1
- package/dist/sdk/user-storage.d.mts +4 -3
- package/dist/sdk/user-storage.d.mts.map +1 -1
- package/dist/sdk/user-storage.mjs +38 -32
- package/dist/sdk/user-storage.mjs.map +1 -1
- package/dist/sdk/utils/messaging-signing-snap-requests.cjs +16 -4
- package/dist/sdk/utils/messaging-signing-snap-requests.cjs.map +1 -1
- package/dist/sdk/utils/messaging-signing-snap-requests.d.cts +2 -2
- package/dist/sdk/utils/messaging-signing-snap-requests.d.cts.map +1 -1
- package/dist/sdk/utils/messaging-signing-snap-requests.d.mts +2 -2
- package/dist/sdk/utils/messaging-signing-snap-requests.d.mts.map +1 -1
- package/dist/sdk/utils/messaging-signing-snap-requests.mjs +16 -4
- package/dist/sdk/utils/messaging-signing-snap-requests.mjs.map +1 -1
- package/dist/shared/storage-schema.cjs +4 -7
- package/dist/shared/storage-schema.cjs.map +1 -1
- package/dist/shared/storage-schema.d.cts +2 -1
- package/dist/shared/storage-schema.d.cts.map +1 -1
- package/dist/shared/storage-schema.d.mts +2 -1
- package/dist/shared/storage-schema.d.mts.map +1 -1
- package/dist/shared/storage-schema.mjs +3 -5
- package/dist/shared/storage-schema.mjs.map +1 -1
- package/package.json +2 -2
|
@@ -7,19 +7,9 @@ import { canPerformAccountSyncing } from "./sync-utils.mjs";
|
|
|
7
7
|
*/
|
|
8
8
|
export function setupAccountSyncingSubscriptions(options) {
|
|
9
9
|
const { getMessenger, getUserStorageControllerInstance } = options;
|
|
10
|
-
|
|
11
|
-
//
|
|
12
|
-
async (account) => {
|
|
13
|
-
if (!canPerformAccountSyncing(options) ||
|
|
14
|
-
!getUserStorageControllerInstance().state
|
|
15
|
-
.hasAccountSyncingSyncedAtLeastOnce) {
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
await saveInternalAccountToUserStorage(account, options);
|
|
19
|
-
});
|
|
20
|
-
getMessenger().subscribe('AccountsController:accountRenamed',
|
|
21
|
-
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
22
|
-
async (account) => {
|
|
10
|
+
// We don't listen to `AccountsController:accountAdded`
|
|
11
|
+
// because it publishes `AccountsController:accountRenamed` in any case.
|
|
12
|
+
getMessenger().subscribe('AccountsController:accountRenamed', async (account) => {
|
|
23
13
|
if (!canPerformAccountSyncing(options) ||
|
|
24
14
|
!getUserStorageControllerInstance().state
|
|
25
15
|
.hasAccountSyncingSyncedAtLeastOnce) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup-subscriptions.mjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/account-syncing/setup-subscriptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gCAAgC,EAAE,qCAAiC;AAC5E,OAAO,EAAE,wBAAwB,EAAE,yBAAqB;AAGxD;;;;GAIG;AACH,MAAM,UAAU,gCAAgC,CAC9C,OAA8B;IAE9B,MAAM,EAAE,YAAY,EAAE,gCAAgC,EAAE,GAAG,OAAO,CAAC;IAEnE,
|
|
1
|
+
{"version":3,"file":"setup-subscriptions.mjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/account-syncing/setup-subscriptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gCAAgC,EAAE,qCAAiC;AAC5E,OAAO,EAAE,wBAAwB,EAAE,yBAAqB;AAGxD;;;;GAIG;AACH,MAAM,UAAU,gCAAgC,CAC9C,OAA8B;IAE9B,MAAM,EAAE,YAAY,EAAE,gCAAgC,EAAE,GAAG,OAAO,CAAC;IAEnE,uDAAuD;IACvD,wEAAwE;IACxE,YAAY,EAAE,CAAC,SAAS,CACtB,mCAAmC,EAEnC,KAAK,EAAE,OAAO,EAAE,EAAE;QAChB,IACE,CAAC,wBAAwB,CAAC,OAAO,CAAC;YAClC,CAAC,gCAAgC,EAAE,CAAC,KAAK;iBACtC,kCAAkC,EACrC;YACA,OAAO;SACR;QAED,MAAM,gCAAgC,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC3D,CAAC,CACF,CAAC;AACJ,CAAC","sourcesContent":["import { saveInternalAccountToUserStorage } from './controller-integration';\nimport { canPerformAccountSyncing } from './sync-utils';\nimport type { AccountSyncingOptions } from './types';\n\n/**\n * Initialize and setup events to listen to for account syncing\n *\n * @param options - parameters used for initializing and enabling account syncing\n */\nexport function setupAccountSyncingSubscriptions(\n options: AccountSyncingOptions,\n) {\n const { getMessenger, getUserStorageControllerInstance } = options;\n\n // We don't listen to `AccountsController:accountAdded`\n // because it publishes `AccountsController:accountRenamed` in any case.\n getMessenger().subscribe(\n 'AccountsController:accountRenamed',\n\n async (account) => {\n if (\n !canPerformAccountSyncing(options) ||\n !getUserStorageControllerInstance().state\n .hasAccountSyncingSyncedAtLeastOnce\n ) {\n return;\n }\n\n await saveInternalAccountToUserStorage(account, options);\n },\n );\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getUserStorageAccountsList = exports.getInternalAccountsList = exports.canPerformAccountSyncing = void 0;
|
|
4
|
-
const
|
|
4
|
+
const keyring_controller_1 = require("@metamask/keyring-controller");
|
|
5
5
|
const storage_schema_1 = require("../../../shared/storage-schema.cjs");
|
|
6
6
|
/**
|
|
7
7
|
* Checks if account syncing can be performed based on a set of conditions
|
|
@@ -28,24 +28,33 @@ exports.canPerformAccountSyncing = canPerformAccountSyncing;
|
|
|
28
28
|
* and are from the HD keyring
|
|
29
29
|
*
|
|
30
30
|
* @param options - parameters used for getting the list of internal accounts
|
|
31
|
+
* @param entropySourceId - The entropy source ID used to derive the key,
|
|
32
|
+
* when multiple sources are available (Multi-SRP).
|
|
31
33
|
* @returns the list of internal accounts
|
|
32
34
|
*/
|
|
33
|
-
async function getInternalAccountsList(options) {
|
|
35
|
+
async function getInternalAccountsList(options, entropySourceId) {
|
|
34
36
|
const { getMessenger } = options;
|
|
35
|
-
|
|
36
|
-
const
|
|
37
|
-
|
|
37
|
+
let internalAccountsList = getMessenger().call('AccountsController:listAccounts');
|
|
38
|
+
const doEachInternalAccountHaveEntropySource = internalAccountsList.every((account) => Boolean(account.options.entropySource));
|
|
39
|
+
if (!doEachInternalAccountHaveEntropySource) {
|
|
40
|
+
await getMessenger().call('AccountsController:updateAccounts');
|
|
41
|
+
internalAccountsList = getMessenger().call('AccountsController:listAccounts');
|
|
42
|
+
}
|
|
43
|
+
return internalAccountsList.filter((account) => entropySourceId === account.options.entropySource &&
|
|
44
|
+
account.metadata.keyring.type === String(keyring_controller_1.KeyringTypes.hd));
|
|
38
45
|
}
|
|
39
46
|
exports.getInternalAccountsList = getInternalAccountsList;
|
|
40
47
|
/**
|
|
41
48
|
* Get the list of user storage accounts
|
|
42
49
|
*
|
|
43
50
|
* @param options - parameters used for getting the list of user storage accounts
|
|
51
|
+
* @param entropySourceId - The entropy source ID used to derive the storage key,
|
|
52
|
+
* when multiple sources are available (Multi-SRP).
|
|
44
53
|
* @returns the list of user storage accounts
|
|
45
54
|
*/
|
|
46
|
-
async function getUserStorageAccountsList(options) {
|
|
55
|
+
async function getUserStorageAccountsList(options, entropySourceId) {
|
|
47
56
|
const { getUserStorageControllerInstance } = options;
|
|
48
|
-
const rawAccountsListResponse = await getUserStorageControllerInstance().performGetStorageAllFeatureEntries(storage_schema_1.USER_STORAGE_FEATURE_NAMES.accounts);
|
|
57
|
+
const rawAccountsListResponse = await getUserStorageControllerInstance().performGetStorageAllFeatureEntries(storage_schema_1.USER_STORAGE_FEATURE_NAMES.accounts, entropySourceId);
|
|
49
58
|
return (rawAccountsListResponse?.map((rawAccount) => JSON.parse(rawAccount)) ?? null);
|
|
50
59
|
}
|
|
51
60
|
exports.getUserStorageAccountsList = getUserStorageAccountsList;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync-utils.cjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/account-syncing/sync-utils.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"sync-utils.cjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/account-syncing/sync-utils.ts"],"names":[],"mappings":";;;AAAA,qEAA4D;AAI5D,uEAA4E;AAE5E;;;;;GAKG;AACH,SAAgB,wBAAwB,CACtC,OAA8B;IAE9B,MAAM,EAAE,YAAY,EAAE,gCAAgC,EAAE,GAAG,OAAO,CAAC;IAEnE,MAAM,EACJ,sBAAsB,EACtB,uBAAuB,EACvB,0BAA0B,GAC3B,GAAG,gCAAgC,EAAE,CAAC,KAAK,CAAC;IAC7C,MAAM,aAAa,GAAG,YAAY,EAAE,CAAC,IAAI,CACvC,qCAAqC,CACtC,CAAC;IAEF,IACE,CAAC,sBAAsB;QACvB,CAAC,uBAAuB;QACxB,CAAC,aAAa;QACd,0BAA0B,EAC1B;QACA,OAAO,KAAK,CAAC;KACd;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAxBD,4DAwBC;AAED;;;;;;;;;GASG;AACI,KAAK,UAAU,uBAAuB,CAC3C,OAA8B,EAC9B,eAAuB;IAEvB,MAAM,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC;IAEjC,IAAI,oBAAoB,GAAG,YAAY,EAAE,CAAC,IAAI,CAC5C,iCAAiC,CAClC,CAAC;IAEF,MAAM,sCAAsC,GAAG,oBAAoB,CAAC,KAAK,CACvE,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,CACpD,CAAC;IAEF,IAAI,CAAC,sCAAsC,EAAE;QAC3C,MAAM,YAAY,EAAE,CAAC,IAAI,CAAC,mCAAmC,CAAC,CAAC;QAC/D,oBAAoB,GAAG,YAAY,EAAE,CAAC,IAAI,CACxC,iCAAiC,CAClC,CAAC;KACH;IAED,OAAO,oBAAoB,CAAC,MAAM,CAChC,CAAC,OAAO,EAAE,EAAE,CACV,eAAe,KAAK,OAAO,CAAC,OAAO,CAAC,aAAa;QACjD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,KAAK,MAAM,CAAC,iCAAY,CAAC,EAAE,CAAC,CAC5D,CAAC;AACJ,CAAC;AA1BD,0DA0BC;AAED;;;;;;;GAOG;AACI,KAAK,UAAU,0BAA0B,CAC9C,OAA8B,EAC9B,eAAwB;IAExB,MAAM,EAAE,gCAAgC,EAAE,GAAG,OAAO,CAAC;IAErD,MAAM,uBAAuB,GAC3B,MAAM,gCAAgC,EAAE,CAAC,kCAAkC,CACzE,2CAA0B,CAAC,QAAQ,EACnC,eAAe,CAChB,CAAC;IAEJ,OAAO,CACL,uBAAuB,EAAE,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI,IAAI,CAC7E,CAAC;AACJ,CAAC;AAfD,gEAeC","sourcesContent":["import { KeyringTypes } from '@metamask/keyring-controller';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\n\nimport type { AccountSyncingOptions, UserStorageAccount } from './types';\nimport { USER_STORAGE_FEATURE_NAMES } from '../../../shared/storage-schema';\n\n/**\n * Checks if account syncing can be performed based on a set of conditions\n *\n * @param options - parameters used for checking if account syncing can be performed\n * @returns Returns true if account syncing can be performed, false otherwise.\n */\nexport function canPerformAccountSyncing(\n options: AccountSyncingOptions,\n): boolean {\n const { getMessenger, getUserStorageControllerInstance } = options;\n\n const {\n isBackupAndSyncEnabled,\n isAccountSyncingEnabled,\n isAccountSyncingInProgress,\n } = getUserStorageControllerInstance().state;\n const isAuthEnabled = getMessenger().call(\n 'AuthenticationController:isSignedIn',\n );\n\n if (\n !isBackupAndSyncEnabled ||\n !isAccountSyncingEnabled ||\n !isAuthEnabled ||\n isAccountSyncingInProgress\n ) {\n return false;\n }\n\n return true;\n}\n\n/**\n * Get the list of internal accounts\n * This function returns only the internal accounts that are from the primary SRP\n * and are from the HD keyring\n *\n * @param options - parameters used for getting the list of internal accounts\n * @param entropySourceId - The entropy source ID used to derive the key,\n * when multiple sources are available (Multi-SRP).\n * @returns the list of internal accounts\n */\nexport async function getInternalAccountsList(\n options: AccountSyncingOptions,\n entropySourceId: string,\n): Promise<InternalAccount[]> {\n const { getMessenger } = options;\n\n let internalAccountsList = getMessenger().call(\n 'AccountsController:listAccounts',\n );\n\n const doEachInternalAccountHaveEntropySource = internalAccountsList.every(\n (account) => Boolean(account.options.entropySource),\n );\n\n if (!doEachInternalAccountHaveEntropySource) {\n await getMessenger().call('AccountsController:updateAccounts');\n internalAccountsList = getMessenger().call(\n 'AccountsController:listAccounts',\n );\n }\n\n return internalAccountsList.filter(\n (account) =>\n entropySourceId === account.options.entropySource &&\n account.metadata.keyring.type === String(KeyringTypes.hd), // sync only EVM accounts until we support multichain accounts\n );\n}\n\n/**\n * Get the list of user storage accounts\n *\n * @param options - parameters used for getting the list of user storage accounts\n * @param entropySourceId - The entropy source ID used to derive the storage key,\n * when multiple sources are available (Multi-SRP).\n * @returns the list of user storage accounts\n */\nexport async function getUserStorageAccountsList(\n options: AccountSyncingOptions,\n entropySourceId?: string,\n): Promise<UserStorageAccount[] | null> {\n const { getUserStorageControllerInstance } = options;\n\n const rawAccountsListResponse =\n await getUserStorageControllerInstance().performGetStorageAllFeatureEntries(\n USER_STORAGE_FEATURE_NAMES.accounts,\n entropySourceId,\n );\n\n return (\n rawAccountsListResponse?.map((rawAccount) => JSON.parse(rawAccount)) ?? null\n );\n}\n"]}
|
|
@@ -13,14 +13,18 @@ export declare function canPerformAccountSyncing(options: AccountSyncingOptions)
|
|
|
13
13
|
* and are from the HD keyring
|
|
14
14
|
*
|
|
15
15
|
* @param options - parameters used for getting the list of internal accounts
|
|
16
|
+
* @param entropySourceId - The entropy source ID used to derive the key,
|
|
17
|
+
* when multiple sources are available (Multi-SRP).
|
|
16
18
|
* @returns the list of internal accounts
|
|
17
19
|
*/
|
|
18
|
-
export declare function getInternalAccountsList(options: AccountSyncingOptions): Promise<InternalAccount[]>;
|
|
20
|
+
export declare function getInternalAccountsList(options: AccountSyncingOptions, entropySourceId: string): Promise<InternalAccount[]>;
|
|
19
21
|
/**
|
|
20
22
|
* Get the list of user storage accounts
|
|
21
23
|
*
|
|
22
24
|
* @param options - parameters used for getting the list of user storage accounts
|
|
25
|
+
* @param entropySourceId - The entropy source ID used to derive the storage key,
|
|
26
|
+
* when multiple sources are available (Multi-SRP).
|
|
23
27
|
* @returns the list of user storage accounts
|
|
24
28
|
*/
|
|
25
|
-
export declare function getUserStorageAccountsList(options: AccountSyncingOptions): Promise<UserStorageAccount[] | null>;
|
|
29
|
+
export declare function getUserStorageAccountsList(options: AccountSyncingOptions, entropySourceId?: string): Promise<UserStorageAccount[] | null>;
|
|
26
30
|
//# sourceMappingURL=sync-utils.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync-utils.d.cts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/account-syncing/sync-utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sync-utils.d.cts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/account-syncing/sync-utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AAEtE,OAAO,KAAK,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,oBAAgB;AAGzE;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAsBT;AAED;;;;;;;;;GASG;AACH,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE,qBAAqB,EAC9B,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,eAAe,EAAE,CAAC,CAuB5B;AAED;;;;;;;GAOG;AACH,wBAAsB,0BAA0B,CAC9C,OAAO,EAAE,qBAAqB,EAC9B,eAAe,CAAC,EAAE,MAAM,GACvB,OAAO,CAAC,kBAAkB,EAAE,GAAG,IAAI,CAAC,CAYtC"}
|
|
@@ -13,14 +13,18 @@ export declare function canPerformAccountSyncing(options: AccountSyncingOptions)
|
|
|
13
13
|
* and are from the HD keyring
|
|
14
14
|
*
|
|
15
15
|
* @param options - parameters used for getting the list of internal accounts
|
|
16
|
+
* @param entropySourceId - The entropy source ID used to derive the key,
|
|
17
|
+
* when multiple sources are available (Multi-SRP).
|
|
16
18
|
* @returns the list of internal accounts
|
|
17
19
|
*/
|
|
18
|
-
export declare function getInternalAccountsList(options: AccountSyncingOptions): Promise<InternalAccount[]>;
|
|
20
|
+
export declare function getInternalAccountsList(options: AccountSyncingOptions, entropySourceId: string): Promise<InternalAccount[]>;
|
|
19
21
|
/**
|
|
20
22
|
* Get the list of user storage accounts
|
|
21
23
|
*
|
|
22
24
|
* @param options - parameters used for getting the list of user storage accounts
|
|
25
|
+
* @param entropySourceId - The entropy source ID used to derive the storage key,
|
|
26
|
+
* when multiple sources are available (Multi-SRP).
|
|
23
27
|
* @returns the list of user storage accounts
|
|
24
28
|
*/
|
|
25
|
-
export declare function getUserStorageAccountsList(options: AccountSyncingOptions): Promise<UserStorageAccount[] | null>;
|
|
29
|
+
export declare function getUserStorageAccountsList(options: AccountSyncingOptions, entropySourceId?: string): Promise<UserStorageAccount[] | null>;
|
|
26
30
|
//# sourceMappingURL=sync-utils.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync-utils.d.mts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/account-syncing/sync-utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sync-utils.d.mts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/account-syncing/sync-utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AAEtE,OAAO,KAAK,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,oBAAgB;AAGzE;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAsBT;AAED;;;;;;;;;GASG;AACH,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE,qBAAqB,EAC9B,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,eAAe,EAAE,CAAC,CAuB5B;AAED;;;;;;;GAOG;AACH,wBAAsB,0BAA0B,CAC9C,OAAO,EAAE,qBAAqB,EAC9B,eAAe,CAAC,EAAE,MAAM,GACvB,OAAO,CAAC,kBAAkB,EAAE,GAAG,IAAI,CAAC,CAYtC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { KeyringTypes } from "@metamask/keyring-controller";
|
|
2
2
|
import { USER_STORAGE_FEATURE_NAMES } from "../../../shared/storage-schema.mjs";
|
|
3
3
|
/**
|
|
4
4
|
* Checks if account syncing can be performed based on a set of conditions
|
|
@@ -24,23 +24,32 @@ export function canPerformAccountSyncing(options) {
|
|
|
24
24
|
* and are from the HD keyring
|
|
25
25
|
*
|
|
26
26
|
* @param options - parameters used for getting the list of internal accounts
|
|
27
|
+
* @param entropySourceId - The entropy source ID used to derive the key,
|
|
28
|
+
* when multiple sources are available (Multi-SRP).
|
|
27
29
|
* @returns the list of internal accounts
|
|
28
30
|
*/
|
|
29
|
-
export async function getInternalAccountsList(options) {
|
|
31
|
+
export async function getInternalAccountsList(options, entropySourceId) {
|
|
30
32
|
const { getMessenger } = options;
|
|
31
|
-
|
|
32
|
-
const
|
|
33
|
-
|
|
33
|
+
let internalAccountsList = getMessenger().call('AccountsController:listAccounts');
|
|
34
|
+
const doEachInternalAccountHaveEntropySource = internalAccountsList.every((account) => Boolean(account.options.entropySource));
|
|
35
|
+
if (!doEachInternalAccountHaveEntropySource) {
|
|
36
|
+
await getMessenger().call('AccountsController:updateAccounts');
|
|
37
|
+
internalAccountsList = getMessenger().call('AccountsController:listAccounts');
|
|
38
|
+
}
|
|
39
|
+
return internalAccountsList.filter((account) => entropySourceId === account.options.entropySource &&
|
|
40
|
+
account.metadata.keyring.type === String(KeyringTypes.hd));
|
|
34
41
|
}
|
|
35
42
|
/**
|
|
36
43
|
* Get the list of user storage accounts
|
|
37
44
|
*
|
|
38
45
|
* @param options - parameters used for getting the list of user storage accounts
|
|
46
|
+
* @param entropySourceId - The entropy source ID used to derive the storage key,
|
|
47
|
+
* when multiple sources are available (Multi-SRP).
|
|
39
48
|
* @returns the list of user storage accounts
|
|
40
49
|
*/
|
|
41
|
-
export async function getUserStorageAccountsList(options) {
|
|
50
|
+
export async function getUserStorageAccountsList(options, entropySourceId) {
|
|
42
51
|
const { getUserStorageControllerInstance } = options;
|
|
43
|
-
const rawAccountsListResponse = await getUserStorageControllerInstance().performGetStorageAllFeatureEntries(USER_STORAGE_FEATURE_NAMES.accounts);
|
|
52
|
+
const rawAccountsListResponse = await getUserStorageControllerInstance().performGetStorageAllFeatureEntries(USER_STORAGE_FEATURE_NAMES.accounts, entropySourceId);
|
|
44
53
|
return (rawAccountsListResponse?.map((rawAccount) => JSON.parse(rawAccount)) ?? null);
|
|
45
54
|
}
|
|
46
55
|
//# sourceMappingURL=sync-utils.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync-utils.mjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/account-syncing/sync-utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sync-utils.mjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/account-syncing/sync-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,qCAAqC;AAI5D,OAAO,EAAE,0BAA0B,EAAE,2CAAuC;AAE5E;;;;;GAKG;AACH,MAAM,UAAU,wBAAwB,CACtC,OAA8B;IAE9B,MAAM,EAAE,YAAY,EAAE,gCAAgC,EAAE,GAAG,OAAO,CAAC;IAEnE,MAAM,EACJ,sBAAsB,EACtB,uBAAuB,EACvB,0BAA0B,GAC3B,GAAG,gCAAgC,EAAE,CAAC,KAAK,CAAC;IAC7C,MAAM,aAAa,GAAG,YAAY,EAAE,CAAC,IAAI,CACvC,qCAAqC,CACtC,CAAC;IAEF,IACE,CAAC,sBAAsB;QACvB,CAAC,uBAAuB;QACxB,CAAC,aAAa;QACd,0BAA0B,EAC1B;QACA,OAAO,KAAK,CAAC;KACd;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC3C,OAA8B,EAC9B,eAAuB;IAEvB,MAAM,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC;IAEjC,IAAI,oBAAoB,GAAG,YAAY,EAAE,CAAC,IAAI,CAC5C,iCAAiC,CAClC,CAAC;IAEF,MAAM,sCAAsC,GAAG,oBAAoB,CAAC,KAAK,CACvE,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,CACpD,CAAC;IAEF,IAAI,CAAC,sCAAsC,EAAE;QAC3C,MAAM,YAAY,EAAE,CAAC,IAAI,CAAC,mCAAmC,CAAC,CAAC;QAC/D,oBAAoB,GAAG,YAAY,EAAE,CAAC,IAAI,CACxC,iCAAiC,CAClC,CAAC;KACH;IAED,OAAO,oBAAoB,CAAC,MAAM,CAChC,CAAC,OAAO,EAAE,EAAE,CACV,eAAe,KAAK,OAAO,CAAC,OAAO,CAAC,aAAa;QACjD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,KAAK,MAAM,CAAC,YAAY,CAAC,EAAE,CAAC,CAC5D,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAC9C,OAA8B,EAC9B,eAAwB;IAExB,MAAM,EAAE,gCAAgC,EAAE,GAAG,OAAO,CAAC;IAErD,MAAM,uBAAuB,GAC3B,MAAM,gCAAgC,EAAE,CAAC,kCAAkC,CACzE,0BAA0B,CAAC,QAAQ,EACnC,eAAe,CAChB,CAAC;IAEJ,OAAO,CACL,uBAAuB,EAAE,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI,IAAI,CAC7E,CAAC;AACJ,CAAC","sourcesContent":["import { KeyringTypes } from '@metamask/keyring-controller';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\n\nimport type { AccountSyncingOptions, UserStorageAccount } from './types';\nimport { USER_STORAGE_FEATURE_NAMES } from '../../../shared/storage-schema';\n\n/**\n * Checks if account syncing can be performed based on a set of conditions\n *\n * @param options - parameters used for checking if account syncing can be performed\n * @returns Returns true if account syncing can be performed, false otherwise.\n */\nexport function canPerformAccountSyncing(\n options: AccountSyncingOptions,\n): boolean {\n const { getMessenger, getUserStorageControllerInstance } = options;\n\n const {\n isBackupAndSyncEnabled,\n isAccountSyncingEnabled,\n isAccountSyncingInProgress,\n } = getUserStorageControllerInstance().state;\n const isAuthEnabled = getMessenger().call(\n 'AuthenticationController:isSignedIn',\n );\n\n if (\n !isBackupAndSyncEnabled ||\n !isAccountSyncingEnabled ||\n !isAuthEnabled ||\n isAccountSyncingInProgress\n ) {\n return false;\n }\n\n return true;\n}\n\n/**\n * Get the list of internal accounts\n * This function returns only the internal accounts that are from the primary SRP\n * and are from the HD keyring\n *\n * @param options - parameters used for getting the list of internal accounts\n * @param entropySourceId - The entropy source ID used to derive the key,\n * when multiple sources are available (Multi-SRP).\n * @returns the list of internal accounts\n */\nexport async function getInternalAccountsList(\n options: AccountSyncingOptions,\n entropySourceId: string,\n): Promise<InternalAccount[]> {\n const { getMessenger } = options;\n\n let internalAccountsList = getMessenger().call(\n 'AccountsController:listAccounts',\n );\n\n const doEachInternalAccountHaveEntropySource = internalAccountsList.every(\n (account) => Boolean(account.options.entropySource),\n );\n\n if (!doEachInternalAccountHaveEntropySource) {\n await getMessenger().call('AccountsController:updateAccounts');\n internalAccountsList = getMessenger().call(\n 'AccountsController:listAccounts',\n );\n }\n\n return internalAccountsList.filter(\n (account) =>\n entropySourceId === account.options.entropySource &&\n account.metadata.keyring.type === String(KeyringTypes.hd), // sync only EVM accounts until we support multichain accounts\n );\n}\n\n/**\n * Get the list of user storage accounts\n *\n * @param options - parameters used for getting the list of user storage accounts\n * @param entropySourceId - The entropy source ID used to derive the storage key,\n * when multiple sources are available (Multi-SRP).\n * @returns the list of user storage accounts\n */\nexport async function getUserStorageAccountsList(\n options: AccountSyncingOptions,\n entropySourceId?: string,\n): Promise<UserStorageAccount[] | null> {\n const { getUserStorageControllerInstance } = options;\n\n const rawAccountsListResponse =\n await getUserStorageControllerInstance().performGetStorageAllFeatureEntries(\n USER_STORAGE_FEATURE_NAMES.accounts,\n entropySourceId,\n );\n\n return (\n rawAccountsListResponse?.map((rawAccount) => JSON.parse(rawAccount)) ?? null\n );\n}\n"]}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const keyring_controller_1 = require("@metamask/keyring-controller");
|
|
3
|
+
exports.mapInternalAccountToUserStorageAccount = exports.isNameDefaultAccountName = void 0;
|
|
5
4
|
const constants_1 = require("./constants.cjs");
|
|
6
5
|
/**
|
|
7
6
|
* Tells if the given name is a default account name.
|
|
@@ -34,44 +33,4 @@ const mapInternalAccountToUserStorageAccount = (internalAccount) => {
|
|
|
34
33
|
};
|
|
35
34
|
};
|
|
36
35
|
exports.mapInternalAccountToUserStorageAccount = mapInternalAccountToUserStorageAccount;
|
|
37
|
-
/**
|
|
38
|
-
* Transforms a list of any internal accounts to a list of internal accounts that
|
|
39
|
-
* have the correct keyring type and are from the primary SRP.
|
|
40
|
-
*
|
|
41
|
-
* @param internalAccountsList - The list of internal accounts
|
|
42
|
-
* @param options - Parameters used for checking if the internal account is from the primary SRP
|
|
43
|
-
* @returns Returns a list of internal accounts that have the correct keyring type and are from the primary SRP.
|
|
44
|
-
*/
|
|
45
|
-
async function mapInternalAccountsListToPrimarySRPHdKeyringInternalAccountsList(internalAccountsList, options) {
|
|
46
|
-
const { getMessenger } = options;
|
|
47
|
-
const primarySRPHdKeyringAccountsAddresses = (await getMessenger().call('KeyringController:withKeyring', {
|
|
48
|
-
type: keyring_controller_1.KeyringTypes.hd,
|
|
49
|
-
index: 0,
|
|
50
|
-
}, async ({ keyring }) => {
|
|
51
|
-
return await keyring.getAccounts();
|
|
52
|
-
}));
|
|
53
|
-
return internalAccountsList.filter((account) => primarySRPHdKeyringAccountsAddresses?.includes(account.address));
|
|
54
|
-
}
|
|
55
|
-
exports.mapInternalAccountsListToPrimarySRPHdKeyringInternalAccountsList = mapInternalAccountsListToPrimarySRPHdKeyringInternalAccountsList;
|
|
56
|
-
/**
|
|
57
|
-
* Checks if the given internal account is from the primary SRP and is from the HD keyring.
|
|
58
|
-
*
|
|
59
|
-
* @param account - The internal account to check
|
|
60
|
-
* @param options - Parameters used for checking if the internal account is from the primary SRP
|
|
61
|
-
* @returns Returns true if the internal account is from the primary SRP, false otherwise.
|
|
62
|
-
*/
|
|
63
|
-
async function isInternalAccountFromPrimarySRPHdKeyring(account, options) {
|
|
64
|
-
if (account.metadata.keyring.type !== keyring_controller_1.KeyringTypes.hd) {
|
|
65
|
-
return false;
|
|
66
|
-
}
|
|
67
|
-
const { getMessenger } = options;
|
|
68
|
-
const primarySRPHdKeyringAccountsAddresses = (await getMessenger().call('KeyringController:withKeyring', {
|
|
69
|
-
type: keyring_controller_1.KeyringTypes.hd,
|
|
70
|
-
index: 0,
|
|
71
|
-
}, async ({ keyring }) => {
|
|
72
|
-
return await keyring.getAccounts();
|
|
73
|
-
}));
|
|
74
|
-
return primarySRPHdKeyringAccountsAddresses.includes(account.address);
|
|
75
|
-
}
|
|
76
|
-
exports.isInternalAccountFromPrimarySRPHdKeyring = isInternalAccountFromPrimarySRPHdKeyring;
|
|
77
36
|
//# sourceMappingURL=utils.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.cjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/account-syncing/utils.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"utils.cjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/account-syncing/utils.ts"],"names":[],"mappings":";;;AAEA,+CAIqB;AAGrB;;;;;;GAMG;AAEI,MAAM,wBAAwB,GAAG,CAAC,IAAY,EAAE,EAAE;IACvD,OAAO,2CAA+B,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE;QACrD,OAAO,IAAI,MAAM,CAAC,IAAI,MAAM,YAAY,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAJW,QAAA,wBAAwB,4BAInC;AAEF;;;;;GAKG;AACI,MAAM,sCAAsC,GAAG,CACpD,eAAgC,EACZ,EAAE;IACtB,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,GAAG,eAAe,CAAC;IAClD,MAAM,EAAE,IAAI,EAAE,iBAAiB,EAAE,GAAG,QAAQ,CAAC;IAE7C,OAAO;QACL,CAAC,oCAAwB,CAAC,EAAE,gCAAoB;QAChD,CAAC,EAAE,OAAO;QACV,CAAC,EAAE,EAAE;QACL,CAAC,EAAE,IAAI;QACP,GAAG,CAAC,IAAA,gCAAwB,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,iBAAiB,EAAE,CAAC;KACtE,CAAC;AACJ,CAAC,CAAC;AAbW,QAAA,sCAAsC,0CAajD","sourcesContent":["import type { InternalAccount } from '@metamask/keyring-internal-api';\n\nimport {\n USER_STORAGE_VERSION_KEY,\n USER_STORAGE_VERSION,\n LOCALIZED_DEFAULT_ACCOUNT_NAMES,\n} from './constants';\nimport type { UserStorageAccount } from './types';\n\n/**\n * Tells if the given name is a default account name.\n * Default account names are localized names that are automatically generated by the clients.\n *\n * @param name - the name to check\n * @returns true if the name is a default account name, false otherwise\n */\n\nexport const isNameDefaultAccountName = (name: string) => {\n return LOCALIZED_DEFAULT_ACCOUNT_NAMES.some((prefix) => {\n return new RegExp(`^${prefix} ([0-9]+)$`, 'u').test(name);\n });\n};\n\n/**\n * Map an internal account to a user storage account\n *\n * @param internalAccount - An internal account\n * @returns A user storage account\n */\nexport const mapInternalAccountToUserStorageAccount = (\n internalAccount: InternalAccount,\n): UserStorageAccount => {\n const { address, id, metadata } = internalAccount;\n const { name, nameLastUpdatedAt } = metadata;\n\n return {\n [USER_STORAGE_VERSION_KEY]: USER_STORAGE_VERSION,\n a: address,\n i: id,\n n: name,\n ...(isNameDefaultAccountName(name) ? {} : { nlu: nameLastUpdatedAt }),\n };\n};\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { InternalAccount } from "@metamask/keyring-internal-api";
|
|
2
|
-
import type {
|
|
2
|
+
import type { UserStorageAccount } from "./types.cjs";
|
|
3
3
|
/**
|
|
4
4
|
* Tells if the given name is a default account name.
|
|
5
5
|
* Default account names are localized names that are automatically generated by the clients.
|
|
@@ -15,21 +15,4 @@ export declare const isNameDefaultAccountName: (name: string) => boolean;
|
|
|
15
15
|
* @returns A user storage account
|
|
16
16
|
*/
|
|
17
17
|
export declare const mapInternalAccountToUserStorageAccount: (internalAccount: InternalAccount) => UserStorageAccount;
|
|
18
|
-
/**
|
|
19
|
-
* Transforms a list of any internal accounts to a list of internal accounts that
|
|
20
|
-
* have the correct keyring type and are from the primary SRP.
|
|
21
|
-
*
|
|
22
|
-
* @param internalAccountsList - The list of internal accounts
|
|
23
|
-
* @param options - Parameters used for checking if the internal account is from the primary SRP
|
|
24
|
-
* @returns Returns a list of internal accounts that have the correct keyring type and are from the primary SRP.
|
|
25
|
-
*/
|
|
26
|
-
export declare function mapInternalAccountsListToPrimarySRPHdKeyringInternalAccountsList(internalAccountsList: InternalAccount[], options: AccountSyncingOptions): Promise<InternalAccount[]>;
|
|
27
|
-
/**
|
|
28
|
-
* Checks if the given internal account is from the primary SRP and is from the HD keyring.
|
|
29
|
-
*
|
|
30
|
-
* @param account - The internal account to check
|
|
31
|
-
* @param options - Parameters used for checking if the internal account is from the primary SRP
|
|
32
|
-
* @returns Returns true if the internal account is from the primary SRP, false otherwise.
|
|
33
|
-
*/
|
|
34
|
-
export declare function isInternalAccountFromPrimarySRPHdKeyring(account: InternalAccount, options: AccountSyncingOptions): Promise<boolean>;
|
|
35
18
|
//# sourceMappingURL=utils.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.cts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/account-syncing/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.d.cts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/account-syncing/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AAOtE,OAAO,KAAK,EAAE,kBAAkB,EAAE,oBAAgB;AAElD;;;;;;GAMG;AAEH,eAAO,MAAM,wBAAwB,SAAU,MAAM,YAIpD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,sCAAsC,oBAChC,eAAe,KAC/B,kBAWF,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { InternalAccount } from "@metamask/keyring-internal-api";
|
|
2
|
-
import type {
|
|
2
|
+
import type { UserStorageAccount } from "./types.mjs";
|
|
3
3
|
/**
|
|
4
4
|
* Tells if the given name is a default account name.
|
|
5
5
|
* Default account names are localized names that are automatically generated by the clients.
|
|
@@ -15,21 +15,4 @@ export declare const isNameDefaultAccountName: (name: string) => boolean;
|
|
|
15
15
|
* @returns A user storage account
|
|
16
16
|
*/
|
|
17
17
|
export declare const mapInternalAccountToUserStorageAccount: (internalAccount: InternalAccount) => UserStorageAccount;
|
|
18
|
-
/**
|
|
19
|
-
* Transforms a list of any internal accounts to a list of internal accounts that
|
|
20
|
-
* have the correct keyring type and are from the primary SRP.
|
|
21
|
-
*
|
|
22
|
-
* @param internalAccountsList - The list of internal accounts
|
|
23
|
-
* @param options - Parameters used for checking if the internal account is from the primary SRP
|
|
24
|
-
* @returns Returns a list of internal accounts that have the correct keyring type and are from the primary SRP.
|
|
25
|
-
*/
|
|
26
|
-
export declare function mapInternalAccountsListToPrimarySRPHdKeyringInternalAccountsList(internalAccountsList: InternalAccount[], options: AccountSyncingOptions): Promise<InternalAccount[]>;
|
|
27
|
-
/**
|
|
28
|
-
* Checks if the given internal account is from the primary SRP and is from the HD keyring.
|
|
29
|
-
*
|
|
30
|
-
* @param account - The internal account to check
|
|
31
|
-
* @param options - Parameters used for checking if the internal account is from the primary SRP
|
|
32
|
-
* @returns Returns true if the internal account is from the primary SRP, false otherwise.
|
|
33
|
-
*/
|
|
34
|
-
export declare function isInternalAccountFromPrimarySRPHdKeyring(account: InternalAccount, options: AccountSyncingOptions): Promise<boolean>;
|
|
35
18
|
//# sourceMappingURL=utils.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.mts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/account-syncing/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.d.mts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/account-syncing/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AAOtE,OAAO,KAAK,EAAE,kBAAkB,EAAE,oBAAgB;AAElD;;;;;;GAMG;AAEH,eAAO,MAAM,wBAAwB,SAAU,MAAM,YAIpD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,sCAAsC,oBAChC,eAAe,KAC/B,kBAWF,CAAC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { KeyringTypes } from "@metamask/keyring-controller";
|
|
2
1
|
import { USER_STORAGE_VERSION_KEY, USER_STORAGE_VERSION, LOCALIZED_DEFAULT_ACCOUNT_NAMES } from "./constants.mjs";
|
|
3
2
|
/**
|
|
4
3
|
* Tells if the given name is a default account name.
|
|
@@ -29,42 +28,4 @@ export const mapInternalAccountToUserStorageAccount = (internalAccount) => {
|
|
|
29
28
|
...(isNameDefaultAccountName(name) ? {} : { nlu: nameLastUpdatedAt }),
|
|
30
29
|
};
|
|
31
30
|
};
|
|
32
|
-
/**
|
|
33
|
-
* Transforms a list of any internal accounts to a list of internal accounts that
|
|
34
|
-
* have the correct keyring type and are from the primary SRP.
|
|
35
|
-
*
|
|
36
|
-
* @param internalAccountsList - The list of internal accounts
|
|
37
|
-
* @param options - Parameters used for checking if the internal account is from the primary SRP
|
|
38
|
-
* @returns Returns a list of internal accounts that have the correct keyring type and are from the primary SRP.
|
|
39
|
-
*/
|
|
40
|
-
export async function mapInternalAccountsListToPrimarySRPHdKeyringInternalAccountsList(internalAccountsList, options) {
|
|
41
|
-
const { getMessenger } = options;
|
|
42
|
-
const primarySRPHdKeyringAccountsAddresses = (await getMessenger().call('KeyringController:withKeyring', {
|
|
43
|
-
type: KeyringTypes.hd,
|
|
44
|
-
index: 0,
|
|
45
|
-
}, async ({ keyring }) => {
|
|
46
|
-
return await keyring.getAccounts();
|
|
47
|
-
}));
|
|
48
|
-
return internalAccountsList.filter((account) => primarySRPHdKeyringAccountsAddresses?.includes(account.address));
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Checks if the given internal account is from the primary SRP and is from the HD keyring.
|
|
52
|
-
*
|
|
53
|
-
* @param account - The internal account to check
|
|
54
|
-
* @param options - Parameters used for checking if the internal account is from the primary SRP
|
|
55
|
-
* @returns Returns true if the internal account is from the primary SRP, false otherwise.
|
|
56
|
-
*/
|
|
57
|
-
export async function isInternalAccountFromPrimarySRPHdKeyring(account, options) {
|
|
58
|
-
if (account.metadata.keyring.type !== KeyringTypes.hd) {
|
|
59
|
-
return false;
|
|
60
|
-
}
|
|
61
|
-
const { getMessenger } = options;
|
|
62
|
-
const primarySRPHdKeyringAccountsAddresses = (await getMessenger().call('KeyringController:withKeyring', {
|
|
63
|
-
type: KeyringTypes.hd,
|
|
64
|
-
index: 0,
|
|
65
|
-
}, async ({ keyring }) => {
|
|
66
|
-
return await keyring.getAccounts();
|
|
67
|
-
}));
|
|
68
|
-
return primarySRPHdKeyringAccountsAddresses.includes(account.address);
|
|
69
|
-
}
|
|
70
31
|
//# sourceMappingURL=utils.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.mjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/account-syncing/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.mjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/account-syncing/utils.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,wBAAwB,EACxB,oBAAoB,EACpB,+BAA+B,EAChC,wBAAoB;AAGrB;;;;;;GAMG;AAEH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,IAAY,EAAE,EAAE;IACvD,OAAO,+BAA+B,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE;QACrD,OAAO,IAAI,MAAM,CAAC,IAAI,MAAM,YAAY,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,sCAAsC,GAAG,CACpD,eAAgC,EACZ,EAAE;IACtB,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,GAAG,eAAe,CAAC;IAClD,MAAM,EAAE,IAAI,EAAE,iBAAiB,EAAE,GAAG,QAAQ,CAAC;IAE7C,OAAO;QACL,CAAC,wBAAwB,CAAC,EAAE,oBAAoB;QAChD,CAAC,EAAE,OAAO;QACV,CAAC,EAAE,EAAE;QACL,CAAC,EAAE,IAAI;QACP,GAAG,CAAC,wBAAwB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,iBAAiB,EAAE,CAAC;KACtE,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import type { InternalAccount } from '@metamask/keyring-internal-api';\n\nimport {\n USER_STORAGE_VERSION_KEY,\n USER_STORAGE_VERSION,\n LOCALIZED_DEFAULT_ACCOUNT_NAMES,\n} from './constants';\nimport type { UserStorageAccount } from './types';\n\n/**\n * Tells if the given name is a default account name.\n * Default account names are localized names that are automatically generated by the clients.\n *\n * @param name - the name to check\n * @returns true if the name is a default account name, false otherwise\n */\n\nexport const isNameDefaultAccountName = (name: string) => {\n return LOCALIZED_DEFAULT_ACCOUNT_NAMES.some((prefix) => {\n return new RegExp(`^${prefix} ([0-9]+)$`, 'u').test(name);\n });\n};\n\n/**\n * Map an internal account to a user storage account\n *\n * @param internalAccount - An internal account\n * @returns A user storage account\n */\nexport const mapInternalAccountToUserStorageAccount = (\n internalAccount: InternalAccount,\n): UserStorageAccount => {\n const { address, id, metadata } = internalAccount;\n const { name, nameLastUpdatedAt } = metadata;\n\n return {\n [USER_STORAGE_VERSION_KEY]: USER_STORAGE_VERSION,\n a: address,\n i: id,\n n: name,\n ...(isNameDefaultAccountName(name) ? {} : { nlu: nameLastUpdatedAt }),\n };\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.cjs","sourceRoot":"","sources":["../../../src/controllers/user-storage/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,sBAAsB,GAAG;IACpC,IAAI,EAAE,MAAM;IACZ,cAAc,EAAE,gBAAgB;CACxB,CAAC","sourcesContent":["export const BACKUPANDSYNC_FEATURES = {\n main: 'main',\n accountSyncing: 'accountSyncing',\n} as const;\n"]}
|
|
1
|
+
{"version":3,"file":"constants.cjs","sourceRoot":"","sources":["../../../src/controllers/user-storage/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,sBAAsB,GAAG;IACpC,IAAI,EAAE,MAAM;IACZ,cAAc,EAAE,gBAAgB;IAChC,cAAc,EAAE,gBAAgB;CACxB,CAAC","sourcesContent":["export const BACKUPANDSYNC_FEATURES = {\n main: 'main',\n accountSyncing: 'accountSyncing',\n contactSyncing: 'contactSyncing',\n} as const;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.cts","sourceRoot":"","sources":["../../../src/controllers/user-storage/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,sBAAsB
|
|
1
|
+
{"version":3,"file":"constants.d.cts","sourceRoot":"","sources":["../../../src/controllers/user-storage/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,sBAAsB;;;;CAIzB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.mts","sourceRoot":"","sources":["../../../src/controllers/user-storage/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,sBAAsB
|
|
1
|
+
{"version":3,"file":"constants.d.mts","sourceRoot":"","sources":["../../../src/controllers/user-storage/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,sBAAsB;;;;CAIzB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.mjs","sourceRoot":"","sources":["../../../src/controllers/user-storage/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,IAAI,EAAE,MAAM;IACZ,cAAc,EAAE,gBAAgB;CACxB,CAAC","sourcesContent":["export const BACKUPANDSYNC_FEATURES = {\n main: 'main',\n accountSyncing: 'accountSyncing',\n} as const;\n"]}
|
|
1
|
+
{"version":3,"file":"constants.mjs","sourceRoot":"","sources":["../../../src/controllers/user-storage/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,IAAI,EAAE,MAAM;IACZ,cAAc,EAAE,gBAAgB;IAChC,cAAc,EAAE,gBAAgB;CACxB,CAAC","sourcesContent":["export const BACKUPANDSYNC_FEATURES = {\n main: 'main',\n accountSyncing: 'accountSyncing',\n contactSyncing: 'contactSyncing',\n} as const;\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.USER_STORAGE_VERSION = exports.USER_STORAGE_VERSION_KEY = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Key for version in User Storage schema
|
|
6
|
+
*/
|
|
7
|
+
exports.USER_STORAGE_VERSION_KEY = 'v';
|
|
8
|
+
/**
|
|
9
|
+
* Current version of User Storage schema
|
|
10
|
+
*/
|
|
11
|
+
exports.USER_STORAGE_VERSION = '1';
|
|
12
|
+
//# sourceMappingURL=constants.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.cjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/contact-syncing/constants.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACU,QAAA,wBAAwB,GAAG,GAAG,CAAC;AAE5C;;GAEG;AACU,QAAA,oBAAoB,GAAG,GAAG,CAAC","sourcesContent":["/**\n * Key for version in User Storage schema\n */\nexport const USER_STORAGE_VERSION_KEY = 'v';\n\n/**\n * Current version of User Storage schema\n */\nexport const USER_STORAGE_VERSION = '1';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.cts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/contact-syncing/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,wBAAwB,MAAM,CAAC;AAE5C;;GAEG;AACH,eAAO,MAAM,oBAAoB,MAAM,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.mts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/contact-syncing/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,wBAAwB,MAAM,CAAC;AAE5C;;GAEG;AACH,eAAO,MAAM,oBAAoB,MAAM,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.mjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/contact-syncing/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAG,CAAC;AAE5C;;GAEG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAG,CAAC","sourcesContent":["/**\n * Key for version in User Storage schema\n */\nexport const USER_STORAGE_VERSION_KEY = 'v';\n\n/**\n * Current version of User Storage schema\n */\nexport const USER_STORAGE_VERSION = '1';\n"]}
|