@metamask-previews/profile-sync-controller 17.0.0-preview-d2bf8ff → 17.0.0-preview-4da9cec1
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 +5 -0
- package/dist/controllers/user-storage/UserStorageController.cjs +56 -3
- package/dist/controllers/user-storage/UserStorageController.cjs.map +1 -1
- package/dist/controllers/user-storage/UserStorageController.d.cts +40 -2
- package/dist/controllers/user-storage/UserStorageController.d.cts.map +1 -1
- package/dist/controllers/user-storage/UserStorageController.d.mts +40 -2
- package/dist/controllers/user-storage/UserStorageController.d.mts.map +1 -1
- package/dist/controllers/user-storage/UserStorageController.mjs +53 -0
- package/dist/controllers/user-storage/UserStorageController.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 +281 -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 +275 -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 +64 -0
- package/dist/controllers/user-storage/contact-syncing/utils.cjs.map +1 -0
- package/dist/controllers/user-storage/contact-syncing/utils.d.cts +36 -0
- package/dist/controllers/user-storage/contact-syncing/utils.d.cts.map +1 -0
- package/dist/controllers/user-storage/contact-syncing/utils.d.mts +36 -0
- package/dist/controllers/user-storage/contact-syncing/utils.d.mts.map +1 -0
- package/dist/controllers/user-storage/contact-syncing/utils.mjs +58 -0
- package/dist/controllers/user-storage/contact-syncing/utils.mjs.map +1 -0
- package/dist/shared/storage-schema.cjs +3 -1
- package/dist/shared/storage-schema.cjs.map +1 -1
- package/dist/shared/storage-schema.d.cts +2 -0
- package/dist/shared/storage-schema.d.cts.map +1 -1
- package/dist/shared/storage-schema.d.mts +2 -0
- package/dist/shared/storage-schema.d.mts.map +1 -1
- package/dist/shared/storage-schema.mjs +3 -1
- package/dist/shared/storage-schema.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { Hex } from "@metamask/utils";
|
|
2
|
+
import type { USER_STORAGE_VERSION_KEY, USER_STORAGE_VERSION } from "./constants.mjs";
|
|
3
|
+
import type { UserStorageControllerMessenger } from "../UserStorageController.mjs";
|
|
4
|
+
import type UserStorageController from "../UserStorageController.mjs";
|
|
5
|
+
export type UserStorageContactEntry = {
|
|
6
|
+
/**
|
|
7
|
+
* The Version 'v' of the User Storage.
|
|
8
|
+
* NOTE - will allow us to support upgrade/downgrades in the future
|
|
9
|
+
*/
|
|
10
|
+
[USER_STORAGE_VERSION_KEY]: typeof USER_STORAGE_VERSION;
|
|
11
|
+
/** the address 'a' of the contact */
|
|
12
|
+
a: string;
|
|
13
|
+
/** the name 'n' of the contact */
|
|
14
|
+
n: string;
|
|
15
|
+
/** the chainId 'c' of the contact */
|
|
16
|
+
c: Hex;
|
|
17
|
+
/** the memo 'm' of the contact (optional) */
|
|
18
|
+
m?: string;
|
|
19
|
+
/** the addressType 't' of the contact (optional) */
|
|
20
|
+
t?: string;
|
|
21
|
+
/** the isEns flag 'e' of the contact (optional) */
|
|
22
|
+
e?: boolean;
|
|
23
|
+
/** the lastUpdatedAt timestamp 'lu' of the contact */
|
|
24
|
+
lu?: number;
|
|
25
|
+
/** the deletedAt timestamp 'dt' of the contact (optional) */
|
|
26
|
+
dt?: number;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Options for contact syncing operations
|
|
30
|
+
*/
|
|
31
|
+
export type ContactSyncingOptions = {
|
|
32
|
+
getUserStorageControllerInstance: () => UserStorageController;
|
|
33
|
+
getMessenger: () => UserStorageControllerMessenger;
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=types.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/contact-syncing/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAE3C,OAAO,KAAK,EACV,wBAAwB,EACxB,oBAAoB,EACrB,wBAAoB;AACrB,OAAO,KAAK,EAAE,8BAA8B,EAAE,qCAAiC;AAC/E,OAAO,KAAK,qBAAqB,qCAAiC;AAElE,MAAM,MAAM,uBAAuB,GAAG;IACpC;;;OAGG;IACH,CAAC,wBAAwB,CAAC,EAAE,OAAO,oBAAoB,CAAC;IACxD,qCAAqC;IACrC,CAAC,EAAE,MAAM,CAAC;IACV,kCAAkC;IAClC,CAAC,EAAE,MAAM,CAAC;IACV,qCAAqC;IACrC,CAAC,EAAE,GAAG,CAAC;IACP,6CAA6C;IAC7C,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,oDAAoD;IACpD,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,mDAAmD;IACnD,CAAC,CAAC,EAAE,OAAO,CAAC;IACZ,sDAAsD;IACtD,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,6DAA6D;IAC7D,EAAE,CAAC,EAAE,MAAM,CAAC;CACb,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC,gCAAgC,EAAE,MAAM,qBAAqB,CAAC;IAC9D,YAAY,EAAE,MAAM,8BAA8B,CAAC;CACpD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.mjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/contact-syncing/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Hex } from '@metamask/utils';\n\nimport type {\n USER_STORAGE_VERSION_KEY,\n USER_STORAGE_VERSION,\n} from './constants';\nimport type { UserStorageControllerMessenger } from '../UserStorageController';\nimport type UserStorageController from '../UserStorageController';\n\nexport type UserStorageContactEntry = {\n /**\n * The Version 'v' of the User Storage.\n * NOTE - will allow us to support upgrade/downgrades in the future\n */\n [USER_STORAGE_VERSION_KEY]: typeof USER_STORAGE_VERSION;\n /** the address 'a' of the contact */\n a: string;\n /** the name 'n' of the contact */\n n: string;\n /** the chainId 'c' of the contact */\n c: Hex;\n /** the memo 'm' of the contact (optional) */\n m?: string;\n /** the addressType 't' of the contact (optional) */\n t?: string;\n /** the isEns flag 'e' of the contact (optional) */\n e?: boolean;\n /** the lastUpdatedAt timestamp 'lu' of the contact */\n lu?: number;\n /** the deletedAt timestamp 'dt' of the contact (optional) */\n dt?: number;\n};\n\n/**\n * Options for contact syncing operations\n */\nexport type ContactSyncingOptions = {\n getUserStorageControllerInstance: () => UserStorageController;\n getMessenger: () => UserStorageControllerMessenger;\n};\n"]}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isContactBridgedFromAccounts = exports.mapUserStorageEntryToAddressBookEntry = exports.mapAddressBookEntryToUserStorageEntry = void 0;
|
|
4
|
+
const constants_1 = require("./constants.cjs");
|
|
5
|
+
/**
|
|
6
|
+
* Map an address book entry to a user storage address book entry
|
|
7
|
+
* Always sets a current timestamp for entries going to remote storage
|
|
8
|
+
*
|
|
9
|
+
* @param addressBookEntry - An address book entry
|
|
10
|
+
* @returns A user storage address book entry
|
|
11
|
+
*/
|
|
12
|
+
const mapAddressBookEntryToUserStorageEntry = (addressBookEntry) => {
|
|
13
|
+
const { address, name, chainId, memo, addressType, isEns, lastUpdatedAt, deletedAt, } = addressBookEntry;
|
|
14
|
+
const now = Date.now();
|
|
15
|
+
return {
|
|
16
|
+
[constants_1.USER_STORAGE_VERSION_KEY]: constants_1.USER_STORAGE_VERSION,
|
|
17
|
+
a: address,
|
|
18
|
+
n: name,
|
|
19
|
+
c: chainId,
|
|
20
|
+
...(memo ? { m: memo } : {}),
|
|
21
|
+
...(addressType ? { t: addressType } : {}),
|
|
22
|
+
...(isEns ? { e: isEns } : {}),
|
|
23
|
+
lu: lastUpdatedAt || now,
|
|
24
|
+
...(deletedAt ? { dt: deletedAt } : {}),
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
exports.mapAddressBookEntryToUserStorageEntry = mapAddressBookEntryToUserStorageEntry;
|
|
28
|
+
/**
|
|
29
|
+
* Map a user storage address book entry to an address book entry
|
|
30
|
+
* Preserves sync metadata from remote storage while keeping the
|
|
31
|
+
* entry compatible with AddressBookController
|
|
32
|
+
*
|
|
33
|
+
* @param userStorageEntry - A user storage address book entry
|
|
34
|
+
* @returns An address book entry with sync metadata for internal use
|
|
35
|
+
*/
|
|
36
|
+
const mapUserStorageEntryToAddressBookEntry = (userStorageEntry) => {
|
|
37
|
+
const addressBookEntry = {
|
|
38
|
+
address: userStorageEntry.a,
|
|
39
|
+
name: userStorageEntry.n,
|
|
40
|
+
chainId: userStorageEntry.c,
|
|
41
|
+
memo: userStorageEntry.m || '',
|
|
42
|
+
isEns: userStorageEntry.e || false,
|
|
43
|
+
...(userStorageEntry.t
|
|
44
|
+
? { addressType: userStorageEntry.t }
|
|
45
|
+
: {}),
|
|
46
|
+
// Include remote metadata for sync operation only (not stored in AddressBookController)
|
|
47
|
+
...(userStorageEntry.dt ? { deletedAt: userStorageEntry.dt } : {}),
|
|
48
|
+
...(userStorageEntry.lu ? { lastUpdatedAt: userStorageEntry.lu } : {}),
|
|
49
|
+
};
|
|
50
|
+
return addressBookEntry;
|
|
51
|
+
};
|
|
52
|
+
exports.mapUserStorageEntryToAddressBookEntry = mapUserStorageEntryToAddressBookEntry;
|
|
53
|
+
/**
|
|
54
|
+
* Check if a contact entry is bridged from accounts
|
|
55
|
+
* Contacts with chainId "*" are global accounts bridged from the accounts system
|
|
56
|
+
*
|
|
57
|
+
* @param contactEntry - The contact entry to check
|
|
58
|
+
* @returns True if the contact is bridged from accounts
|
|
59
|
+
*/
|
|
60
|
+
const isContactBridgedFromAccounts = (contactEntry) => {
|
|
61
|
+
return String(contactEntry.chainId) === '*';
|
|
62
|
+
};
|
|
63
|
+
exports.isContactBridgedFromAccounts = isContactBridgedFromAccounts;
|
|
64
|
+
//# sourceMappingURL=utils.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.cjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/contact-syncing/utils.ts"],"names":[],"mappings":";;;AAKA,+CAA6E;AAY7E;;;;;;GAMG;AACI,MAAM,qCAAqC,GAAG,CACnD,gBAAkC,EACT,EAAE;IAC3B,MAAM,EACJ,OAAO,EACP,IAAI,EACJ,OAAO,EACP,IAAI,EACJ,WAAW,EACX,KAAK,EACL,aAAa,EACb,SAAS,GACV,GAAG,gBAAwC,CAAC;IAE7C,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAEvB,OAAO;QACL,CAAC,oCAAwB,CAAC,EAAE,gCAAoB;QAChD,CAAC,EAAE,OAAO;QACV,CAAC,EAAE,IAAI;QACP,CAAC,EAAE,OAAO;QACV,GAAG,CAAC,IA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EF,OAAO,gBAAgB,CAAC;AAC1B,CAAC,CAAC;AAlBW,QAAA,qCAAqC,yCAkBhD;AAEF;;;;;;GAMG;AACI,MAAM,4BAA4B,GAAG,CAC1C,YAA8B,EACrB,EAAE;IACX,OAAO,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,KAAK,GAAG,CAAC;AAC9C,CAAC,CAAC;AAJW,QAAA,4BAA4B,gCAIvC","sourcesContent":["import type {\n AddressBookEntry,\n AddressType,\n} from '@metamask/address-book-controller';\n\nimport { USER_STORAGE_VERSION_KEY, USER_STORAGE_VERSION } from './constants';\nimport type { UserStorageContactEntry } from './types';\n\n/**\n * Extends AddressBookEntry with sync metadata\n * This is only used internally during the sync process and is not stored in AddressBookController\n */\nexport type SyncAddressBookEntry = AddressBookEntry & {\n lastUpdatedAt?: number;\n deletedAt?: number;\n};\n\n/**\n * Map an address book entry to a user storage address book entry\n * Always sets a current timestamp for entries going to remote storage\n *\n * @param addressBookEntry - An address book entry\n * @returns A user storage address book entry\n */\nexport const mapAddressBookEntryToUserStorageEntry = (\n addressBookEntry: AddressBookEntry,\n): UserStorageContactEntry => {\n const {\n address,\n name,\n chainId,\n memo,\n addressType,\n isEns,\n lastUpdatedAt,\n deletedAt,\n } = addressBookEntry as SyncAddressBookEntry;\n\n const now = Date.now();\n\n return {\n [USER_STORAGE_VERSION_KEY]: USER_STORAGE_VERSION,\n a: address,\n n: name,\n c: chainId,\n ...(memo ? { m: memo } : {}),\n ...(addressType ? { t: addressType } : {}),\n ...(isEns ? { e: isEns } : {}),\n lu: lastUpdatedAt || now,\n ...(deletedAt ? { dt: deletedAt } : {}),\n };\n};\n\n/**\n * Map a user storage address book entry to an address book entry\n * Preserves sync metadata from remote storage while keeping the\n * entry compatible with AddressBookController\n *\n * @param userStorageEntry - A user storage address book entry\n * @returns An address book entry with sync metadata for internal use\n */\nexport const mapUserStorageEntryToAddressBookEntry = (\n userStorageEntry: UserStorageContactEntry,\n): SyncAddressBookEntry => {\n const addressBookEntry: SyncAddressBookEntry = {\n address: userStorageEntry.a,\n name: userStorageEntry.n,\n chainId: userStorageEntry.c,\n memo: userStorageEntry.m || '',\n isEns: userStorageEntry.e || false,\n ...(userStorageEntry.t\n ? { addressType: userStorageEntry.t as AddressType }\n : {}),\n // Include remote metadata for sync operation only (not stored in AddressBookController)\n ...(userStorageEntry.dt ? { deletedAt: userStorageEntry.dt } : {}),\n ...(userStorageEntry.lu ? { lastUpdatedAt: userStorageEntry.lu } : {}),\n };\n\n return addressBookEntry;\n};\n\n/**\n * Check if a contact entry is bridged from accounts\n * Contacts with chainId \"*\" are global accounts bridged from the accounts system\n *\n * @param contactEntry - The contact entry to check\n * @returns True if the contact is bridged from accounts\n */\nexport const isContactBridgedFromAccounts = (\n contactEntry: AddressBookEntry,\n): boolean => {\n return String(contactEntry.chainId) === '*';\n};\n"]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { AddressBookEntry } from "@metamask/address-book-controller";
|
|
2
|
+
import type { UserStorageContactEntry } from "./types.cjs";
|
|
3
|
+
/**
|
|
4
|
+
* Extends AddressBookEntry with sync metadata
|
|
5
|
+
* This is only used internally during the sync process and is not stored in AddressBookController
|
|
6
|
+
*/
|
|
7
|
+
export type SyncAddressBookEntry = AddressBookEntry & {
|
|
8
|
+
lastUpdatedAt?: number;
|
|
9
|
+
deletedAt?: number;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Map an address book entry to a user storage address book entry
|
|
13
|
+
* Always sets a current timestamp for entries going to remote storage
|
|
14
|
+
*
|
|
15
|
+
* @param addressBookEntry - An address book entry
|
|
16
|
+
* @returns A user storage address book entry
|
|
17
|
+
*/
|
|
18
|
+
export declare const mapAddressBookEntryToUserStorageEntry: (addressBookEntry: AddressBookEntry) => UserStorageContactEntry;
|
|
19
|
+
/**
|
|
20
|
+
* Map a user storage address book entry to an address book entry
|
|
21
|
+
* Preserves sync metadata from remote storage while keeping the
|
|
22
|
+
* entry compatible with AddressBookController
|
|
23
|
+
*
|
|
24
|
+
* @param userStorageEntry - A user storage address book entry
|
|
25
|
+
* @returns An address book entry with sync metadata for internal use
|
|
26
|
+
*/
|
|
27
|
+
export declare const mapUserStorageEntryToAddressBookEntry: (userStorageEntry: UserStorageContactEntry) => SyncAddressBookEntry;
|
|
28
|
+
/**
|
|
29
|
+
* Check if a contact entry is bridged from accounts
|
|
30
|
+
* Contacts with chainId "*" are global accounts bridged from the accounts system
|
|
31
|
+
*
|
|
32
|
+
* @param contactEntry - The contact entry to check
|
|
33
|
+
* @returns True if the contact is bridged from accounts
|
|
34
|
+
*/
|
|
35
|
+
export declare const isContactBridgedFromAccounts: (contactEntry: AddressBookEntry) => boolean;
|
|
36
|
+
//# sourceMappingURL=utils.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.cts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/contact-syncing/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAEjB,0CAA0C;AAG3C,OAAO,KAAK,EAAE,uBAAuB,EAAE,oBAAgB;AAEvD;;;GAGG;AACH,MAAM,MAAM,oBAAoB,GAAG,gBAAgB,GAAG;IACpD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,qCAAqC,qBAC9B,gBAAgB,KACjC,uBAyBF,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,qCAAqC,qBAC9B,uBAAuB,KACxC,oBAgBF,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,4BAA4B,iBACzB,gBAAgB,KAC7B,OAEF,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { AddressBookEntry } from "@metamask/address-book-controller";
|
|
2
|
+
import type { UserStorageContactEntry } from "./types.mjs";
|
|
3
|
+
/**
|
|
4
|
+
* Extends AddressBookEntry with sync metadata
|
|
5
|
+
* This is only used internally during the sync process and is not stored in AddressBookController
|
|
6
|
+
*/
|
|
7
|
+
export type SyncAddressBookEntry = AddressBookEntry & {
|
|
8
|
+
lastUpdatedAt?: number;
|
|
9
|
+
deletedAt?: number;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Map an address book entry to a user storage address book entry
|
|
13
|
+
* Always sets a current timestamp for entries going to remote storage
|
|
14
|
+
*
|
|
15
|
+
* @param addressBookEntry - An address book entry
|
|
16
|
+
* @returns A user storage address book entry
|
|
17
|
+
*/
|
|
18
|
+
export declare const mapAddressBookEntryToUserStorageEntry: (addressBookEntry: AddressBookEntry) => UserStorageContactEntry;
|
|
19
|
+
/**
|
|
20
|
+
* Map a user storage address book entry to an address book entry
|
|
21
|
+
* Preserves sync metadata from remote storage while keeping the
|
|
22
|
+
* entry compatible with AddressBookController
|
|
23
|
+
*
|
|
24
|
+
* @param userStorageEntry - A user storage address book entry
|
|
25
|
+
* @returns An address book entry with sync metadata for internal use
|
|
26
|
+
*/
|
|
27
|
+
export declare const mapUserStorageEntryToAddressBookEntry: (userStorageEntry: UserStorageContactEntry) => SyncAddressBookEntry;
|
|
28
|
+
/**
|
|
29
|
+
* Check if a contact entry is bridged from accounts
|
|
30
|
+
* Contacts with chainId "*" are global accounts bridged from the accounts system
|
|
31
|
+
*
|
|
32
|
+
* @param contactEntry - The contact entry to check
|
|
33
|
+
* @returns True if the contact is bridged from accounts
|
|
34
|
+
*/
|
|
35
|
+
export declare const isContactBridgedFromAccounts: (contactEntry: AddressBookEntry) => boolean;
|
|
36
|
+
//# sourceMappingURL=utils.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.mts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/contact-syncing/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAEjB,0CAA0C;AAG3C,OAAO,KAAK,EAAE,uBAAuB,EAAE,oBAAgB;AAEvD;;;GAGG;AACH,MAAM,MAAM,oBAAoB,GAAG,gBAAgB,GAAG;IACpD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,qCAAqC,qBAC9B,gBAAgB,KACjC,uBAyBF,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,qCAAqC,qBAC9B,uBAAuB,KACxC,oBAgBF,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,4BAA4B,iBACzB,gBAAgB,KAC7B,OAEF,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { USER_STORAGE_VERSION_KEY, USER_STORAGE_VERSION } from "./constants.mjs";
|
|
2
|
+
/**
|
|
3
|
+
* Map an address book entry to a user storage address book entry
|
|
4
|
+
* Always sets a current timestamp for entries going to remote storage
|
|
5
|
+
*
|
|
6
|
+
* @param addressBookEntry - An address book entry
|
|
7
|
+
* @returns A user storage address book entry
|
|
8
|
+
*/
|
|
9
|
+
export const mapAddressBookEntryToUserStorageEntry = (addressBookEntry) => {
|
|
10
|
+
const { address, name, chainId, memo, addressType, isEns, lastUpdatedAt, deletedAt, } = addressBookEntry;
|
|
11
|
+
const now = Date.now();
|
|
12
|
+
return {
|
|
13
|
+
[USER_STORAGE_VERSION_KEY]: USER_STORAGE_VERSION,
|
|
14
|
+
a: address,
|
|
15
|
+
n: name,
|
|
16
|
+
c: chainId,
|
|
17
|
+
...(memo ? { m: memo } : {}),
|
|
18
|
+
...(addressType ? { t: addressType } : {}),
|
|
19
|
+
...(isEns ? { e: isEns } : {}),
|
|
20
|
+
lu: lastUpdatedAt || now,
|
|
21
|
+
...(deletedAt ? { dt: deletedAt } : {}),
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Map a user storage address book entry to an address book entry
|
|
26
|
+
* Preserves sync metadata from remote storage while keeping the
|
|
27
|
+
* entry compatible with AddressBookController
|
|
28
|
+
*
|
|
29
|
+
* @param userStorageEntry - A user storage address book entry
|
|
30
|
+
* @returns An address book entry with sync metadata for internal use
|
|
31
|
+
*/
|
|
32
|
+
export const mapUserStorageEntryToAddressBookEntry = (userStorageEntry) => {
|
|
33
|
+
const addressBookEntry = {
|
|
34
|
+
address: userStorageEntry.a,
|
|
35
|
+
name: userStorageEntry.n,
|
|
36
|
+
chainId: userStorageEntry.c,
|
|
37
|
+
memo: userStorageEntry.m || '',
|
|
38
|
+
isEns: userStorageEntry.e || false,
|
|
39
|
+
...(userStorageEntry.t
|
|
40
|
+
? { addressType: userStorageEntry.t }
|
|
41
|
+
: {}),
|
|
42
|
+
// Include remote metadata for sync operation only (not stored in AddressBookController)
|
|
43
|
+
...(userStorageEntry.dt ? { deletedAt: userStorageEntry.dt } : {}),
|
|
44
|
+
...(userStorageEntry.lu ? { lastUpdatedAt: userStorageEntry.lu } : {}),
|
|
45
|
+
};
|
|
46
|
+
return addressBookEntry;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Check if a contact entry is bridged from accounts
|
|
50
|
+
* Contacts with chainId "*" are global accounts bridged from the accounts system
|
|
51
|
+
*
|
|
52
|
+
* @param contactEntry - The contact entry to check
|
|
53
|
+
* @returns True if the contact is bridged from accounts
|
|
54
|
+
*/
|
|
55
|
+
export const isContactBridgedFromAccounts = (contactEntry) => {
|
|
56
|
+
return String(contactEntry.chainId) === '*';
|
|
57
|
+
};
|
|
58
|
+
//# sourceMappingURL=utils.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.mjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/contact-syncing/utils.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,wBAAoB;AAY7E;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,qCAAqC,GAAG,CACnD,gBAAkC,EACT,EAAE;IAC3B,MAAM,EACJ,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P,wFAAwF;QACxF,GAAG,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,gBAAgB,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAClE,GAAG,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,gBAAgB,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACvE,CAAC;IAEF,OAAO,gBAAgB,CAAC;AAC1B,CAAC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAC1C,YAA8B,EACrB,EAAE;IACX,OAAO,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,KAAK,GAAG,CAAC;AAC9C,CAAC,CAAC","sourcesContent":["import type {\n AddressBookEntry,\n AddressType,\n} from '@metamask/address-book-controller';\n\nimport { USER_STORAGE_VERSION_KEY, USER_STORAGE_VERSION } from './constants';\nimport type { UserStorageContactEntry } from './types';\n\n/**\n * Extends AddressBookEntry with sync metadata\n * This is only used internally during the sync process and is not stored in AddressBookController\n */\nexport type SyncAddressBookEntry = AddressBookEntry & {\n lastUpdatedAt?: number;\n deletedAt?: number;\n};\n\n/**\n * Map an address book entry to a user storage address book entry\n * Always sets a current timestamp for entries going to remote storage\n *\n * @param addressBookEntry - An address book entry\n * @returns A user storage address book entry\n */\nexport const mapAddressBookEntryToUserStorageEntry = (\n addressBookEntry: AddressBookEntry,\n): UserStorageContactEntry => {\n const {\n address,\n name,\n chainId,\n memo,\n addressType,\n isEns,\n lastUpdatedAt,\n deletedAt,\n } = addressBookEntry as SyncAddressBookEntry;\n\n const now = Date.now();\n\n return {\n [USER_STORAGE_VERSION_KEY]: USER_STORAGE_VERSION,\n a: address,\n n: name,\n c: chainId,\n ...(memo ? { m: memo } : {}),\n ...(addressType ? { t: addressType } : {}),\n ...(isEns ? { e: isEns } : {}),\n lu: lastUpdatedAt || now,\n ...(deletedAt ? { dt: deletedAt } : {}),\n };\n};\n\n/**\n * Map a user storage address book entry to an address book entry\n * Preserves sync metadata from remote storage while keeping the\n * entry compatible with AddressBookController\n *\n * @param userStorageEntry - A user storage address book entry\n * @returns An address book entry with sync metadata for internal use\n */\nexport const mapUserStorageEntryToAddressBookEntry = (\n userStorageEntry: UserStorageContactEntry,\n): SyncAddressBookEntry => {\n const addressBookEntry: SyncAddressBookEntry = {\n address: userStorageEntry.a,\n name: userStorageEntry.n,\n chainId: userStorageEntry.c,\n memo: userStorageEntry.m || '',\n isEns: userStorageEntry.e || false,\n ...(userStorageEntry.t\n ? { addressType: userStorageEntry.t as AddressType }\n : {}),\n // Include remote metadata for sync operation only (not stored in AddressBookController)\n ...(userStorageEntry.dt ? { deletedAt: userStorageEntry.dt } : {}),\n ...(userStorageEntry.lu ? { lastUpdatedAt: userStorageEntry.lu } : {}),\n };\n\n return addressBookEntry;\n};\n\n/**\n * Check if a contact entry is bridged from accounts\n * Contacts with chainId \"*\" are global accounts bridged from the accounts system\n *\n * @param contactEntry - The contact entry to check\n * @returns True if the contact is bridged from accounts\n */\nexport const isContactBridgedFromAccounts = (\n contactEntry: AddressBookEntry,\n): boolean => {\n return String(contactEntry.chainId) === '*';\n};\n"]}
|
|
@@ -14,11 +14,13 @@ exports.USER_STORAGE_FEATURE_NAMES = {
|
|
|
14
14
|
notifications: 'notifications',
|
|
15
15
|
accounts: 'accounts_v2',
|
|
16
16
|
networks: 'networks',
|
|
17
|
+
addressBook: 'addressBook',
|
|
17
18
|
};
|
|
18
19
|
exports.USER_STORAGE_SCHEMA = {
|
|
19
20
|
[exports.USER_STORAGE_FEATURE_NAMES.notifications]: ['notification_settings'],
|
|
20
21
|
[exports.USER_STORAGE_FEATURE_NAMES.accounts]: [ALLOW_ARBITRARY_KEYS],
|
|
21
|
-
[exports.USER_STORAGE_FEATURE_NAMES.networks]: [ALLOW_ARBITRARY_KEYS],
|
|
22
|
+
[exports.USER_STORAGE_FEATURE_NAMES.networks]: [ALLOW_ARBITRARY_KEYS],
|
|
23
|
+
[exports.USER_STORAGE_FEATURE_NAMES.addressBook]: [ALLOW_ARBITRARY_KEYS], // keyed by address_chainId
|
|
22
24
|
};
|
|
23
25
|
const getFeatureAndKeyFromPath = (path, options = { validateAgainstSchema: true }) => {
|
|
24
26
|
const pathRegex = /^\w+\.\w+$/u;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage-schema.cjs","sourceRoot":"","sources":["../../src/shared/storage-schema.ts"],"names":[],"mappings":";;;AAAA,uDAAgD;AAEhD;;;;;;GAMG;AACH,MAAM,oBAAoB,GAAG,sBAA+B,CAAC;AAEhD,QAAA,0BAA0B,GAAG;IACxC,aAAa,EAAE,eAAe;IAC9B,QAAQ,EAAE,aAAa;IACvB,QAAQ,EAAE,UAAU;
|
|
1
|
+
{"version":3,"file":"storage-schema.cjs","sourceRoot":"","sources":["../../src/shared/storage-schema.ts"],"names":[],"mappings":";;;AAAA,uDAAgD;AAEhD;;;;;;GAMG;AACH,MAAM,oBAAoB,GAAG,sBAA+B,CAAC;AAEhD,QAAA,0BAA0B,GAAG;IACxC,aAAa,EAAE,eAAe;IAC9B,QAAQ,EAAE,aAAa;IACvB,QAAQ,EAAE,UAAU;IACpB,WAAW,EAAE,aAAa;CAClB,CAAC;AAKE,QAAA,mBAAmB,GAAG;IACjC,CAAC,kCAA0B,CAAC,aAAa,CAAC,EAAE,CAAC,uBAAuB,CAAC;IACrE,CAAC,kCAA0B,CAAC,QAAQ,CAAC,EAAE,CAAC,oBAAoB,CAAC;IAC7D,CAAC,kCAA0B,CAAC,QAAQ,CAAC,EAAE,CAAC,oBAAoB,CAAC;IAC7D,CAAC,kCAA0B,CAAC,WAAW,CAAC,EAAE,CAAC,oBAAoB,CAAC,EAAE,2BAA2B;CACrF,CAAC;AAuCJ,MAAM,wBAAwB,GAAG,CACtC,IAE2C,EAC3C,UAEI,EAAE,qBAAqB,EAAE,IAAS,EAAE,EAGN,EAAE;IACpC,M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G,IAAA,6BAAgB,EAAC,GAAG,GAAG,UAAU,CAAC,CAAC;IAErD,OAAO,GAAG,OAAO,IAAI,SAAS,EAAE,CAAC;AACnC,CAAC;AAbD,0CAaC","sourcesContent":["import { createSHA256Hash } from './encryption';\n\n/**\n * The User Storage Endpoint requires a feature name and a namespace key.\n * Developers can provide additional features and keys by extending these types below.\n *\n * Adding ALLOW_ARBITRARY_KEYS as the first key in the array allows for any key to be used for this feature.\n * This can be useful for features where keys are not deterministic (eg. accounts addresses).\n */\nconst ALLOW_ARBITRARY_KEYS = 'ALLOW_ARBITRARY_KEYS' as const;\n\nexport const USER_STORAGE_FEATURE_NAMES = {\n notifications: 'notifications',\n accounts: 'accounts_v2',\n networks: 'networks',\n addressBook: 'addressBook',\n} as const;\n\nexport type UserStorageFeatureNames =\n (typeof USER_STORAGE_FEATURE_NAMES)[keyof typeof USER_STORAGE_FEATURE_NAMES];\n\nexport const USER_STORAGE_SCHEMA = {\n [USER_STORAGE_FEATURE_NAMES.notifications]: ['notification_settings'],\n [USER_STORAGE_FEATURE_NAMES.accounts]: [ALLOW_ARBITRARY_KEYS], // keyed by account addresses\n [USER_STORAGE_FEATURE_NAMES.networks]: [ALLOW_ARBITRARY_KEYS], // keyed by chains/networks\n [USER_STORAGE_FEATURE_NAMES.addressBook]: [ALLOW_ARBITRARY_KEYS], // keyed by address_chainId\n} as const;\n\ntype UserStorageSchema = typeof USER_STORAGE_SCHEMA;\n\nexport type UserStorageFeatureKeys<Feature extends UserStorageFeatureNames> =\n UserStorageSchema[Feature][0] extends typeof ALLOW_ARBITRARY_KEYS\n ? string\n : UserStorageSchema[Feature][number];\n\ntype UserStorageFeatureAndKey = {\n feature: UserStorageFeatureNames;\n key: UserStorageFeatureKeys<UserStorageFeatureNames>;\n};\n\nexport type UserStoragePathWithFeatureOnly = UserStorageFeatureNames;\nexport type UserStoragePathWithFeatureAndKey = {\n [K in UserStorageFeatureNames]: `${K}.${UserStorageFeatureKeys<K>}`;\n}[UserStoragePathWithFeatureOnly];\n\n/**\n * The below types are mainly used for the SDK.\n * These exist so that the SDK can be used with arbitrary feature names and keys.\n *\n * We only type enforce feature names and keys when using UserStorageController.\n * This is done so we don't end up with magic strings within the applications.\n */\n\nexport type UserStorageGenericFeatureName = string;\nexport type UserStorageGenericFeatureKey = string;\nexport type UserStorageGenericPathWithFeatureAndKey =\n `${UserStorageGenericFeatureName}.${UserStorageGenericFeatureKey}`;\nexport type UserStorageGenericPathWithFeatureOnly =\n UserStorageGenericFeatureName;\n\ntype UserStorageGenericFeatureAndKey = {\n feature: UserStorageGenericFeatureName;\n key: UserStorageGenericFeatureKey;\n};\n\nexport const getFeatureAndKeyFromPath = <T extends boolean>(\n path: T extends true\n ? UserStoragePathWithFeatureAndKey\n : UserStorageGenericPathWithFeatureAndKey,\n options: {\n validateAgainstSchema: T;\n } = { validateAgainstSchema: true as T },\n): T extends true\n ? UserStorageFeatureAndKey\n : UserStorageGenericFeatureAndKey => {\n const pathRegex = /^\\w+\\.\\w+$/u;\n\n if (!pathRegex.test(path)) {\n throw new Error(\n `user-storage - path is not in the correct format. Correct format: 'feature.key'`,\n );\n }\n\n const [feature, key] = path.split('.');\n\n if (options.validateAgainstSchema) {\n const featureToValidate = feature as UserStorageFeatureNames;\n const keyToValidate = key as UserStorageFeatureKeys<\n typeof featureToValidate\n >;\n\n if (!(featureToValidate in USER_STORAGE_SCHEMA)) {\n throw new Error(\n `user-storage - invalid feature provided: ${featureToValidate}. Valid features: ${Object.keys(\n USER_STORAGE_SCHEMA,\n ).join(', ')}`,\n );\n }\n\n const validFeature = USER_STORAGE_SCHEMA[\n featureToValidate\n ] as readonly string[];\n\n if (\n !validFeature.includes(keyToValidate) &&\n !validFeature.includes(ALLOW_ARBITRARY_KEYS)\n ) {\n const validKeys = USER_STORAGE_SCHEMA[featureToValidate].join(', ');\n\n throw new Error(\n `user-storage - invalid key provided for this feature: ${keyToValidate}. Valid keys: ${validKeys}`,\n );\n }\n }\n\n return { feature, key } as T extends true\n ? UserStorageFeatureAndKey\n : UserStorageGenericFeatureAndKey;\n};\n\n/**\n * Constructs a unique entry path for a user.\n * This can be done due to the uniqueness of the storage key (no users will share the same storage key).\n * The users entry is a unique hash that cannot be reversed.\n *\n * @param path - string in the form of `${feature}.${key}` that matches schema\n * @param storageKey - users storage key\n * @param options - options object\n * @param options.validateAgainstSchema - whether to validate the path against the schema.\n * This defaults to true, and should only be set to false when using the SDK with arbitrary feature names and keys.\n * @returns path to store entry\n */\nexport function createEntryPath<T extends boolean>(\n path: T extends true\n ? UserStoragePathWithFeatureAndKey\n : UserStorageGenericPathWithFeatureAndKey,\n storageKey: string,\n options: {\n validateAgainstSchema: T;\n } = { validateAgainstSchema: true as T },\n): string {\n const { feature, key } = getFeatureAndKeyFromPath(path, options);\n const hashedKey = createSHA256Hash(key + storageKey);\n\n return `${feature}/${hashedKey}`;\n}\n"]}
|
|
@@ -10,12 +10,14 @@ export declare const USER_STORAGE_FEATURE_NAMES: {
|
|
|
10
10
|
readonly notifications: "notifications";
|
|
11
11
|
readonly accounts: "accounts_v2";
|
|
12
12
|
readonly networks: "networks";
|
|
13
|
+
readonly addressBook: "addressBook";
|
|
13
14
|
};
|
|
14
15
|
export type UserStorageFeatureNames = (typeof USER_STORAGE_FEATURE_NAMES)[keyof typeof USER_STORAGE_FEATURE_NAMES];
|
|
15
16
|
export declare const USER_STORAGE_SCHEMA: {
|
|
16
17
|
readonly notifications: readonly ["notification_settings"];
|
|
17
18
|
readonly accounts_v2: readonly ["ALLOW_ARBITRARY_KEYS"];
|
|
18
19
|
readonly networks: readonly ["ALLOW_ARBITRARY_KEYS"];
|
|
20
|
+
readonly addressBook: readonly ["ALLOW_ARBITRARY_KEYS"];
|
|
19
21
|
};
|
|
20
22
|
type UserStorageSchema = typeof USER_STORAGE_SCHEMA;
|
|
21
23
|
export type UserStorageFeatureKeys<Feature extends UserStorageFeatureNames> = UserStorageSchema[Feature][0] extends typeof ALLOW_ARBITRARY_KEYS ? string : UserStorageSchema[Feature][number];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage-schema.d.cts","sourceRoot":"","sources":["../../src/shared/storage-schema.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,QAAA,MAAM,oBAAoB,wBAAkC,CAAC;AAE7D,eAAO,MAAM,0BAA0B
|
|
1
|
+
{"version":3,"file":"storage-schema.d.cts","sourceRoot":"","sources":["../../src/shared/storage-schema.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,QAAA,MAAM,oBAAoB,wBAAkC,CAAC;AAE7D,eAAO,MAAM,0BAA0B;;;;;CAK7B,CAAC;AAEX,MAAM,MAAM,uBAAuB,GACjC,CAAC,OAAO,0BAA0B,CAAC,CAAC,MAAM,OAAO,0BAA0B,CAAC,CAAC;AAE/E,eAAO,MAAM,mBAAmB;;;;;CAKtB,CAAC;AAEX,KAAK,iBAAiB,GAAG,OAAO,mBAAmB,CAAC;AAEpD,MAAM,MAAM,sBAAsB,CAAC,OAAO,SAAS,uBAAuB,IACxE,iBAAiB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS,OAAO,oBAAoB,GAC7D,MAAM,GACN,iBAAiB,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC;AAEzC,KAAK,wBAAwB,GAAG;IAC9B,OAAO,EAAE,uBAAuB,CAAC;IACjC,GAAG,EAAE,sBAAsB,CAAC,uBAAuB,CAAC,CAAC;CACtD,CAAC;AAEF,MAAM,MAAM,8BAA8B,GAAG,uBAAuB,CAAC;AACrE,MAAM,MAAM,gCAAgC,GAAG;KAC5C,CAAC,IAAI,uBAAuB,GAAG,GAAG,CAAC,IAAI,sBAAsB,CAAC,CAAC,CAAC,EAAE;CACpE,CAAC,8BAA8B,CAAC,CAAC;AAElC;;;;;;GAMG;AAEH,MAAM,MAAM,6BAA6B,GAAG,MAAM,CAAC;AACnD,MAAM,MAAM,4BAA4B,GAAG,MAAM,CAAC;AAClD,MAAM,MAAM,uCAAuC,GACjD,GAAG,6BAA6B,IAAI,4BAA4B,EAAE,CAAC;AACrE,MAAM,MAAM,qCAAqC,GAC/C,6BAA6B,CAAC;AAEhC,KAAK,+BAA+B,GAAG;IACrC,OAAO,EAAE,6BAA6B,CAAC;IACvC,GAAG,EAAE,4BAA4B,CAAC;CACnC,CAAC;AAEF,eAAO,MAAM,wBAAwB;;iFAqDpC,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS,OAAO,EAC/C,IAAI,EAAE,CAAC,SAAS,IAAI,GAChB,gCAAgC,GAChC,uCAAuC,EAC3C,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE;IACP,qBAAqB,EAAE,CAAC,CAAC;CACa,GACvC,MAAM,CAKR"}
|
|
@@ -10,12 +10,14 @@ export declare const USER_STORAGE_FEATURE_NAMES: {
|
|
|
10
10
|
readonly notifications: "notifications";
|
|
11
11
|
readonly accounts: "accounts_v2";
|
|
12
12
|
readonly networks: "networks";
|
|
13
|
+
readonly addressBook: "addressBook";
|
|
13
14
|
};
|
|
14
15
|
export type UserStorageFeatureNames = (typeof USER_STORAGE_FEATURE_NAMES)[keyof typeof USER_STORAGE_FEATURE_NAMES];
|
|
15
16
|
export declare const USER_STORAGE_SCHEMA: {
|
|
16
17
|
readonly notifications: readonly ["notification_settings"];
|
|
17
18
|
readonly accounts_v2: readonly ["ALLOW_ARBITRARY_KEYS"];
|
|
18
19
|
readonly networks: readonly ["ALLOW_ARBITRARY_KEYS"];
|
|
20
|
+
readonly addressBook: readonly ["ALLOW_ARBITRARY_KEYS"];
|
|
19
21
|
};
|
|
20
22
|
type UserStorageSchema = typeof USER_STORAGE_SCHEMA;
|
|
21
23
|
export type UserStorageFeatureKeys<Feature extends UserStorageFeatureNames> = UserStorageSchema[Feature][0] extends typeof ALLOW_ARBITRARY_KEYS ? string : UserStorageSchema[Feature][number];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage-schema.d.mts","sourceRoot":"","sources":["../../src/shared/storage-schema.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,QAAA,MAAM,oBAAoB,wBAAkC,CAAC;AAE7D,eAAO,MAAM,0BAA0B
|
|
1
|
+
{"version":3,"file":"storage-schema.d.mts","sourceRoot":"","sources":["../../src/shared/storage-schema.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,QAAA,MAAM,oBAAoB,wBAAkC,CAAC;AAE7D,eAAO,MAAM,0BAA0B;;;;;CAK7B,CAAC;AAEX,MAAM,MAAM,uBAAuB,GACjC,CAAC,OAAO,0BAA0B,CAAC,CAAC,MAAM,OAAO,0BAA0B,CAAC,CAAC;AAE/E,eAAO,MAAM,mBAAmB;;;;;CAKtB,CAAC;AAEX,KAAK,iBAAiB,GAAG,OAAO,mBAAmB,CAAC;AAEpD,MAAM,MAAM,sBAAsB,CAAC,OAAO,SAAS,uBAAuB,IACxE,iBAAiB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS,OAAO,oBAAoB,GAC7D,MAAM,GACN,iBAAiB,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC;AAEzC,KAAK,wBAAwB,GAAG;IAC9B,OAAO,EAAE,uBAAuB,CAAC;IACjC,GAAG,EAAE,sBAAsB,CAAC,uBAAuB,CAAC,CAAC;CACtD,CAAC;AAEF,MAAM,MAAM,8BAA8B,GAAG,uBAAuB,CAAC;AACrE,MAAM,MAAM,gCAAgC,GAAG;KAC5C,CAAC,IAAI,uBAAuB,GAAG,GAAG,CAAC,IAAI,sBAAsB,CAAC,CAAC,CAAC,EAAE;CACpE,CAAC,8BAA8B,CAAC,CAAC;AAElC;;;;;;GAMG;AAEH,MAAM,MAAM,6BAA6B,GAAG,MAAM,CAAC;AACnD,MAAM,MAAM,4BAA4B,GAAG,MAAM,CAAC;AAClD,MAAM,MAAM,uCAAuC,GACjD,GAAG,6BAA6B,IAAI,4BAA4B,EAAE,CAAC;AACrE,MAAM,MAAM,qCAAqC,GAC/C,6BAA6B,CAAC;AAEhC,KAAK,+BAA+B,GAAG;IACrC,OAAO,EAAE,6BAA6B,CAAC;IACvC,GAAG,EAAE,4BAA4B,CAAC;CACnC,CAAC;AAEF,eAAO,MAAM,wBAAwB;;iFAqDpC,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS,OAAO,EAC/C,IAAI,EAAE,CAAC,SAAS,IAAI,GAChB,gCAAgC,GAChC,uCAAuC,EAC3C,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE;IACP,qBAAqB,EAAE,CAAC,CAAC;CACa,GACvC,MAAM,CAKR"}
|
|
@@ -11,11 +11,13 @@ export const USER_STORAGE_FEATURE_NAMES = {
|
|
|
11
11
|
notifications: 'notifications',
|
|
12
12
|
accounts: 'accounts_v2',
|
|
13
13
|
networks: 'networks',
|
|
14
|
+
addressBook: 'addressBook',
|
|
14
15
|
};
|
|
15
16
|
export const USER_STORAGE_SCHEMA = {
|
|
16
17
|
[USER_STORAGE_FEATURE_NAMES.notifications]: ['notification_settings'],
|
|
17
18
|
[USER_STORAGE_FEATURE_NAMES.accounts]: [ALLOW_ARBITRARY_KEYS],
|
|
18
|
-
[USER_STORAGE_FEATURE_NAMES.networks]: [ALLOW_ARBITRARY_KEYS],
|
|
19
|
+
[USER_STORAGE_FEATURE_NAMES.networks]: [ALLOW_ARBITRARY_KEYS],
|
|
20
|
+
[USER_STORAGE_FEATURE_NAMES.addressBook]: [ALLOW_ARBITRARY_KEYS], // keyed by address_chainId
|
|
19
21
|
};
|
|
20
22
|
export const getFeatureAndKeyFromPath = (path, options = { validateAgainstSchema: true }) => {
|
|
21
23
|
const pathRegex = /^\w+\.\w+$/u;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage-schema.mjs","sourceRoot":"","sources":["../../src/shared/storage-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,+BAAqB;AAEhD;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MAAM,iBAAiB,GAAG,OAAkC,CAAC;QAC7D,MAAM,aAAa,GAAG,GAErB,CAAC;QAEF,IAAI,CAAC,CAAC,iBAAiB,IAAI,mBAAmB,CAAC,EAAE;YAC/C,MAAM,IAAI,KAAK,CACb,4CAA4C,iBAAiB,qBAAqB,MAAM,CAAC,IAAI,CAC3F,mBAAmB,CACpB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CACf,CAAC;SACH;QAED,MAAM,YAAY,GAAG,mBAAmB,CACtC,iBAAiB,CACG,CAAC;QAEvB,IACE,CAAC,YAAY,CAAC,QAAQ,CAAC,aAAa,CAAC;YACrC,CAAC,YAAY,CAAC,QAAQ,CAAC,oBAAoB,CAAC,EAC5C;YACA,MAAM,SAAS,GAAG,mBAAmB,CAAC,iBAAiB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAEpE,MAAM,IAAI,KAAK,CACb,yDAAyD,aAAa,iBAAiB,SAAS,EAAE,CACnG,CAAC;SACH;KACF;IAED,OAAO,EAAE,OAAO,EAAE,GAAG,EAEc,CAAC;AACtC,CAAC,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,eAAe,CAC7B,IAE2C,EAC3C,UAAkB,EAClB,UAEI,EAAE,qBAAqB,EAAE,IAAS,EAAE;IAExC,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,wBAAwB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACjE,MAAM,SAAS,GAAG,gBAAgB,CAAC,GAAG,GAAG,UAAU,CAAC,CAAC;IAErD,OAAO,GAAG,OAAO,IAAI,SAAS,EAAE,CAAC;AACnC,CAAC","sourcesContent":["import { createSHA256Hash } from './encryption';\n\n/**\n * The User Storage Endpoint requires a feature name and a namespace key.\n * Developers can provide additional features and keys by extending these types below.\n *\n * Adding ALLOW_ARBITRARY_KEYS as the first key in the array allows for any key to be used for this feature.\n * This can be useful for features where keys are not deterministic (eg. accounts addresses).\n */\nconst ALLOW_ARBITRARY_KEYS = 'ALLOW_ARBITRARY_KEYS' as const;\n\nexport const USER_STORAGE_FEATURE_NAMES = {\n notifications: 'notifications',\n accounts: 'accounts_v2',\n networks: 'networks',\n addressBook: 'addressBook',\n} as const;\n\nexport type UserStorageFeatureNames =\n (typeof USER_STORAGE_FEATURE_NAMES)[keyof typeof USER_STORAGE_FEATURE_NAMES];\n\nexport const USER_STORAGE_SCHEMA = {\n [USER_STORAGE_FEATURE_NAMES.notifications]: ['notification_settings'],\n [USER_STORAGE_FEATURE_NAMES.accounts]: [ALLOW_ARBITRARY_KEYS], // keyed by account addresses\n [USER_STORAGE_FEATURE_NAMES.networks]: [ALLOW_ARBITRARY_KEYS], // keyed by chains/networks\n [USER_STORAGE_FEATURE_NAMES.addressBook]: [ALLOW_ARBITRARY_KEYS], // keyed by address_chainId\n} as const;\n\ntype UserStorageSchema = typeof USER_STORAGE_SCHEMA;\n\nexport type UserStorageFeatureKeys<Feature extends UserStorageFeatureNames> =\n UserStorageSchema[Feature][0] extends typeof ALLOW_ARBITRARY_KEYS\n ? string\n : UserStorageSchema[Feature][number];\n\ntype UserStorageFeatureAndKey = {\n feature: UserStorageFeatureNames;\n key: UserStorageFeatureKeys<UserStorageFeatureNames>;\n};\n\nexport type UserStoragePathWithFeatureOnly = UserStorageFeatureNames;\nexport type UserStoragePathWithFeatureAndKey = {\n [K in UserStorageFeatureNames]: `${K}.${UserStorageFeatureKeys<K>}`;\n}[UserStoragePathWithFeatureOnly];\n\n/**\n * The below types are mainly used for the SDK.\n * These exist so that the SDK can be used with arbitrary feature names and keys.\n *\n * We only type enforce feature names and keys when using UserStorageController.\n * This is done so we don't end up with magic strings within the applications.\n */\n\nexport type UserStorageGenericFeatureName = string;\nexport type UserStorageGenericFeatureKey = string;\nexport type UserStorageGenericPathWithFeatureAndKey =\n `${UserStorageGenericFeatureName}.${UserStorageGenericFeatureKey}`;\nexport type UserStorageGenericPathWithFeatureOnly =\n UserStorageGenericFeatureName;\n\ntype UserStorageGenericFeatureAndKey = {\n feature: UserStorageGenericFeatureName;\n key: UserStorageGenericFeatureKey;\n};\n\nexport const getFeatureAndKeyFromPath = <T extends boolean>(\n path: T extends true\n ? UserStoragePathWithFeatureAndKey\n : UserStorageGenericPathWithFeatureAndKey,\n options: {\n validateAgainstSchema: T;\n } = { validateAgainstSchema: true as T },\n): T extends true\n ? UserStorageFeatureAndKey\n : UserStorageGenericFeatureAndKey => {\n const pathRegex = /^\\w+\\.\\w+$/u;\n\n if (!pathRegex.test(path)) {\n throw new Error(\n `user-storage - path is not in the correct format. Correct format: 'feature.key'`,\n );\n }\n\n const [feature, key] = path.split('.');\n\n if (options.validateAgainstSchema) {\n const featureToValidate = feature as UserStorageFeatureNames;\n const keyToValidate = key as UserStorageFeatureKeys<\n typeof featureToValidate\n >;\n\n if (!(featureToValidate in USER_STORAGE_SCHEMA)) {\n throw new Error(\n `user-storage - invalid feature provided: ${featureToValidate}. Valid features: ${Object.keys(\n USER_STORAGE_SCHEMA,\n ).join(', ')}`,\n );\n }\n\n const validFeature = USER_STORAGE_SCHEMA[\n featureToValidate\n ] as readonly string[];\n\n if (\n !validFeature.includes(keyToValidate) &&\n !validFeature.includes(ALLOW_ARBITRARY_KEYS)\n ) {\n const validKeys = USER_STORAGE_SCHEMA[featureToValidate].join(', ');\n\n throw new Error(\n `user-storage - invalid key provided for this feature: ${keyToValidate}. Valid keys: ${validKeys}`,\n );\n }\n }\n\n return { feature, key } as T extends true\n ? UserStorageFeatureAndKey\n : UserStorageGenericFeatureAndKey;\n};\n\n/**\n * Constructs a unique entry path for a user.\n * This can be done due to the uniqueness of the storage key (no users will share the same storage key).\n * The users entry is a unique hash that cannot be reversed.\n *\n * @param path - string in the form of `${feature}.${key}` that matches schema\n * @param storageKey - users storage key\n * @param options - options object\n * @param options.validateAgainstSchema - whether to validate the path against the schema.\n * This defaults to true, and should only be set to false when using the SDK with arbitrary feature names and keys.\n * @returns path to store entry\n */\nexport function createEntryPath<T extends boolean>(\n path: T extends true\n ? UserStoragePathWithFeatureAndKey\n : UserStorageGenericPathWithFeatureAndKey,\n storageKey: string,\n options: {\n validateAgainstSchema: T;\n } = { validateAgainstSchema: true as T },\n): string {\n const { feature, key } = getFeatureAndKeyFromPath(path, options);\n const hashedKey = createSHA256Hash(key + storageKey);\n\n return `${feature}/${hashedKey}`;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metamask-previews/profile-sync-controller",
|
|
3
|
-
"version": "17.0.0-preview-
|
|
3
|
+
"version": "17.0.0-preview-4da9cec1",
|
|
4
4
|
"description": "The profile sync helps developers synchronize data across multiple clients and devices in a privacy-preserving way. All data saved in the user storage database is encrypted client-side to preserve privacy. The user storage provides a modular design, giving developers the flexibility to construct and manage their storage spaces in a way that best suits their needs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"MetaMask",
|