@metamask/profile-sync-controller 32.1.1 → 32.3.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 +27 -1
- package/README.md +21 -0
- package/dist/controllers/authentication/AuthenticationController-method-action-types.d.ts +80 -1
- package/dist/controllers/authentication/AuthenticationController-method-action-types.d.ts.map +1 -1
- package/dist/controllers/authentication/AuthenticationController-method-action-types.js.map +1 -1
- package/dist/controllers/authentication/AuthenticationController.d.ts +79 -2
- package/dist/controllers/authentication/AuthenticationController.d.ts.map +1 -1
- package/dist/controllers/authentication/AuthenticationController.js +374 -12
- package/dist/controllers/authentication/AuthenticationController.js.map +1 -1
- package/dist/controllers/authentication/index.d.ts +1 -1
- package/dist/controllers/authentication/index.d.ts.map +1 -1
- package/dist/controllers/authentication/index.js.map +1 -1
- package/dist/controllers/authentication/mocks/mockResponses.d.ts +5 -0
- package/dist/controllers/authentication/mocks/mockResponses.d.ts.map +1 -1
- package/dist/controllers/authentication/mocks/mockResponses.js +26 -1
- package/dist/controllers/authentication/mocks/mockResponses.js.map +1 -1
- package/dist/controllers/user-storage/UserStorageController.d.ts.map +1 -1
- package/dist/controllers/user-storage/UserStorageController.js +6 -5
- package/dist/controllers/user-storage/UserStorageController.js.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/flow-srp.d.ts +60 -2
- package/dist/sdk/authentication-jwt-bearer/flow-srp.d.ts.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/flow-srp.js +122 -2
- package/dist/sdk/authentication-jwt-bearer/flow-srp.js.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/mfa/schemas.d.ts +693 -0
- package/dist/sdk/authentication-jwt-bearer/mfa/schemas.d.ts.map +1 -0
- package/dist/sdk/authentication-jwt-bearer/mfa/schemas.js +266 -0
- package/dist/sdk/authentication-jwt-bearer/mfa/schemas.js.map +1 -0
- package/dist/sdk/authentication-jwt-bearer/mfa/services.d.ts +104 -0
- package/dist/sdk/authentication-jwt-bearer/mfa/services.d.ts.map +1 -0
- package/dist/sdk/authentication-jwt-bearer/mfa/services.js +368 -0
- package/dist/sdk/authentication-jwt-bearer/mfa/services.js.map +1 -0
- package/dist/sdk/authentication-jwt-bearer/mfa/types.d.ts +125 -0
- package/dist/sdk/authentication-jwt-bearer/mfa/types.d.ts.map +1 -0
- package/dist/sdk/authentication-jwt-bearer/mfa/types.js +3 -0
- package/dist/sdk/authentication-jwt-bearer/mfa/types.js.map +1 -0
- package/dist/sdk/authentication-jwt-bearer/services.d.ts +4 -5
- package/dist/sdk/authentication-jwt-bearer/services.d.ts.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/services.js +7 -4
- package/dist/sdk/authentication-jwt-bearer/services.js.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/types.d.ts +9 -0
- package/dist/sdk/authentication-jwt-bearer/types.d.ts.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/types.js.map +1 -1
- package/dist/sdk/authentication.d.ts +17 -7
- package/dist/sdk/authentication.d.ts.map +1 -1
- package/dist/sdk/authentication.js +25 -1
- package/dist/sdk/authentication.js.map +1 -1
- package/dist/sdk/constants.d.ts +3 -0
- package/dist/sdk/constants.d.ts.map +1 -1
- package/dist/sdk/constants.js +3 -0
- package/dist/sdk/constants.js.map +1 -1
- package/dist/sdk/errors.d.ts +106 -0
- package/dist/sdk/errors.d.ts.map +1 -1
- package/dist/sdk/errors.js +179 -0
- package/dist/sdk/errors.js.map +1 -1
- package/dist/sdk/index.d.ts +3 -0
- package/dist/sdk/index.d.ts.map +1 -1
- package/dist/sdk/index.js +1 -0
- package/dist/sdk/index.js.map +1 -1
- package/dist/sdk/mocks/auth.d.ts +63 -0
- package/dist/sdk/mocks/auth.d.ts.map +1 -1
- package/dist/sdk/mocks/auth.js +90 -0
- package/dist/sdk/mocks/auth.js.map +1 -1
- package/dist/sdk/utils/as-record.d.ts +10 -0
- package/dist/sdk/utils/as-record.d.ts.map +1 -0
- package/dist/sdk/utils/as-record.js +14 -0
- package/dist/sdk/utils/as-record.js.map +1 -0
- package/dist/sdk/utils/jwt.d.ts +13 -0
- package/dist/sdk/utils/jwt.d.ts.map +1 -0
- package/dist/sdk/utils/jwt.js +21 -0
- package/dist/sdk/utils/jwt.js.map +1 -0
- package/dist/sdk/utils/to-error-message.d.ts +8 -0
- package/dist/sdk/utils/to-error-message.d.ts.map +1 -0
- package/dist/sdk/utils/to-error-message.js +10 -0
- package/dist/sdk/utils/to-error-message.js.map +1 -0
- package/dist/sdk/utils/validate-login-response.d.ts.map +1 -1
- package/dist/sdk/utils/validate-login-response.js +5 -7
- package/dist/sdk/utils/validate-login-response.js.map +1 -1
- package/dist/sdk/utils/validate-pair-response.d.ts +4 -0
- package/dist/sdk/utils/validate-pair-response.d.ts.map +1 -1
- package/dist/sdk/utils/validate-pair-response.js.map +1 -1
- package/dist/shared/storage-schema.d.ts +1 -0
- package/dist/shared/storage-schema.d.ts.map +1 -1
- package/dist/shared/storage-schema.js +1 -0
- package/dist/shared/storage-schema.js.map +1 -1
- package/dist/shared/utils/entropy-source.d.ts +3 -12
- package/dist/shared/utils/entropy-source.d.ts.map +1 -1
- package/dist/shared/utils/entropy-source.js +4 -17
- package/dist/shared/utils/entropy-source.js.map +1 -1
- package/package.json +12 -9
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { decodeJwtPayload } from './jwt.js';
|
|
1
2
|
/**
|
|
2
3
|
* Validates that the input is a well-formed, non-expired LoginResponse.
|
|
3
4
|
*
|
|
@@ -30,13 +31,10 @@ export function validateLoginResponse(input) {
|
|
|
30
31
|
*/
|
|
31
32
|
function isJwtExpired(token) {
|
|
32
33
|
try {
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const base64 = parts[1].replace(/-/gu, '+').replace(/_/gu, '/');
|
|
38
|
-
const { exp } = JSON.parse(atob(base64));
|
|
39
|
-
return !Number.isInteger(exp) || exp * 1000 <= Date.now();
|
|
34
|
+
const { exp } = decodeJwtPayload(token);
|
|
35
|
+
return (typeof exp !== 'number' ||
|
|
36
|
+
!Number.isInteger(exp) ||
|
|
37
|
+
exp * 1000 <= Date.now());
|
|
40
38
|
}
|
|
41
39
|
catch {
|
|
42
40
|
return true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-login-response.js","sourceRoot":"","sources":["../../../src/sdk/utils/validate-login-response.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"validate-login-response.js","sourceRoot":"","sources":["../../../src/sdk/utils/validate-login-response.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE5C;;;;;;;;;;GAUG;AACH,MAAM,UAAU,qBAAqB,CAAC,KAAc;IAClD,MAAM,YAAY,GAAG,KAAsB,CAAC;IAE5C,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,CAAC,YAAY,EAAE,KAAK,IAAI,CAAC,YAAY,EAAE,OAAO,EAAE,CAAC;QACnD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,YAAY,CAAC,YAAY,CAAC,KAAK,CAAC,WAAW,CAAC,EAAE,CAAC;QACjD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;GAKG;AACH,SAAS,YAAY,CAAC,KAAa;IACjC,IAAI,CAAC;QACH,MAAM,EAAE,GAAG,EAAE,GAAG,gBAAgB,CAAC,KAAK,CAAsB,CAAC;QAC7D,OAAO,CACL,OAAO,GAAG,KAAK,QAAQ;YACvB,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC;YACtB,GAAG,GAAG,IAAI,IAAI,IAAI,CAAC,GAAG,EAAE,CACzB,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC","sourcesContent":["import type { LoginResponse } from '../authentication.js';\nimport { decodeJwtPayload } from './jwt.js';\n\n/**\n * Validates that the input is a well-formed, non-expired LoginResponse.\n *\n * Checks structural shape (token + profile objects exist) and verifies\n * the JWT access token's `exp` claim is still in the future. This acts\n * as a hard guard against stale cached tokens regardless of client-side\n * TTL tracking (obtainedAt / expiresIn), which can be corrupted.\n *\n * @param input - unknown/untyped input\n * @returns boolean if input is a valid, non-expired LoginResponse\n */\nexport function validateLoginResponse(input: unknown): input is LoginResponse {\n const assumedInput = input as LoginResponse;\n\n if (!assumedInput) {\n return false;\n }\n\n if (!assumedInput?.token || !assumedInput?.profile) {\n return false;\n }\n\n if (isJwtExpired(assumedInput.token.accessToken)) {\n return false;\n }\n\n return true;\n}\n\n/**\n * Checks whether a JWT has expired by decoding its `exp` claim.\n *\n * @param token - A JWT string.\n * @returns true if the token is expired or cannot be decoded; false if still valid.\n */\nfunction isJwtExpired(token: string): boolean {\n try {\n const { exp } = decodeJwtPayload(token) as { exp?: unknown };\n return (\n typeof exp !== 'number' ||\n !Number.isInteger(exp) ||\n exp * 1000 <= Date.now()\n );\n } catch {\n return true;\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-pair-response.d.ts","sourceRoot":"","sources":["../../../src/sdk/utils/validate-pair-response.ts"],"names":[],"mappings":"AAEA,KAAK,eAAe,GAAG;IACrB,gBAAgB,EAAE,MAAM,CAAC;IACzB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,cAAc,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CAChD,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,OAAO,EAAE;QACP,UAAU,EAAE,MAAM,CAAC;QACnB,aAAa,EAAE,MAAM,CAAC;QACtB,cAAc,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"validate-pair-response.d.ts","sourceRoot":"","sources":["../../../src/sdk/utils/validate-pair-response.ts"],"names":[],"mappings":"AAEA,KAAK,eAAe,GAAG;IACrB,gBAAgB,EAAE,MAAM,CAAC;IACzB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,cAAc,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CAChD,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,OAAO,EAAE;QACP,UAAU,EAAE,MAAM,CAAC;QACnB,aAAa,EAAE,MAAM,CAAC;QACtB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,qBAAqB,CAAC,EAAE;YAAE,EAAE,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,MAAM,CAAA;SAAE,EAAE,CAAC;KACxD,CAAC;IACF,eAAe,CAAC,EAAE,eAAe,EAAE,CAAC;CACrC,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,OAAO,GACb,OAAO,CAAC,KAAK,IAAI,eAAe,CAwBlC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-pair-response.js","sourceRoot":"","sources":["../../../src/sdk/utils/validate-pair-response.ts"],"names":[],"mappings":"AAAA,yDAAyD;
|
|
1
|
+
{"version":3,"file":"validate-pair-response.js","sourceRoot":"","sources":["../../../src/sdk/utils/validate-pair-response.ts"],"names":[],"mappings":"AAAA,yDAAyD;AAkBzD;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CAClC,KAAc;IAEd,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QACxC,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;IAClE,CAAC;IAED,MAAM,OAAO,GAAG,KAAgC,CAAC;IACjD,MAAM,OAAO,GAAG,OAAO,CAAC,OAA8C,CAAC;IACvE,IAAI,CAAC,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAC5C,MAAM,IAAI,KAAK,CACb,2DAA2D,CAC5D,CAAC;IACJ,CAAC;IAED,IAAI,OAAO,OAAO,CAAC,UAAU,KAAK,QAAQ,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC;QAClE,MAAM,IAAI,KAAK,CACb,8DAA8D,CAC/D,CAAC;IACJ,CAAC;IAED,IAAI,OAAO,OAAO,CAAC,aAAa,KAAK,QAAQ,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC;QACxE,MAAM,IAAI,KAAK,CACb,iEAAiE,CAClE,CAAC;IACJ,CAAC;AACH,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\n\ntype RawProfileAlias = {\n alias_profile_id: string;\n canonical_profile_id: string;\n identifier_ids: { id: string; type: string }[];\n};\n\nexport type RawPairResponse = {\n profile: {\n profile_id: string;\n identifier_id: string;\n metametrics_id?: string;\n paired_identifier_ids?: { id: string; type: string }[];\n };\n profile_aliases?: RawProfileAlias[];\n};\n\n/**\n * Asserts that the raw API response from the profile pairing endpoint has the\n * expected shape before we attempt to map it into a `PairProfilesResponse`.\n * Throws if the response is malformed.\n *\n * @param input - The raw JSON parsed from the pair endpoint response body.\n */\nexport function validatePairResponse(\n input: unknown,\n): asserts input is RawPairResponse {\n if (!input || typeof input !== 'object') {\n throw new Error('validatePairResponse: input is not an object');\n }\n\n const assumed = input as Record<string, unknown>;\n const profile = assumed.profile as Record<string, unknown> | undefined;\n if (!profile || typeof profile !== 'object') {\n throw new Error(\n 'validatePairResponse: profile is missing or not an object',\n );\n }\n\n if (typeof profile.profile_id !== 'string' || !profile.profile_id) {\n throw new Error(\n 'validatePairResponse: profile.profile_id is missing or empty',\n );\n }\n\n if (typeof profile.identifier_id !== 'string' || !profile.identifier_id) {\n throw new Error(\n 'validatePairResponse: profile.identifier_id is missing or empty',\n );\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage-schema.d.ts","sourceRoot":"","sources":["../../src/shared/storage-schema.ts"],"names":[],"mappings":"AAEA;;;GAGG;AAEH;;;GAGG;AACH,eAAO,MAAM,0BAA0B;IACrC,aAAa;IACb,QAAQ;IACR,WAAW;CACZ,CAAC;AAEF,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,SAC7B,uCAAuC,KAC5C,+BAYF,CAAC;AAEF;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,uCAAuC,EAC7C,UAAU,EAAE,MAAM,GACjB,MAAM,CAKR"}
|
|
1
|
+
{"version":3,"file":"storage-schema.d.ts","sourceRoot":"","sources":["../../src/shared/storage-schema.ts"],"names":[],"mappings":"AAEA;;;GAGG;AAEH;;;GAGG;AACH,eAAO,MAAM,0BAA0B;IACrC,aAAa;IACb,QAAQ;IACR,WAAW;IACX,WAAW;CACZ,CAAC;AAEF,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,SAC7B,uCAAuC,KAC5C,+BAYF,CAAC;AAEF;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,uCAAuC,EAC7C,UAAU,EAAE,MAAM,GACjB,MAAM,CAKR"}
|
|
@@ -11,6 +11,7 @@ export const USER_STORAGE_FEATURE_NAMES = {
|
|
|
11
11
|
notifications: 'notifications',
|
|
12
12
|
accounts: 'accounts_v2',
|
|
13
13
|
addressBook: 'addressBook',
|
|
14
|
+
rampsOrders: 'rampsOrders',
|
|
14
15
|
};
|
|
15
16
|
export const getFeatureAndKeyFromPath = (path) => {
|
|
16
17
|
const pathRegex = /^\w+\.\w+$/u;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage-schema.js","sourceRoot":"","sources":["../../src/shared/storage-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD;;;GAGG;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG;IACxC,aAAa,EAAE,eAAe;IAC9B,QAAQ,EAAE,aAAa;IACvB,WAAW,EAAE,aAAa;CAC3B,CAAC;AAcF,MAAM,CAAC,MAAM,wBAAwB,GAAG,CACtC,IAA6C,EACZ,EAAE;IACnC,MAAM,SAAS,GAAG,aAAa,CAAC;IAEhC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CACb,iFAAiF,CAClF,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,OAAO,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAEvC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAqC,CAAC;AAC7D,CAAC,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,UAAU,eAAe,CAC7B,IAA6C,EAC7C,UAAkB;IAElB,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,wBAAwB,CAAC,IAAI,CAAC,CAAC;IACxD,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/index.js';\n\n/**\n * The User Storage Endpoint requires a feature name and a namespace key.\n * Any user storage path should be in the form of `feature.key`.\n */\n\n/**\n * Helper object that contains the feature names used in the controllers and SDK.\n * Developers don't need to add new feature names to this object anymore, as the schema enforcement has been deprecated.\n */\nexport const USER_STORAGE_FEATURE_NAMES = {\n notifications: 'notifications',\n accounts: 'accounts_v2',\n addressBook: 'addressBook',\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 = (\n path: UserStorageGenericPathWithFeatureAndKey,\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 return { feature, key } as 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 * @returns path to store entry\n */\nexport function createEntryPath(\n path: UserStorageGenericPathWithFeatureAndKey,\n storageKey: string,\n): string {\n const { feature, key } = getFeatureAndKeyFromPath(path);\n const hashedKey = createSHA256Hash(key + storageKey);\n\n return `${feature}/${hashedKey}`;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"storage-schema.js","sourceRoot":"","sources":["../../src/shared/storage-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD;;;GAGG;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG;IACxC,aAAa,EAAE,eAAe;IAC9B,QAAQ,EAAE,aAAa;IACvB,WAAW,EAAE,aAAa;IAC1B,WAAW,EAAE,aAAa;CAC3B,CAAC;AAcF,MAAM,CAAC,MAAM,wBAAwB,GAAG,CACtC,IAA6C,EACZ,EAAE;IACnC,MAAM,SAAS,GAAG,aAAa,CAAC;IAEhC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CACb,iFAAiF,CAClF,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,OAAO,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAEvC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAqC,CAAC;AAC7D,CAAC,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,UAAU,eAAe,CAC7B,IAA6C,EAC7C,UAAkB;IAElB,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,wBAAwB,CAAC,IAAI,CAAC,CAAC;IACxD,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/index.js';\n\n/**\n * The User Storage Endpoint requires a feature name and a namespace key.\n * Any user storage path should be in the form of `feature.key`.\n */\n\n/**\n * Helper object that contains the feature names used in the controllers and SDK.\n * Developers don't need to add new feature names to this object anymore, as the schema enforcement has been deprecated.\n */\nexport const USER_STORAGE_FEATURE_NAMES = {\n notifications: 'notifications',\n accounts: 'accounts_v2',\n addressBook: 'addressBook',\n rampsOrders: 'rampsOrders',\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 = (\n path: UserStorageGenericPathWithFeatureAndKey,\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 return { feature, key } as 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 * @returns path to store entry\n */\nexport function createEntryPath(\n path: UserStorageGenericPathWithFeatureAndKey,\n storageKey: string,\n): string {\n const { feature, key } = getFeatureAndKeyFromPath(path);\n const hashedKey = createSHA256Hash(key + storageKey);\n\n return `${feature}/${hashedKey}`;\n}\n"]}
|
|
@@ -1,22 +1,13 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
/**
|
|
3
|
-
* Reads HD keyring entropy source IDs (metadata IDs) from KeyringController
|
|
4
|
-
* keyrings, primary first. Returns an empty array when none are available
|
|
5
|
-
* (e.g. the wallet is locked, where `keyrings` is cleared).
|
|
6
|
-
*
|
|
7
|
-
* @param keyrings - Keyrings from `KeyringController:getState`.
|
|
8
|
-
* @returns The HD keyring metadata IDs, primary first.
|
|
9
|
-
*/
|
|
10
|
-
export declare function getHdKeyringEntropySourceIds(keyrings: KeyringObject[] | null | undefined): string[];
|
|
1
|
+
import type { KeyringControllerState } from '@metamask/keyring-controller';
|
|
11
2
|
/**
|
|
12
3
|
* Resolves the primary SRP's entropy source ID (the first HD keyring's
|
|
13
4
|
* metadata ID). The ID is randomly regenerated whenever the vault is
|
|
14
5
|
* recreated (e.g. on restore).
|
|
15
6
|
*
|
|
16
|
-
* @param
|
|
7
|
+
* @param keyringState - KeyringController state.
|
|
17
8
|
* @returns The primary HD keyring metadata ID.
|
|
18
9
|
* @throws If no HD keyring is available; callers must only resolve while
|
|
19
10
|
* the wallet is unlocked.
|
|
20
11
|
*/
|
|
21
|
-
export declare function getPrimaryHdKeyringEntropySourceId(
|
|
12
|
+
export declare function getPrimaryHdKeyringEntropySourceId(keyringState: KeyringControllerState): string;
|
|
22
13
|
//# sourceMappingURL=entropy-source.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entropy-source.d.ts","sourceRoot":"","sources":["../../../src/shared/utils/entropy-source.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"entropy-source.d.ts","sourceRoot":"","sources":["../../../src/shared/utils/entropy-source.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAE3E;;;;;;;;;GASG;AACH,wBAAgB,kCAAkC,CAChD,YAAY,EAAE,sBAAsB,GACnC,MAAM,CASR"}
|
|
@@ -1,29 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
/**
|
|
3
|
-
* Reads HD keyring entropy source IDs (metadata IDs) from KeyringController
|
|
4
|
-
* keyrings, primary first. Returns an empty array when none are available
|
|
5
|
-
* (e.g. the wallet is locked, where `keyrings` is cleared).
|
|
6
|
-
*
|
|
7
|
-
* @param keyrings - Keyrings from `KeyringController:getState`.
|
|
8
|
-
* @returns The HD keyring metadata IDs, primary first.
|
|
9
|
-
*/
|
|
10
|
-
export function getHdKeyringEntropySourceIds(keyrings) {
|
|
11
|
-
return (keyrings ?? [])
|
|
12
|
-
.filter((keyring) => keyring.type === KeyringTypes.hd.toString())
|
|
13
|
-
.map((keyring) => keyring.metadata.id);
|
|
14
|
-
}
|
|
1
|
+
import { selectPrimaryHdKeyringEntropySourceId } from '@metamask/keyring-controller';
|
|
15
2
|
/**
|
|
16
3
|
* Resolves the primary SRP's entropy source ID (the first HD keyring's
|
|
17
4
|
* metadata ID). The ID is randomly regenerated whenever the vault is
|
|
18
5
|
* recreated (e.g. on restore).
|
|
19
6
|
*
|
|
20
|
-
* @param
|
|
7
|
+
* @param keyringState - KeyringController state.
|
|
21
8
|
* @returns The primary HD keyring metadata ID.
|
|
22
9
|
* @throws If no HD keyring is available; callers must only resolve while
|
|
23
10
|
* the wallet is unlocked.
|
|
24
11
|
*/
|
|
25
|
-
export function getPrimaryHdKeyringEntropySourceId(
|
|
26
|
-
const
|
|
12
|
+
export function getPrimaryHdKeyringEntropySourceId(keyringState) {
|
|
13
|
+
const primaryEntropySourceId = selectPrimaryHdKeyringEntropySourceId(keyringState);
|
|
27
14
|
if (!primaryEntropySourceId) {
|
|
28
15
|
throw new Error('getPrimaryHdKeyringEntropySourceId - no HD keyring available');
|
|
29
16
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entropy-source.js","sourceRoot":"","sources":["../../../src/shared/utils/entropy-source.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"entropy-source.js","sourceRoot":"","sources":["../../../src/shared/utils/entropy-source.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qCAAqC,EAAE,MAAM,8BAA8B,CAAC;AAGrF;;;;;;;;;GASG;AACH,MAAM,UAAU,kCAAkC,CAChD,YAAoC;IAEpC,MAAM,sBAAsB,GAC1B,qCAAqC,CAAC,YAAY,CAAC,CAAC;IACtD,IAAI,CAAC,sBAAsB,EAAE,CAAC;QAC5B,MAAM,IAAI,KAAK,CACb,8DAA8D,CAC/D,CAAC;IACJ,CAAC;IACD,OAAO,sBAAsB,CAAC;AAChC,CAAC","sourcesContent":["import { selectPrimaryHdKeyringEntropySourceId } from '@metamask/keyring-controller';\nimport type { KeyringControllerState } from '@metamask/keyring-controller';\n\n/**\n * Resolves the primary SRP's entropy source ID (the first HD keyring's\n * metadata ID). The ID is randomly regenerated whenever the vault is\n * recreated (e.g. on restore).\n *\n * @param keyringState - KeyringController state.\n * @returns The primary HD keyring metadata ID.\n * @throws If no HD keyring is available; callers must only resolve while\n * the wallet is unlocked.\n */\nexport function getPrimaryHdKeyringEntropySourceId(\n keyringState: KeyringControllerState,\n): string {\n const primaryEntropySourceId =\n selectPrimaryHdKeyringEntropySourceId(keyringState);\n if (!primaryEntropySourceId) {\n throw new Error(\n 'getPrimaryHdKeyringEntropySourceId - no HD keyring available',\n );\n }\n return primaryEntropySourceId;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metamask/profile-sync-controller",
|
|
3
|
-
"version": "32.
|
|
3
|
+
"version": "32.3.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
|
"Ethereum",
|
|
@@ -75,36 +75,39 @@
|
|
|
75
75
|
"dependencies": {
|
|
76
76
|
"@metamask/address-book-controller": "^8.0.0",
|
|
77
77
|
"@metamask/base-controller": "^10.0.0",
|
|
78
|
+
"@metamask/controller-utils": "^13.0.0",
|
|
78
79
|
"@metamask/key-tree": "^10.1.1",
|
|
79
80
|
"@metamask/keyring-controller": "^28.0.0",
|
|
80
81
|
"@metamask/messenger": "^3.0.0",
|
|
81
82
|
"@metamask/seedless-onboarding-controller": "^11.0.0",
|
|
83
|
+
"@metamask/superstruct": "^3.4.1",
|
|
82
84
|
"@metamask/utils": "^12.0.0",
|
|
83
85
|
"@noble/ciphers": "^1.3.0",
|
|
84
86
|
"@noble/curves": "^1.9.2",
|
|
85
87
|
"@noble/hashes": "^1.8.0",
|
|
86
88
|
"@signinwithethereum/siwe": "^4.2.1",
|
|
87
|
-
"immer": "^9.0.
|
|
89
|
+
"immer": "^9.0.21",
|
|
88
90
|
"loglevel": "^1.8.1"
|
|
89
91
|
},
|
|
90
92
|
"devDependencies": {
|
|
91
|
-
"@lavamoat/allow-scripts": "^3.
|
|
93
|
+
"@lavamoat/allow-scripts": "^3.4.3",
|
|
92
94
|
"@lavamoat/preinstall-always-fail": "^2.1.0",
|
|
93
|
-
"@metamask/auto-changelog": "^6.1
|
|
95
|
+
"@metamask/auto-changelog": "^6.2.1",
|
|
94
96
|
"@metamask/eth-hd-keyring": "^15.0.0",
|
|
95
97
|
"@metamask/keyring-api": "^24.0.0",
|
|
96
98
|
"@metamask/keyring-internal-api": "^12.0.0",
|
|
97
99
|
"@metamask/providers": "^22.1.0",
|
|
100
|
+
"@metamask/rpc-errors": "^7.0.2",
|
|
98
101
|
"@types/jest": "^30.0.0",
|
|
99
102
|
"@typescript/native": "npm:typescript@^7.0.2",
|
|
100
103
|
"deepmerge": "^4.2.2",
|
|
101
|
-
"ethers": "^6.
|
|
104
|
+
"ethers": "^6.17.0",
|
|
102
105
|
"jest": "^30.4.2",
|
|
103
106
|
"jest-environment-jsdom": "^30.4.1",
|
|
104
|
-
"nock": "^13.
|
|
105
|
-
"rimraf": "^
|
|
106
|
-
"ts-jest": "^29.4.
|
|
107
|
-
"tsx": "^4.
|
|
107
|
+
"nock": "^13.5.6",
|
|
108
|
+
"rimraf": "^6.1.3",
|
|
109
|
+
"ts-jest": "^29.4.12",
|
|
110
|
+
"tsx": "^4.23.13",
|
|
108
111
|
"typedoc": "^0.25.13",
|
|
109
112
|
"typedoc-plugin-missing-exports": "^2.0.0",
|
|
110
113
|
"typescript": "npm:@typescript/typescript6@^6.0.2",
|