@metamask/profile-sync-controller 16.0.0 → 17.0.0
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 +15 -1
- 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 +77 -27
- package/dist/controllers/user-storage/UserStorageController.cjs.map +1 -1
- package/dist/controllers/user-storage/UserStorageController.d.cts +24 -10
- package/dist/controllers/user-storage/UserStorageController.d.cts.map +1 -1
- package/dist/controllers/user-storage/UserStorageController.d.mts +24 -10
- package/dist/controllers/user-storage/UserStorageController.d.mts.map +1 -1
- package/dist/controllers/user-storage/UserStorageController.mjs +77 -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/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 +1 -6
- package/dist/shared/storage-schema.cjs.map +1 -1
- package/dist/shared/storage-schema.d.cts +0 -1
- package/dist/shared/storage-schema.d.cts.map +1 -1
- package/dist/shared/storage-schema.d.mts +0 -1
- package/dist/shared/storage-schema.d.mts.map +1 -1
- package/dist/shared/storage-schema.mjs +0 -4
- package/dist/shared/storage-schema.mjs.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage-schema.d.mts","sourceRoot":"","sources":["../../src/shared/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B;;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"}
|
|
@@ -38,10 +38,6 @@ export const getFeatureAndKeyFromPath = (path, options = { validateAgainstSchema
|
|
|
38
38
|
}
|
|
39
39
|
return { feature, key };
|
|
40
40
|
};
|
|
41
|
-
export const isPathWithFeatureAndKey = (path) => {
|
|
42
|
-
const pathRegex = /^\w+\.\w+$/u;
|
|
43
|
-
return pathRegex.test(path);
|
|
44
|
-
};
|
|
45
41
|
/**
|
|
46
42
|
* Constructs a unique entry path for a user.
|
|
47
43
|
* This can be done due to the uniqueness of the storage key (no users will share the same storage key).
|
|
@@ -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;;;;;;GAMG;AACH,MAAM,oBAAoB,GAAG,sBAA+B,CAAC;AAE7D,MAAM,CAAC,MAAM,0BAA0B,GAAG;IACxC,aAAa,EAAE,eAAe;IAC9B,QAAQ,EAAE,aAAa;IACvB,QAAQ,EAAE,UAAU;CACZ,CAAC;AAKX,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,CAAC,0BAA0B,CAAC,aAAa,CAAC,EAAE,CAAC,uBAAuB,CAAC;IACrE,CAAC,0BAA0B,CAAC,QAAQ,CAAC,EAAE,CAAC,oBAAoB,CAAC;IAC7D,CAAC,0BAA0B,CAAC,QAAQ,CAAC,EAAE,CAAC,oBAAoB,CAAC,EAAE,2BAA2B;CAClF,CAAC;AAuCX,MAAM,CAAC,MAAM,wBAAwB,GAAG,CACtC,IAE2C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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} 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} 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/profile-sync-controller",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "17.0.0",
|
|
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",
|
|
@@ -101,7 +101,6 @@
|
|
|
101
101
|
},
|
|
102
102
|
"dependencies": {
|
|
103
103
|
"@metamask/base-controller": "^8.0.1",
|
|
104
|
-
"@metamask/keyring-api": "^18.0.0",
|
|
105
104
|
"@metamask/snaps-sdk": "^7.1.0",
|
|
106
105
|
"@metamask/snaps-utils": "^9.4.0",
|
|
107
106
|
"@noble/ciphers": "^0.5.2",
|
|
@@ -115,6 +114,7 @@
|
|
|
115
114
|
"@lavamoat/preinstall-always-fail": "^2.1.0",
|
|
116
115
|
"@metamask/accounts-controller": "^30.0.0",
|
|
117
116
|
"@metamask/auto-changelog": "^3.4.4",
|
|
117
|
+
"@metamask/keyring-api": "^18.0.0",
|
|
118
118
|
"@metamask/keyring-controller": "^22.0.1",
|
|
119
119
|
"@metamask/keyring-internal-api": "^6.2.0",
|
|
120
120
|
"@metamask/network-controller": "^23.5.1",
|