@metamask/profile-sync-controller 0.7.0 → 0.8.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 CHANGED
@@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.8.0]
11
+
12
+ ### Fixed
13
+
14
+ - **BREAKING** update profile-sync notification settings path hash ([#4711](https://github.com/MetaMask/core/pull/4711))
15
+ - changing this path also means the underlying storage hash has changed. But this will align with our existing solutions that are in prod.
16
+
10
17
  ## [0.7.0]
11
18
 
12
19
  ### Changed
@@ -197,7 +204,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
197
204
 
198
205
  - Initial release
199
206
 
200
- [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/profile-sync-controller@0.7.0...HEAD
207
+ [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/profile-sync-controller@0.8.0...HEAD
208
+ [0.8.0]: https://github.com/MetaMask/core/compare/@metamask/profile-sync-controller@0.7.0...@metamask/profile-sync-controller@0.8.0
201
209
  [0.7.0]: https://github.com/MetaMask/core/compare/@metamask/profile-sync-controller@0.6.0...@metamask/profile-sync-controller@0.7.0
202
210
  [0.6.0]: https://github.com/MetaMask/core/compare/@metamask/profile-sync-controller@0.5.0...@metamask/profile-sync-controller@0.6.0
203
211
  [0.5.0]: https://github.com/MetaMask/core/compare/@metamask/profile-sync-controller@0.4.0...@metamask/profile-sync-controller@0.5.0
@@ -21,7 +21,7 @@ const createMockAllFeatureEntriesResponse = async (dataArr = [mockStorage_1.MOCK
21
21
  Data: await (0, mockStorage_1.MOCK_ENCRYPTED_STORAGE_DATA)(d),
22
22
  })));
23
23
  exports.createMockAllFeatureEntriesResponse = createMockAllFeatureEntriesResponse;
24
- const getMockUserStorageGetResponse = async (path = 'notifications.notificationSettings') => {
24
+ const getMockUserStorageGetResponse = async (path = 'notifications.notification_settings') => {
25
25
  return {
26
26
  url: (0, exports.getMockUserStorageEndpoint)(path),
27
27
  requestMethod: 'GET',
@@ -37,7 +37,7 @@ const getMockUserStorageAllFeatureEntriesResponse = async (path = 'notifications
37
37
  };
38
38
  };
39
39
  exports.getMockUserStorageAllFeatureEntriesResponse = getMockUserStorageAllFeatureEntriesResponse;
40
- const getMockUserStoragePutResponse = (path = 'notifications.notificationSettings') => {
40
+ const getMockUserStoragePutResponse = (path = 'notifications.notification_settings') => {
41
41
  return {
42
42
  url: (0, exports.getMockUserStorageEndpoint)(path),
43
43
  requestMethod: 'PUT',
@@ -1 +1 @@
1
- {"version":3,"file":"mockResponses.cjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/__fixtures__/mockResponses.ts"],"names":[],"mappings":";;;AAIA,0CAA4C;AAK5C,8CAAoD;AACpD,mDAIuB;AAQhB,MAAM,0BAA0B,GAAG,CACxC,IAAuE,EACvE,EAAE;IACF,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE;QAChC,OAAO,GAAG,gCAAqB,IAAI,IAAI,EAAE,CAAC;KAC3C;IAED,OAAO,GAAG,gCAAqB,IAAI,IAAA,wBAAe,EAChD,IAAwC,EACxC,8BAAgB,CACjB,EAAE,CAAC;AACN,CAAC,CAAC;AAXW,QAAA,0BAA0B,8BAWrC;AAEK,MAAM,4BAA4B,GAAG,KAAK,EAC/C,IAAa,EACoB,EAAE,CAAC,CAAC;IACrC,SAAS,EAAE,YAAY;IACvB,IAAI,EAAE,MAAM,IAAA,yCAA2B,EAAC,IAAI,CAAC;CAC9C,CAAC,CAAC;AALU,QAAA,4BAA4B,gCAKtC;AAEI,MAAM,mCAAmC,GAAG,KAAK,EACtD,UAAoB,CAAC,+BAAiB,CAAC,EACW,EAAE,CACpD,OAAO,CAAC,GAAG,CACT,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;IACxB,SAAS,EAAE,YAAY;IACvB,IAAI,EAAE,MAAM,IAAA,yCAA2B,EAAC,CAAC,CAAC;CAC3C,CAAC,CAAC,CACJ,CAAC;AARS,QAAA,mCAAmC,uCAQ5C;AAEG,MAAM,6BAA6B,GAAG,KAAK,EAChD,OAAyC,oCAAoC,EAC7E,EAAE;IACF,OAAO;QACL,GAAG,EAAE,IAAA,kCAA0B,EAAC,IAAI,CAAC;QACrC,aAAa,EAAE,KAAK;QACpB,QAAQ,EAAE,MAAM,IAAA,oCAA4B,GAAE;KACxB,CAAC;AAC3B,CAAC,CAAC;AARW,QAAA,6BAA6B,iCAQxC;AAEK,MAAM,2CAA2C,GAAG,KAAK,EAC9D,OAAuC,eAAe,EACtD,OAAkB,EAClB,EAAE;IACF,OAAO;QACL,GAAG,EAAE,IAAA,kCAA0B,EAAC,IAAI,CAAC;QACrC,aAAa,EAAE,KAAK;QACpB,QAAQ,EAAE,MAAM,IAAA,2CAAmC,EAAC,OAAO,CAAC;KACtC,CAAC;AAC3B,CAAC,CAAC;AATW,QAAA,2CAA2C,+CAStD;AAEK,MAAM,6BAA6B,GAAG,CAC3C,OAAyC,oCAAoC,EAC7E,EAAE;IACF,OAAO;QACL,GAAG,EAAE,IAAA,kCAA0B,EAAC,IAAI,CAAC;QACrC,aAAa,EAAE,KAAK;QACpB,QAAQ,EAAE,IAAI;KACQ,CAAC;AAC3B,CAAC,CAAC;AARW,QAAA,6BAA6B,iCAQxC","sourcesContent":["import type {\n UserStoragePathWithFeatureAndKey,\n UserStoragePathWithFeatureOnly,\n} from '../schema';\nimport { createEntryPath } from '../schema';\nimport type {\n GetUserStorageAllFeatureEntriesResponse,\n GetUserStorageResponse,\n} from '../services';\nimport { USER_STORAGE_ENDPOINT } from '../services';\nimport {\n MOCK_ENCRYPTED_STORAGE_DATA,\n MOCK_STORAGE_DATA,\n MOCK_STORAGE_KEY,\n} from './mockStorage';\n\ntype MockResponse = {\n url: string;\n requestMethod: 'GET' | 'POST' | 'PUT';\n response: unknown;\n};\n\nexport const getMockUserStorageEndpoint = (\n path: UserStoragePathWithFeatureAndKey | UserStoragePathWithFeatureOnly,\n) => {\n if (path.split('.').length === 1) {\n return `${USER_STORAGE_ENDPOINT}/${path}`;\n }\n\n return `${USER_STORAGE_ENDPOINT}/${createEntryPath(\n path as UserStoragePathWithFeatureAndKey,\n MOCK_STORAGE_KEY,\n )}`;\n};\n\nexport const createMockGetStorageResponse = async (\n data?: string,\n): Promise<GetUserStorageResponse> => ({\n HashedKey: 'HASHED_KEY',\n Data: await MOCK_ENCRYPTED_STORAGE_DATA(data),\n});\n\nexport const createMockAllFeatureEntriesResponse = async (\n dataArr: string[] = [MOCK_STORAGE_DATA],\n): Promise<GetUserStorageAllFeatureEntriesResponse> =>\n Promise.all(\n dataArr.map(async (d) => ({\n HashedKey: 'HASHED_KEY',\n Data: await MOCK_ENCRYPTED_STORAGE_DATA(d),\n })),\n );\n\nexport const getMockUserStorageGetResponse = async (\n path: UserStoragePathWithFeatureAndKey = 'notifications.notificationSettings',\n) => {\n return {\n url: getMockUserStorageEndpoint(path),\n requestMethod: 'GET',\n response: await createMockGetStorageResponse(),\n } satisfies MockResponse;\n};\n\nexport const getMockUserStorageAllFeatureEntriesResponse = async (\n path: UserStoragePathWithFeatureOnly = 'notifications',\n dataArr?: string[],\n) => {\n return {\n url: getMockUserStorageEndpoint(path),\n requestMethod: 'GET',\n response: await createMockAllFeatureEntriesResponse(dataArr),\n } satisfies MockResponse;\n};\n\nexport const getMockUserStoragePutResponse = (\n path: UserStoragePathWithFeatureAndKey = 'notifications.notificationSettings',\n) => {\n return {\n url: getMockUserStorageEndpoint(path),\n requestMethod: 'PUT',\n response: null,\n } satisfies MockResponse;\n};\n"]}
1
+ {"version":3,"file":"mockResponses.cjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/__fixtures__/mockResponses.ts"],"names":[],"mappings":";;;AAIA,0CAA4C;AAK5C,8CAAoD;AACpD,mDAIuB;AAQhB,MAA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AE,KAAK;QACpB,QAAQ,EAAE,MAAM,IAAA,2CAAmC,EAAC,OAAO,CAAC;KACtC,CAAC;AAC3B,CAAC,CAAC;AATW,QAAA,2CAA2C,+CAStD;AAEK,MAAM,6BAA6B,GAAG,CAC3C,OAAyC,qCAAqC,EAC9E,EAAE;IACF,OAAO;QACL,GAAG,EAAE,IAAA,kCAA0B,EAAC,IAAI,CAAC;QACrC,aAAa,EAAE,KAAK;QACpB,QAAQ,EAAE,IAAI;KACQ,CAAC;AAC3B,CAAC,CAAC;AARW,QAAA,6BAA6B,iCAQxC","sourcesContent":["import type {\n UserStoragePathWithFeatureAndKey,\n UserStoragePathWithFeatureOnly,\n} from '../schema';\nimport { createEntryPath } from '../schema';\nimport type {\n GetUserStorageAllFeatureEntriesResponse,\n GetUserStorageResponse,\n} from '../services';\nimport { USER_STORAGE_ENDPOINT } from '../services';\nimport {\n MOCK_ENCRYPTED_STORAGE_DATA,\n MOCK_STORAGE_DATA,\n MOCK_STORAGE_KEY,\n} from './mockStorage';\n\ntype MockResponse = {\n url: string;\n requestMethod: 'GET' | 'POST' | 'PUT';\n response: unknown;\n};\n\nexport const getMockUserStorageEndpoint = (\n path: UserStoragePathWithFeatureAndKey | UserStoragePathWithFeatureOnly,\n) => {\n if (path.split('.').length === 1) {\n return `${USER_STORAGE_ENDPOINT}/${path}`;\n }\n\n return `${USER_STORAGE_ENDPOINT}/${createEntryPath(\n path as UserStoragePathWithFeatureAndKey,\n MOCK_STORAGE_KEY,\n )}`;\n};\n\nexport const createMockGetStorageResponse = async (\n data?: string,\n): Promise<GetUserStorageResponse> => ({\n HashedKey: 'HASHED_KEY',\n Data: await MOCK_ENCRYPTED_STORAGE_DATA(data),\n});\n\nexport const createMockAllFeatureEntriesResponse = async (\n dataArr: string[] = [MOCK_STORAGE_DATA],\n): Promise<GetUserStorageAllFeatureEntriesResponse> =>\n Promise.all(\n dataArr.map(async (d) => ({\n HashedKey: 'HASHED_KEY',\n Data: await MOCK_ENCRYPTED_STORAGE_DATA(d),\n })),\n );\n\nexport const getMockUserStorageGetResponse = async (\n path: UserStoragePathWithFeatureAndKey = 'notifications.notification_settings',\n) => {\n return {\n url: getMockUserStorageEndpoint(path),\n requestMethod: 'GET',\n response: await createMockGetStorageResponse(),\n } satisfies MockResponse;\n};\n\nexport const getMockUserStorageAllFeatureEntriesResponse = async (\n path: UserStoragePathWithFeatureOnly = 'notifications',\n dataArr?: string[],\n) => {\n return {\n url: getMockUserStorageEndpoint(path),\n requestMethod: 'GET',\n response: await createMockAllFeatureEntriesResponse(dataArr),\n } satisfies MockResponse;\n};\n\nexport const getMockUserStoragePutResponse = (\n path: UserStoragePathWithFeatureAndKey = 'notifications.notification_settings',\n) => {\n return {\n url: getMockUserStorageEndpoint(path),\n requestMethod: 'PUT',\n response: null,\n } satisfies MockResponse;\n};\n"]}
@@ -15,7 +15,7 @@ export const createMockAllFeatureEntriesResponse = async (dataArr = [MOCK_STORAG
15
15
  HashedKey: 'HASHED_KEY',
16
16
  Data: await MOCK_ENCRYPTED_STORAGE_DATA(d),
17
17
  })));
18
- export const getMockUserStorageGetResponse = async (path = 'notifications.notificationSettings') => {
18
+ export const getMockUserStorageGetResponse = async (path = 'notifications.notification_settings') => {
19
19
  return {
20
20
  url: getMockUserStorageEndpoint(path),
21
21
  requestMethod: 'GET',
@@ -29,7 +29,7 @@ export const getMockUserStorageAllFeatureEntriesResponse = async (path = 'notifi
29
29
  response: await createMockAllFeatureEntriesResponse(dataArr),
30
30
  };
31
31
  };
32
- export const getMockUserStoragePutResponse = (path = 'notifications.notificationSettings') => {
32
+ export const getMockUserStoragePutResponse = (path = 'notifications.notification_settings') => {
33
33
  return {
34
34
  url: getMockUserStorageEndpoint(path),
35
35
  requestMethod: 'PUT',
@@ -1 +1 @@
1
- {"version":3,"file":"mockResponses.mjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/__fixtures__/mockResponses.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,eAAe,EAAE,sBAAkB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B,CAAC,IAAI,CAAC;QACrC,aAAa,EAAE,KAAK;QACpB,QAAQ,EAAE,MAAM,mCAAmC,CAAC,OAAO,CAAC;KACtC,CAAC;AAC3B,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAC3C,OAAyC,oCAAoC,EAC7E,EAAE;IACF,OAAO;QACL,GAAG,EAAE,0BAA0B,CAAC,IAAI,CAAC;QACrC,aAAa,EAAE,KAAK;QACpB,QAAQ,EAAE,IAAI;KACQ,CAAC;AAC3B,CAAC,CAAC","sourcesContent":["import type {\n UserStoragePathWithFeatureAndKey,\n UserStoragePathWithFeatureOnly,\n} from '../schema';\nimport { createEntryPath } from '../schema';\nimport type {\n GetUserStorageAllFeatureEntriesResponse,\n GetUserStorageResponse,\n} from '../services';\nimport { USER_STORAGE_ENDPOINT } from '../services';\nimport {\n MOCK_ENCRYPTED_STORAGE_DATA,\n MOCK_STORAGE_DATA,\n MOCK_STORAGE_KEY,\n} from './mockStorage';\n\ntype MockResponse = {\n url: string;\n requestMethod: 'GET' | 'POST' | 'PUT';\n response: unknown;\n};\n\nexport const getMockUserStorageEndpoint = (\n path: UserStoragePathWithFeatureAndKey | UserStoragePathWithFeatureOnly,\n) => {\n if (path.split('.').length === 1) {\n return `${USER_STORAGE_ENDPOINT}/${path}`;\n }\n\n return `${USER_STORAGE_ENDPOINT}/${createEntryPath(\n path as UserStoragePathWithFeatureAndKey,\n MOCK_STORAGE_KEY,\n )}`;\n};\n\nexport const createMockGetStorageResponse = async (\n data?: string,\n): Promise<GetUserStorageResponse> => ({\n HashedKey: 'HASHED_KEY',\n Data: await MOCK_ENCRYPTED_STORAGE_DATA(data),\n});\n\nexport const createMockAllFeatureEntriesResponse = async (\n dataArr: string[] = [MOCK_STORAGE_DATA],\n): Promise<GetUserStorageAllFeatureEntriesResponse> =>\n Promise.all(\n dataArr.map(async (d) => ({\n HashedKey: 'HASHED_KEY',\n Data: await MOCK_ENCRYPTED_STORAGE_DATA(d),\n })),\n );\n\nexport const getMockUserStorageGetResponse = async (\n path: UserStoragePathWithFeatureAndKey = 'notifications.notificationSettings',\n) => {\n return {\n url: getMockUserStorageEndpoint(path),\n requestMethod: 'GET',\n response: await createMockGetStorageResponse(),\n } satisfies MockResponse;\n};\n\nexport const getMockUserStorageAllFeatureEntriesResponse = async (\n path: UserStoragePathWithFeatureOnly = 'notifications',\n dataArr?: string[],\n) => {\n return {\n url: getMockUserStorageEndpoint(path),\n requestMethod: 'GET',\n response: await createMockAllFeatureEntriesResponse(dataArr),\n } satisfies MockResponse;\n};\n\nexport const getMockUserStoragePutResponse = (\n path: UserStoragePathWithFeatureAndKey = 'notifications.notificationSettings',\n) => {\n return {\n url: getMockUserStorageEndpoint(path),\n requestMethod: 'PUT',\n response: null,\n } satisfies MockResponse;\n};\n"]}
1
+ {"version":3,"file":"mockResponses.mjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/__fixtures__/mockResponses.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,eAAe,EAAE,sBAAkB;AAK5C,OAAO,EAAE,qBAAqB,EAAE,wBAAoB;AACpD,OAAO,EACL,2BAA2B,EAC3B,iBAAiB,EACjB,gBAAgB,EACjB,0BAAsB;AAQvB,MAAM,CAAC,MAAM,0BAA0B,GAAG,CACxC,IAAuE,EACvE,EAAE;IACF,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE;QAChC,OAAO,GAAG,qBAAqB,IAAI,IAAI,EAAE,CAAC;KAC3C;IAED,OAAO,GAAG,qBAAqB,IAAI,eAAe,CAChD,IAAwC,EACxC,gBAAgB,CACjB,EAAE,CAAC;AACN,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,4BAA4B,GAAG,KAAK,EAC/C,IAAa,EACoB,EAAE,CAAC,CAAC;IACrC,SAAS,EAAE,YAAY;IACvB,IAAI,EAAE,MAAM,2BAA2B,CAAC,IAAI,CAAC;CAC9C,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,mCAAmC,GAAG,KAAK,EACtD,UAAoB,CAAC,iBAAiB,CAAC,EACW,EAAE,CACpD,OAAO,CAAC,GAAG,CACT,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;IACxB,SAAS,EAAE,YAAY;IACvB,IAAI,EAAE,MAAM,2BAA2B,CAAC,CAAC,CAAC;CAC3C,CAAC,CAAC,CACJ,CAAC;AAEJ,MAAM,CAAC,MAAM,6BAA6B,GAAG,KAAK,EAChD,OAAyC,qCAAqC,EAC9E,EAAE;IACF,OAAO;QACL,GAAG,EAAE,0BAA0B,CAAC,IAAI,CAAC;QACrC,aAAa,EAAE,KAAK;QACpB,QAAQ,EAAE,MAAM,4BAA4B,EAAE;KACxB,CAAC;AAC3B,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,2CAA2C,GAAG,KAAK,EAC9D,OAAuC,eAAe,EACtD,OAAkB,EAClB,EAAE;IACF,OAAO;QACL,GAAG,EAAE,0BAA0B,CAAC,IAAI,CAAC;QACrC,aAAa,EAAE,KAAK;QACpB,QAAQ,EAAE,MAAM,mCAAmC,CAAC,OAAO,CAAC;KACtC,CAAC;AAC3B,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAC3C,OAAyC,qCAAqC,EAC9E,EAAE;IACF,OAAO;QACL,GAAG,EAAE,0BAA0B,CAAC,IAAI,CAAC;QACrC,aAAa,EAAE,KAAK;QACpB,QAAQ,EAAE,IAAI;KACQ,CAAC;AAC3B,CAAC,CAAC","sourcesContent":["import type {\n UserStoragePathWithFeatureAndKey,\n UserStoragePathWithFeatureOnly,\n} from '../schema';\nimport { createEntryPath } from '../schema';\nimport type {\n GetUserStorageAllFeatureEntriesResponse,\n GetUserStorageResponse,\n} from '../services';\nimport { USER_STORAGE_ENDPOINT } from '../services';\nimport {\n MOCK_ENCRYPTED_STORAGE_DATA,\n MOCK_STORAGE_DATA,\n MOCK_STORAGE_KEY,\n} from './mockStorage';\n\ntype MockResponse = {\n url: string;\n requestMethod: 'GET' | 'POST' | 'PUT';\n response: unknown;\n};\n\nexport const getMockUserStorageEndpoint = (\n path: UserStoragePathWithFeatureAndKey | UserStoragePathWithFeatureOnly,\n) => {\n if (path.split('.').length === 1) {\n return `${USER_STORAGE_ENDPOINT}/${path}`;\n }\n\n return `${USER_STORAGE_ENDPOINT}/${createEntryPath(\n path as UserStoragePathWithFeatureAndKey,\n MOCK_STORAGE_KEY,\n )}`;\n};\n\nexport const createMockGetStorageResponse = async (\n data?: string,\n): Promise<GetUserStorageResponse> => ({\n HashedKey: 'HASHED_KEY',\n Data: await MOCK_ENCRYPTED_STORAGE_DATA(data),\n});\n\nexport const createMockAllFeatureEntriesResponse = async (\n dataArr: string[] = [MOCK_STORAGE_DATA],\n): Promise<GetUserStorageAllFeatureEntriesResponse> =>\n Promise.all(\n dataArr.map(async (d) => ({\n HashedKey: 'HASHED_KEY',\n Data: await MOCK_ENCRYPTED_STORAGE_DATA(d),\n })),\n );\n\nexport const getMockUserStorageGetResponse = async (\n path: UserStoragePathWithFeatureAndKey = 'notifications.notification_settings',\n) => {\n return {\n url: getMockUserStorageEndpoint(path),\n requestMethod: 'GET',\n response: await createMockGetStorageResponse(),\n } satisfies MockResponse;\n};\n\nexport const getMockUserStorageAllFeatureEntriesResponse = async (\n path: UserStoragePathWithFeatureOnly = 'notifications',\n dataArr?: string[],\n) => {\n return {\n url: getMockUserStorageEndpoint(path),\n requestMethod: 'GET',\n response: await createMockAllFeatureEntriesResponse(dataArr),\n } satisfies MockResponse;\n};\n\nexport const getMockUserStoragePutResponse = (\n path: UserStoragePathWithFeatureAndKey = 'notifications.notification_settings',\n) => {\n return {\n url: getMockUserStorageEndpoint(path),\n requestMethod: 'PUT',\n response: null,\n } satisfies MockResponse;\n};\n"]}
@@ -18,7 +18,7 @@ const mockEndpointGetUserStorageAllFeatureEntries = async (path = 'notifications
18
18
  return mockEndpoint;
19
19
  };
20
20
  exports.mockEndpointGetUserStorageAllFeatureEntries = mockEndpointGetUserStorageAllFeatureEntries;
21
- const mockEndpointGetUserStorage = async (path = 'notifications.notificationSettings', mockReply) => {
21
+ const mockEndpointGetUserStorage = async (path = 'notifications.notification_settings', mockReply) => {
22
22
  const mockResponse = await (0, mockResponses_1.getMockUserStorageGetResponse)(path);
23
23
  const reply = mockReply ?? {
24
24
  status: 200,
@@ -30,7 +30,7 @@ const mockEndpointGetUserStorage = async (path = 'notifications.notificationSett
30
30
  return mockEndpoint;
31
31
  };
32
32
  exports.mockEndpointGetUserStorage = mockEndpointGetUserStorage;
33
- const mockEndpointUpsertUserStorage = (path = 'notifications.notificationSettings', mockReply) => {
33
+ const mockEndpointUpsertUserStorage = (path = 'notifications.notification_settings', mockReply) => {
34
34
  const mockResponse = (0, mockResponses_1.getMockUserStoragePutResponse)(path);
35
35
  const mockEndpoint = (0, nock_1.default)(mockResponse.url)
36
36
  .put('')
@@ -1 +1 @@
1
- {"version":3,"file":"mockServices.cjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/__fixtures__/mockServices.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AAMxB,uDAIyB;AAOlB,MAAM,2CAA2C,GAAG,KAAK,EAC9D,OAAuC,eAAe,EACtD,SAAqB,EACrB,EAAE;IACF,MAAM,YAAY,GAAG,MAAM,IAAA,2DAA2C,EAAC,IAAI,CAAC,CAAC;IAC7E,MAAM,KAAK,GAAG,SAAS,IAAI;QACzB,MAAM,EAAE,GAAG;QACX,IAAI,EAAE,YAAY,CAAC,QAAQ;KAC5B,CAAC;IAEF,MAAM,YAAY,GAAG,IAAA,cAAI,EAAC,YAAY,CAAC,GAAG,CAAC;SACxC,GAAG,CAAC,EAAE,CAAC;SACP,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;IAEnC,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC;AAfW,QAAA,2CAA2C,+CAetD;AAEK,MAAM,0BAA0B,GAAG,KAAK,EAC7C,OAAyC,oCAAoC,EAC7E,SAAqB,EACrB,EAAE;IACF,MAAM,YAAY,GAAG,MAAM,IAAA,6CAA6B,EAAC,IAAI,CAAC,CAAC;IAC/D,MAAM,KAAK,GAAG,SAAS,IAAI;QACzB,MAAM,EAAE,GAAG;QACX,IAAI,EAAE,YAAY,CAAC,QAAQ;KAC5B,CAAC;IAEF,MAAM,YAAY,GAAG,IAAA,cAAI,EAAC,YAAY,CAAC,GAAG,CAAC;SACxC,GAAG,CAAC,EAAE,CAAC;SACP,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;IAEnC,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC;AAfW,QAAA,0BAA0B,8BAerC;AAEK,MAAM,6BAA6B,GAAG,CAC3C,OAAyC,oCAAoC,EAC7E,SAAqC,EACrC,EAAE;IACF,MAAM,YAAY,GAAG,IAAA,6CAA6B,EAAC,IAAI,CAAC,CAAC;IACzD,MAAM,YAAY,GAAG,IAAA,cAAI,EAAC,YAAY,CAAC,GAAG,CAAC;SACxC,GAAG,CAAC,EAAE,CAAC;SACP,KAAK,CAAC,SAAS,EAAE,MAAM,IAAI,GAAG,CAAC,CAAC;IACnC,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC;AATW,QAAA,6BAA6B,iCASxC","sourcesContent":["import nock from 'nock';\n\nimport type {\n UserStoragePathWithFeatureAndKey,\n UserStoragePathWithFeatureOnly,\n} from '../schema';\nimport {\n getMockUserStorageGetResponse,\n getMockUserStoragePutResponse,\n getMockUserStorageAllFeatureEntriesResponse,\n} from './mockResponses';\n\ntype MockReply = {\n status: nock.StatusCode;\n body?: nock.Body;\n};\n\nexport const mockEndpointGetUserStorageAllFeatureEntries = async (\n path: UserStoragePathWithFeatureOnly = 'notifications',\n mockReply?: MockReply,\n) => {\n const mockResponse = await getMockUserStorageAllFeatureEntriesResponse(path);\n const reply = mockReply ?? {\n status: 200,\n body: mockResponse.response,\n };\n\n const mockEndpoint = nock(mockResponse.url)\n .get('')\n .reply(reply.status, reply.body);\n\n return mockEndpoint;\n};\n\nexport const mockEndpointGetUserStorage = async (\n path: UserStoragePathWithFeatureAndKey = 'notifications.notificationSettings',\n mockReply?: MockReply,\n) => {\n const mockResponse = await getMockUserStorageGetResponse(path);\n const reply = mockReply ?? {\n status: 200,\n body: mockResponse.response,\n };\n\n const mockEndpoint = nock(mockResponse.url)\n .get('')\n .reply(reply.status, reply.body);\n\n return mockEndpoint;\n};\n\nexport const mockEndpointUpsertUserStorage = (\n path: UserStoragePathWithFeatureAndKey = 'notifications.notificationSettings',\n mockReply?: Pick<MockReply, 'status'>,\n) => {\n const mockResponse = getMockUserStoragePutResponse(path);\n const mockEndpoint = nock(mockResponse.url)\n .put('')\n .reply(mockReply?.status ?? 204);\n return mockEndpoint;\n};\n"]}
1
+ {"version":3,"file":"mockServices.cjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/__fixtures__/mockServices.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AAMxB,uDAIyB;AAOlB,MAAM,2CAA2C,GAAG,KAAK,EAC9D,OAAuC,eAAe,EACtD,SAAqB,EACrB,EAAE;IACF,MAAM,YAAY,GAAG,MAAM,IAAA,2DAA2C,EAAC,IAAI,CAAC,CAAC;IAC7E,MAAM,KAAK,GAAG,SAAS,IAAI;QACzB,MAAM,EAAE,GAAG;QACX,IAAI,EAAE,YAAY,CAAC,QAAQ;KAC5B,CAAC;IAEF,MAAM,YAAY,GAAG,IAAA,cAAI,EAAC,YAAY,CAAC,GAAG,CAAC;SACxC,GAAG,CAAC,EAAE,CAAC;SACP,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;IAEnC,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC;AAfW,QAAA,2CAA2C,+CAetD;AAEK,MAAM,0BAA0B,GAAG,KAAK,EAC7C,OAAyC,qCAAqC,EAC9E,SAAqB,EACrB,EAAE;IACF,MAAM,YAAY,GAAG,MAAM,IAAA,6CAA6B,EAAC,IAAI,CAAC,CAAC;IAC/D,MAAM,KAAK,GAAG,SAAS,IAAI;QACzB,MAAM,EAAE,GAAG;QACX,IAAI,EAAE,YAAY,CAAC,QAAQ;KAC5B,CAAC;IAEF,MAAM,YAAY,GAAG,IAAA,cAAI,EAAC,YAAY,CAAC,GAAG,CAAC;SACxC,GAAG,CAAC,EAAE,CAAC;SACP,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;IAEnC,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC;AAfW,QAAA,0BAA0B,8BAerC;AAEK,MAAM,6BAA6B,GAAG,CAC3C,OAAyC,qCAAqC,EAC9E,SAAqC,EACrC,EAAE;IACF,MAAM,YAAY,GAAG,IAAA,6CAA6B,EAAC,IAAI,CAAC,CAAC;IACzD,MAAM,YAAY,GAAG,IAAA,cAAI,EAAC,YAAY,CAAC,GAAG,CAAC;SACxC,GAAG,CAAC,EAAE,CAAC;SACP,KAAK,CAAC,SAAS,EAAE,MAAM,IAAI,GAAG,CAAC,CAAC;IACnC,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC;AATW,QAAA,6BAA6B,iCASxC","sourcesContent":["import nock from 'nock';\n\nimport type {\n UserStoragePathWithFeatureAndKey,\n UserStoragePathWithFeatureOnly,\n} from '../schema';\nimport {\n getMockUserStorageGetResponse,\n getMockUserStoragePutResponse,\n getMockUserStorageAllFeatureEntriesResponse,\n} from './mockResponses';\n\ntype MockReply = {\n status: nock.StatusCode;\n body?: nock.Body;\n};\n\nexport const mockEndpointGetUserStorageAllFeatureEntries = async (\n path: UserStoragePathWithFeatureOnly = 'notifications',\n mockReply?: MockReply,\n) => {\n const mockResponse = await getMockUserStorageAllFeatureEntriesResponse(path);\n const reply = mockReply ?? {\n status: 200,\n body: mockResponse.response,\n };\n\n const mockEndpoint = nock(mockResponse.url)\n .get('')\n .reply(reply.status, reply.body);\n\n return mockEndpoint;\n};\n\nexport const mockEndpointGetUserStorage = async (\n path: UserStoragePathWithFeatureAndKey = 'notifications.notification_settings',\n mockReply?: MockReply,\n) => {\n const mockResponse = await getMockUserStorageGetResponse(path);\n const reply = mockReply ?? {\n status: 200,\n body: mockResponse.response,\n };\n\n const mockEndpoint = nock(mockResponse.url)\n .get('')\n .reply(reply.status, reply.body);\n\n return mockEndpoint;\n};\n\nexport const mockEndpointUpsertUserStorage = (\n path: UserStoragePathWithFeatureAndKey = 'notifications.notification_settings',\n mockReply?: Pick<MockReply, 'status'>,\n) => {\n const mockResponse = getMockUserStoragePutResponse(path);\n const mockEndpoint = nock(mockResponse.url)\n .put('')\n .reply(mockReply?.status ?? 204);\n return mockEndpoint;\n};\n"]}
@@ -18,7 +18,7 @@ export const mockEndpointGetUserStorageAllFeatureEntries = async (path = 'notifi
18
18
  .reply(reply.status, reply.body);
19
19
  return mockEndpoint;
20
20
  };
21
- export const mockEndpointGetUserStorage = async (path = 'notifications.notificationSettings', mockReply) => {
21
+ export const mockEndpointGetUserStorage = async (path = 'notifications.notification_settings', mockReply) => {
22
22
  const mockResponse = await getMockUserStorageGetResponse(path);
23
23
  const reply = mockReply ?? {
24
24
  status: 200,
@@ -29,7 +29,7 @@ export const mockEndpointGetUserStorage = async (path = 'notifications.notificat
29
29
  .reply(reply.status, reply.body);
30
30
  return mockEndpoint;
31
31
  };
32
- export const mockEndpointUpsertUserStorage = (path = 'notifications.notificationSettings', mockReply) => {
32
+ export const mockEndpointUpsertUserStorage = (path = 'notifications.notification_settings', mockReply) => {
33
33
  const mockResponse = getMockUserStoragePutResponse(path);
34
34
  const mockEndpoint = nock(mockResponse.url)
35
35
  .put('')
@@ -1 +1 @@
1
- {"version":3,"file":"mockServices.mjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/__fixtures__/mockServices.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,KAAI,aAAa;;AAMxB,OAAO,EAC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P,KAAK,CAAC,SAAS,EAAE,MAAM,IAAI,GAAG,CAAC,CAAC;IACnC,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC","sourcesContent":["import nock from 'nock';\n\nimport type {\n UserStoragePathWithFeatureAndKey,\n UserStoragePathWithFeatureOnly,\n} from '../schema';\nimport {\n getMockUserStorageGetResponse,\n getMockUserStoragePutResponse,\n getMockUserStorageAllFeatureEntriesResponse,\n} from './mockResponses';\n\ntype MockReply = {\n status: nock.StatusCode;\n body?: nock.Body;\n};\n\nexport const mockEndpointGetUserStorageAllFeatureEntries = async (\n path: UserStoragePathWithFeatureOnly = 'notifications',\n mockReply?: MockReply,\n) => {\n const mockResponse = await getMockUserStorageAllFeatureEntriesResponse(path);\n const reply = mockReply ?? {\n status: 200,\n body: mockResponse.response,\n };\n\n const mockEndpoint = nock(mockResponse.url)\n .get('')\n .reply(reply.status, reply.body);\n\n return mockEndpoint;\n};\n\nexport const mockEndpointGetUserStorage = async (\n path: UserStoragePathWithFeatureAndKey = 'notifications.notificationSettings',\n mockReply?: MockReply,\n) => {\n const mockResponse = await getMockUserStorageGetResponse(path);\n const reply = mockReply ?? {\n status: 200,\n body: mockResponse.response,\n };\n\n const mockEndpoint = nock(mockResponse.url)\n .get('')\n .reply(reply.status, reply.body);\n\n return mockEndpoint;\n};\n\nexport const mockEndpointUpsertUserStorage = (\n path: UserStoragePathWithFeatureAndKey = 'notifications.notificationSettings',\n mockReply?: Pick<MockReply, 'status'>,\n) => {\n const mockResponse = getMockUserStoragePutResponse(path);\n const mockEndpoint = nock(mockResponse.url)\n .put('')\n .reply(mockReply?.status ?? 204);\n return mockEndpoint;\n};\n"]}
1
+ {"version":3,"file":"mockServices.mjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/__fixtures__/mockServices.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,KAAI,aAAa;;AAMxB,OAAO,EACL,6BAA6B,EAC7B,6BAA6B,EAC7B,2CAA2C,EAC5C,4BAAwB;AAOzB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AAO,YAAY,CAAC;AACtB,CAAC,CAAC","sourcesContent":["import nock from 'nock';\n\nimport type {\n UserStoragePathWithFeatureAndKey,\n UserStoragePathWithFeatureOnly,\n} from '../schema';\nimport {\n getMockUserStorageGetResponse,\n getMockUserStoragePutResponse,\n getMockUserStorageAllFeatureEntriesResponse,\n} from './mockResponses';\n\ntype MockReply = {\n status: nock.StatusCode;\n body?: nock.Body;\n};\n\nexport const mockEndpointGetUserStorageAllFeatureEntries = async (\n path: UserStoragePathWithFeatureOnly = 'notifications',\n mockReply?: MockReply,\n) => {\n const mockResponse = await getMockUserStorageAllFeatureEntriesResponse(path);\n const reply = mockReply ?? {\n status: 200,\n body: mockResponse.response,\n };\n\n const mockEndpoint = nock(mockResponse.url)\n .get('')\n .reply(reply.status, reply.body);\n\n return mockEndpoint;\n};\n\nexport const mockEndpointGetUserStorage = async (\n path: UserStoragePathWithFeatureAndKey = 'notifications.notification_settings',\n mockReply?: MockReply,\n) => {\n const mockResponse = await getMockUserStorageGetResponse(path);\n const reply = mockReply ?? {\n status: 200,\n body: mockResponse.response,\n };\n\n const mockEndpoint = nock(mockResponse.url)\n .get('')\n .reply(reply.status, reply.body);\n\n return mockEndpoint;\n};\n\nexport const mockEndpointUpsertUserStorage = (\n path: UserStoragePathWithFeatureAndKey = 'notifications.notification_settings',\n mockReply?: Pick<MockReply, 'status'>,\n) => {\n const mockResponse = getMockUserStoragePutResponse(path);\n const mockEndpoint = nock(mockResponse.url)\n .put('')\n .reply(mockReply?.status ?? 204);\n return mockEndpoint;\n};\n"]}
@@ -11,7 +11,7 @@ const encryption_1 = require("./encryption/index.cjs");
11
11
  */
12
12
  const ALLOW_ARBITRARY_KEYS = 'ALLOW_ARBITRARY_KEYS';
13
13
  exports.USER_STORAGE_SCHEMA = {
14
- notifications: ['notificationSettings'],
14
+ notifications: ['notification_settings'],
15
15
  accounts: [ALLOW_ARBITRARY_KEYS],
16
16
  networks: [ALLOW_ARBITRARY_KEYS], // keyed by chains/networks
17
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CACrC,IAAY,EAC8B,EAAE;IAC5C,MAAM,SAAS,GAAG,aAAa,CAAC;IAEhC,OAAO,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC9B,CAAC,CAAC;AANW,QAAA,uBAAuB,2BAMlC;AAEF;;;;;;;;GAQG;AACH,SAAgB,eAAe,CAC7B,IAAsC,EACtC,UAAkB;IAElB,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,IAAA,gCAAwB,EAAC,IAAI,CAAC,CAAC;IACxD,MAAM,SAAS,GAAG,IAAA,6BAAgB,EAAC,GAAG,GAAG,UAAU,CAAC,CAAC;IAErD,OAAO,GAAG,OAAO,IAAI,SAAS,EAAE,CAAC;AACnC,CAAC;AARD,0CAQC","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_SCHEMA = {\n notifications: ['notificationSettings'],\n accounts: [ALLOW_ARBITRARY_KEYS], // keyed by account addresses\n networks: [ALLOW_ARBITRARY_KEYS], // keyed by chains/networks\n} as const;\n\ntype UserStorageSchema = typeof USER_STORAGE_SCHEMA;\n\ntype UserStorageFeatures = keyof UserStorageSchema;\ntype UserStorageFeatureKeys<Feature extends UserStorageFeatures> =\n UserStorageSchema[Feature][0] extends typeof ALLOW_ARBITRARY_KEYS\n ? string\n : UserStorageSchema[Feature][number];\n\ntype UserStorageFeatureAndKey = {\n feature: UserStorageFeatures;\n key: UserStorageFeatureKeys<UserStorageFeatures>;\n};\n\nexport type UserStoragePathWithFeatureOnly = keyof UserStorageSchema;\nexport type UserStoragePathWithFeatureAndKey = {\n [K in UserStorageFeatures]: `${K}.${UserStorageFeatureKeys<K>}`;\n}[UserStoragePathWithFeatureOnly];\n\nexport const getFeatureAndKeyFromPath = (\n path: UserStoragePathWithFeatureAndKey,\n): UserStorageFeatureAndKey => {\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('.') as [\n UserStorageFeatures,\n UserStorageFeatureKeys<UserStorageFeatures>,\n ];\n\n if (!(feature in USER_STORAGE_SCHEMA)) {\n throw new Error(`user-storage - invalid feature provided: ${feature}`);\n }\n\n const validFeature = USER_STORAGE_SCHEMA[feature] as readonly string[];\n\n if (\n !validFeature.includes(key) &&\n !validFeature.includes(ALLOW_ARBITRARY_KEYS)\n ) {\n const validKeys = USER_STORAGE_SCHEMA[feature].join(', ');\n\n throw new Error(\n `user-storage - invalid key provided for this feature: ${key}. Valid keys: ${validKeys}`,\n );\n }\n\n return { feature, key };\n};\n\nexport const isPathWithFeatureAndKey = (\n path: string,\n): path is UserStoragePathWithFeatureAndKey => {\n const pathRegex = /^\\w+\\.\\w+$/u;\n\n return pathRegex.test(path);\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: UserStoragePathWithFeatureAndKey,\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":"schema.cjs","sourceRoot":"","sources":["../../../src/controllers/user-storage/schema.ts"],"names":[],"mappings":";;;AAAA,uDAAgD;AAEhD;;;;;;GAMG;AACH,MAAM,oBAAoB,GAAG,sBAA+B,CAAC;AAEhD,QAAA,mBAAmB,GAAG;IACjC,aAAa,EAAE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ACtC,UAAkB;IAElB,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,IAAA,gCAAwB,EAAC,IAAI,CAAC,CAAC;IACxD,MAAM,SAAS,GAAG,IAAA,6BAAgB,EAAC,GAAG,GAAG,UAAU,CAAC,CAAC;IAErD,OAAO,GAAG,OAAO,IAAI,SAAS,EAAE,CAAC;AACnC,CAAC;AARD,0CAQC","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_SCHEMA = {\n notifications: ['notification_settings'],\n accounts: [ALLOW_ARBITRARY_KEYS], // keyed by account addresses\n networks: [ALLOW_ARBITRARY_KEYS], // keyed by chains/networks\n} as const;\n\ntype UserStorageSchema = typeof USER_STORAGE_SCHEMA;\n\ntype UserStorageFeatures = keyof UserStorageSchema;\ntype UserStorageFeatureKeys<Feature extends UserStorageFeatures> =\n UserStorageSchema[Feature][0] extends typeof ALLOW_ARBITRARY_KEYS\n ? string\n : UserStorageSchema[Feature][number];\n\ntype UserStorageFeatureAndKey = {\n feature: UserStorageFeatures;\n key: UserStorageFeatureKeys<UserStorageFeatures>;\n};\n\nexport type UserStoragePathWithFeatureOnly = keyof UserStorageSchema;\nexport type UserStoragePathWithFeatureAndKey = {\n [K in UserStorageFeatures]: `${K}.${UserStorageFeatureKeys<K>}`;\n}[UserStoragePathWithFeatureOnly];\n\nexport const getFeatureAndKeyFromPath = (\n path: UserStoragePathWithFeatureAndKey,\n): UserStorageFeatureAndKey => {\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('.') as [\n UserStorageFeatures,\n UserStorageFeatureKeys<UserStorageFeatures>,\n ];\n\n if (!(feature in USER_STORAGE_SCHEMA)) {\n throw new Error(`user-storage - invalid feature provided: ${feature}`);\n }\n\n const validFeature = USER_STORAGE_SCHEMA[feature] as readonly string[];\n\n if (\n !validFeature.includes(key) &&\n !validFeature.includes(ALLOW_ARBITRARY_KEYS)\n ) {\n const validKeys = USER_STORAGE_SCHEMA[feature].join(', ');\n\n throw new Error(\n `user-storage - invalid key provided for this feature: ${key}. Valid keys: ${validKeys}`,\n );\n }\n\n return { feature, key };\n};\n\nexport const isPathWithFeatureAndKey = (\n path: string,\n): path is UserStoragePathWithFeatureAndKey => {\n const pathRegex = /^\\w+\\.\\w+$/u;\n\n return pathRegex.test(path);\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: UserStoragePathWithFeatureAndKey,\n storageKey: string,\n): string {\n const { feature, key } = getFeatureAndKeyFromPath(path);\n const hashedKey = createSHA256Hash(key + storageKey);\n\n return `${feature}/${hashedKey}`;\n}\n"]}
@@ -7,7 +7,7 @@
7
7
  */
8
8
  declare const ALLOW_ARBITRARY_KEYS: "ALLOW_ARBITRARY_KEYS";
9
9
  export declare const USER_STORAGE_SCHEMA: {
10
- readonly notifications: readonly ["notificationSettings"];
10
+ readonly notifications: readonly ["notification_settings"];
11
11
  readonly accounts: readonly ["ALLOW_ARBITRARY_KEYS"];
12
12
  readonly networks: readonly ["ALLOW_ARBITRARY_KEYS"];
13
13
  };
@@ -7,7 +7,7 @@
7
7
  */
8
8
  declare const ALLOW_ARBITRARY_KEYS: "ALLOW_ARBITRARY_KEYS";
9
9
  export declare const USER_STORAGE_SCHEMA: {
10
- readonly notifications: readonly ["notificationSettings"];
10
+ readonly notifications: readonly ["notification_settings"];
11
11
  readonly accounts: readonly ["ALLOW_ARBITRARY_KEYS"];
12
12
  readonly networks: readonly ["ALLOW_ARBITRARY_KEYS"];
13
13
  };
@@ -8,7 +8,7 @@ import { createSHA256Hash } from "./encryption/index.mjs";
8
8
  */
9
9
  const ALLOW_ARBITRARY_KEYS = 'ALLOW_ARBITRARY_KEYS';
10
10
  export const USER_STORAGE_SCHEMA = {
11
- notifications: ['notificationSettings'],
11
+ notifications: ['notification_settings'],
12
12
  accounts: [ALLOW_ARBITRARY_KEYS],
13
13
  networks: [ALLOW_ARBITRARY_KEYS], // keyed by chains/networks
14
14
  };
@@ -1 +1 @@
1
- {"version":3,"file":"schema.mjs","sourceRoot":"","sources":["../../../src/controllers/user-storage/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,+BAAqB;AAEhD;;;;;;GAMG;AACH,MAAM,oBAAoB,GAAG,sBAA+B,CAAC;AAE7D,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,aAAa,EAAE,CAAC,sBAAsB,CAAC;IACvC,QAAQ,EAAE,CAAC,oBAAoB,CAAC;IAChC,QAAQ,EAAE,CAAC,oBAAoB,CAAC,EAAE,2BAA2B;CACrD,CAAC;AAoBX,MAAM,CAAC,MAAM,wBAAwB,GAAG,CACtC,IAAsC,EACZ,EAAE;IAC5B,MAAM,SAAS,GAAG,aAAa,CAAC;IAEhC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;QACzB,MAAM,IAAI,KAAK,CACb,iFAAiF,CAClF,CAAC;KACH;IAED,MAAM,CAAC,OAAO,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAGpC,CAAC;IAEF,IAAI,CAAC,CAAC,OAAO,IAAI,mBAAmB,CAAC,EAAE;QACrC,MAAM,IAAI,KAAK,CAAC,4CAA4C,OAAO,EAAE,CAAC,CAAC;KACxE;IAED,MAAM,YAAY,GAAG,mBAAmB,CAAC,OAAO,CAAsB,CAAC;IAEvE,IACE,CAAC,YAAY,CAAC,QAAQ,CAAC,GAAG,CAAC;QAC3B,CAAC,YAAY,CAAC,QAAQ,CAAC,oBAAoB,CAAC,EAC5C;QACA,MAAM,SAAS,GAAG,mBAAmB,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAE1D,MAAM,IAAI,KAAK,CACb,yDAAyD,GAAG,iBAAiB,SAAS,EAAE,CACzF,CAAC;KACH;IAED,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC;AAC1B,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,uBAAuB,GAAG,CACrC,IAAY,EAC8B,EAAE;IAC5C,MAAM,SAAS,GAAG,aAAa,CAAC;IAEhC,OAAO,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC9B,CAAC,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,UAAU,eAAe,CAC7B,IAAsC,EACtC,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';\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_SCHEMA = {\n notifications: ['notificationSettings'],\n accounts: [ALLOW_ARBITRARY_KEYS], // keyed by account addresses\n networks: [ALLOW_ARBITRARY_KEYS], // keyed by chains/networks\n} as const;\n\ntype UserStorageSchema = typeof USER_STORAGE_SCHEMA;\n\ntype UserStorageFeatures = keyof UserStorageSchema;\ntype UserStorageFeatureKeys<Feature extends UserStorageFeatures> =\n UserStorageSchema[Feature][0] extends typeof ALLOW_ARBITRARY_KEYS\n ? string\n : UserStorageSchema[Feature][number];\n\ntype UserStorageFeatureAndKey = {\n feature: UserStorageFeatures;\n key: UserStorageFeatureKeys<UserStorageFeatures>;\n};\n\nexport type UserStoragePathWithFeatureOnly = keyof UserStorageSchema;\nexport type UserStoragePathWithFeatureAndKey = {\n [K in UserStorageFeatures]: `${K}.${UserStorageFeatureKeys<K>}`;\n}[UserStoragePathWithFeatureOnly];\n\nexport const getFeatureAndKeyFromPath = (\n path: UserStoragePathWithFeatureAndKey,\n): UserStorageFeatureAndKey => {\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('.') as [\n UserStorageFeatures,\n UserStorageFeatureKeys<UserStorageFeatures>,\n ];\n\n if (!(feature in USER_STORAGE_SCHEMA)) {\n throw new Error(`user-storage - invalid feature provided: ${feature}`);\n }\n\n const validFeature = USER_STORAGE_SCHEMA[feature] as readonly string[];\n\n if (\n !validFeature.includes(key) &&\n !validFeature.includes(ALLOW_ARBITRARY_KEYS)\n ) {\n const validKeys = USER_STORAGE_SCHEMA[feature].join(', ');\n\n throw new Error(\n `user-storage - invalid key provided for this feature: ${key}. Valid keys: ${validKeys}`,\n );\n }\n\n return { feature, key };\n};\n\nexport const isPathWithFeatureAndKey = (\n path: string,\n): path is UserStoragePathWithFeatureAndKey => {\n const pathRegex = /^\\w+\\.\\w+$/u;\n\n return pathRegex.test(path);\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: UserStoragePathWithFeatureAndKey,\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":"schema.mjs","sourceRoot":"","sources":["../../../src/controllers/user-storage/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,+BAAqB;AAEhD;;;;;;GAMG;AACH,MAAM,oBAAoB,GAAG,sBAA+B,CAAC;AAE7D,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,aAAa,EAAE,CAAC,uBAAuB,CAAC;IACxC,QAAQ,EAAE,CAAC,oBAAoB,CAAC;IAChC,QAAQ,EAAE,CAAC,oBAAoB,CAAC,EAAE,2BAA2B;CACrD,CAAC;AAoBX,MAAM,CAAC,MAAM,wBAAwB,GAAG,CACtC,IAAsC,EACZ,EAAE;IAC5B,MAAM,SAAS,GAAG,aAAa,CAAC;IAEhC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;QACzB,MAAM,IAAI,KAAK,CACb,iFAAiF,CAClF,CAAC;KACH;IAED,MAAM,CAAC,OAAO,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAGpC,CAAC;IAEF,IAAI,CAAC,CAAC,OAAO,IAAI,mBAAmB,CAAC,EAAE;QACrC,MAAM,IAAI,KAAK,CAAC,4CAA4C,OAAO,EAAE,CAAC,CAAC;KACxE;IAED,MAAM,YAAY,GAAG,mBAAmB,CAAC,OAAO,CAAsB,CAAC;IAEvE,IACE,CAAC,YAAY,CAAC,QAAQ,CAAC,GAAG,CAAC;QAC3B,CAAC,YAAY,CAAC,QAAQ,CAAC,oBAAoB,CAAC,EAC5C;QACA,MAAM,SAAS,GAAG,mBAAmB,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAE1D,MAAM,IAAI,KAAK,CACb,yDAAyD,GAAG,iBAAiB,SAAS,EAAE,CACzF,CAAC;KACH;IAED,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC;AAC1B,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,uBAAuB,GAAG,CACrC,IAAY,EAC8B,EAAE;IAC5C,MAAM,SAAS,GAAG,aAAa,CAAC;IAEhC,OAAO,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC9B,CAAC,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,UAAU,eAAe,CAC7B,IAAsC,EACtC,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';\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_SCHEMA = {\n notifications: ['notification_settings'],\n accounts: [ALLOW_ARBITRARY_KEYS], // keyed by account addresses\n networks: [ALLOW_ARBITRARY_KEYS], // keyed by chains/networks\n} as const;\n\ntype UserStorageSchema = typeof USER_STORAGE_SCHEMA;\n\ntype UserStorageFeatures = keyof UserStorageSchema;\ntype UserStorageFeatureKeys<Feature extends UserStorageFeatures> =\n UserStorageSchema[Feature][0] extends typeof ALLOW_ARBITRARY_KEYS\n ? string\n : UserStorageSchema[Feature][number];\n\ntype UserStorageFeatureAndKey = {\n feature: UserStorageFeatures;\n key: UserStorageFeatureKeys<UserStorageFeatures>;\n};\n\nexport type UserStoragePathWithFeatureOnly = keyof UserStorageSchema;\nexport type UserStoragePathWithFeatureAndKey = {\n [K in UserStorageFeatures]: `${K}.${UserStorageFeatureKeys<K>}`;\n}[UserStoragePathWithFeatureOnly];\n\nexport const getFeatureAndKeyFromPath = (\n path: UserStoragePathWithFeatureAndKey,\n): UserStorageFeatureAndKey => {\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('.') as [\n UserStorageFeatures,\n UserStorageFeatureKeys<UserStorageFeatures>,\n ];\n\n if (!(feature in USER_STORAGE_SCHEMA)) {\n throw new Error(`user-storage - invalid feature provided: ${feature}`);\n }\n\n const validFeature = USER_STORAGE_SCHEMA[feature] as readonly string[];\n\n if (\n !validFeature.includes(key) &&\n !validFeature.includes(ALLOW_ARBITRARY_KEYS)\n ) {\n const validKeys = USER_STORAGE_SCHEMA[feature].join(', ');\n\n throw new Error(\n `user-storage - invalid key provided for this feature: ${key}. Valid keys: ${validKeys}`,\n );\n }\n\n return { feature, key };\n};\n\nexport const isPathWithFeatureAndKey = (\n path: string,\n): path is UserStoragePathWithFeatureAndKey => {\n const pathRegex = /^\\w+\\.\\w+$/u;\n\n return pathRegex.test(path);\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: UserStoragePathWithFeatureAndKey,\n storageKey: string,\n): string {\n const { feature, key } = getFeatureAndKeyFromPath(path);\n const hashedKey = createSHA256Hash(key + storageKey);\n\n return `${feature}/${hashedKey}`;\n}\n"]}
@@ -9,7 +9,7 @@ const encryption_1 = __importDefault(require("../encryption.cjs"));
9
9
  const env_1 = require("../env.cjs");
10
10
  const user_storage_1 = require("../user-storage.cjs");
11
11
  // Example mock notifications storage entry (wildcard)
12
- const MOCK_STORAGE_URL = (0, user_storage_1.STORAGE_URL)(env_1.Env.DEV, 'notifications/notificationSettings');
12
+ const MOCK_STORAGE_URL = (0, user_storage_1.STORAGE_URL)(env_1.Env.DEV, 'notifications/notification_settings');
13
13
  const MOCK_STORAGE_URL_ALL_FEATURE_ENTRIES = (0, user_storage_1.STORAGE_URL)(env_1.Env.DEV, 'notifications');
14
14
  exports.MOCK_STORAGE_KEY = 'MOCK_STORAGE_KEY';
15
15
  // TODO: Either fix this lint violation or explain why it's necessary to ignore.
@@ -1 +1 @@
1
- {"version":3,"file":"mock-userstorage.cjs","sourceRoot":"","sources":["../../../src/sdk/__fixtures__/mock-userstorage.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AAExB,mEAAuC;AACvC,oCAA6B;AAC7B,sDAA8C;AAO9C,sDAAsD;AACtD,MAAM,gBAAgB,GAAG,IAAA,0BAAW,EAClC,SAAG,CAAC,GAAG,EACP,oCAAoC,CACrC,CAAC;AACF,MAAM,oCAAoC,GAAG,IAAA,0BAAW,EACtD,SAAG,CAAC,GAAG,EACP,eAAe,CAChB,CAAC;AAEW,QAAA,gBAAgB,GAAG,kBAAkB,CAAC;AACnD,gFAAgF;AAChF,gEAAgE;AACnD,QAAA,uBAAuB,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC;AACtD,MAAM,iCAAiC,GAAG,KAAK,IAAI,EAAE,CAC1D,MAAM,oBAAU,CAAC,aAAa,CAC5B,IAAI,CAAC,SAAS,CAAC,+BAAuB,CAAC,EACvC,wBAAgB,CACjB,CAAC;AAJS,QAAA,iCAAiC,qCAI1C;AAEG,MAAM,qBAAqB,GAAG,KAAK,IAAI,EAAE,CAAC,CAAC;IAChD,SAAS,EAAE,kEAAkE;IAC7E,IAAI,EAAE,MAAM,IAAA,yCAAiC,GAAE;CAChD,CAAC,CAAC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ent":["import nock from 'nock';\n\nimport encryption from '../encryption';\nimport { Env } from '../env';\nimport { STORAGE_URL } from '../user-storage';\n\ntype MockReply = {\n status: nock.StatusCode;\n body?: nock.Body;\n};\n\n// Example mock notifications storage entry (wildcard)\nconst MOCK_STORAGE_URL = STORAGE_URL(\n Env.DEV,\n 'notifications/notificationSettings',\n);\nconst MOCK_STORAGE_URL_ALL_FEATURE_ENTRIES = STORAGE_URL(\n Env.DEV,\n 'notifications',\n);\n\nexport const MOCK_STORAGE_KEY = 'MOCK_STORAGE_KEY';\n// TODO: Either fix this lint violation or explain why it's necessary to ignore.\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const MOCK_NOTIFICATIONS_DATA = { is_compact: false };\nexport const MOCK_NOTIFICATIONS_DATA_ENCRYPTED = async () =>\n await encryption.encryptString(\n JSON.stringify(MOCK_NOTIFICATIONS_DATA),\n MOCK_STORAGE_KEY,\n );\n\nexport const MOCK_STORAGE_RESPONSE = async () => ({\n HashedKey: '8485d2c14c333ebca415140a276adaf546619b0efc204586b73a5d400a18a5e2',\n Data: await MOCK_NOTIFICATIONS_DATA_ENCRYPTED(),\n});\n\nexport const handleMockUserStorageGet = async (mockReply?: MockReply) => {\n const reply = mockReply ?? {\n status: 200,\n body: await MOCK_STORAGE_RESPONSE(),\n };\n const mockEndpoint = nock(MOCK_STORAGE_URL)\n .persist()\n .get(/.*/u)\n .reply(reply.status, reply.body);\n\n return mockEndpoint;\n};\n\nexport const handleMockUserStorageGetAllFeatureEntries = async (\n mockReply?: MockReply,\n) => {\n const reply = mockReply ?? {\n status: 200,\n body: [await MOCK_STORAGE_RESPONSE()],\n };\n const mockEndpoint = nock(MOCK_STORAGE_URL_ALL_FEATURE_ENTRIES)\n .persist()\n .get('')\n .reply(reply.status, reply.body);\n\n return mockEndpoint;\n};\n\nexport const handleMockUserStoragePut = (mockReply?: MockReply) => {\n const reply = mockReply ?? { status: 204 };\n const mockEndpoint = nock(MOCK_STORAGE_URL)\n .persist()\n .put(/.*/u)\n .reply(reply.status);\n\n return mockEndpoint;\n};\n"]}
1
+ {"version":3,"file":"mock-userstorage.cjs","sourceRoot":"","sources":["../../../src/sdk/__fixtures__/mock-userstorage.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AAExB,mEAAuC;AACvC,oCAA6B;AAC7B,sDAA8C;AAO9C,sDAAsD;AACtD,MAAM,gBAAgB,GAAG,IAAA,0BAAW,EAClC,SAAG,CAAC,GAAG,EACP,qCAAqC,CACtC,CAAC;AACF,MAAM,oCAAoC,GAAG,IAAA,0BAAW,EACtD,SAAG,CAAC,GAAG,EACP,eAAe,CAChB,CAAC;AAEW,QAAA,gBAAgB,GAAG,kBAAkB,CAAC;AACnD,gFAAgF;AAChF,gEAAgE;AACnD,QAAA,uBAAuB,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC;AACtD,MAAM,iCAAiC,GAAG,KAAK,IAAI,EAAE,CAC1D,MAAM,oBAAU,CAAC,aAAa,CAC5B,IAAI,CAAC,SAAS,CAAC,+BAAuB,CAAC,EACvC,wBAAgB,CACjB,CAAC;AAJS,QAAA,iCAAiC,qCAI1C;AAEG,MAAM,qBAAqB,GAAG,KAAK,IAAI,EAAE,CAAC,CAAC;IAChD,SAAS,EAAE,kEAAkE;IAC7E,IAAI,EAAE,MAAM,IAAA,yCAAiC,GAAE;CAChD,CAAC,CAAC;AAHU,QAAA,qBAAqB,yBAG/B;AAEI,MAAM,wBAAwB,GAAG,KAAK,EAAE,SAAqB,EAAE,EAAE;IACtE,MAAM,KAAK,GAAG,SAAS,IAAI;QACzB,MAAM,EAAE,GAAG;QACX,IAAI,EAAE,MAAM,IAAA,6BAAqB,GAAE;KACpC,CAAC;IACF,MAAM,YAAY,GAAG,IAAA,cAAI,EAAC,gBAAgB,CAAC;SACxC,OAAO,EAAE;SACT,GAAG,CAAC,KAAK,CAAC;SACV,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;IAEnC,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC;AAXW,QAAA,wBAAwB,4BAWnC;AAEK,MAAM,yCAAyC,GAAG,KAAK,EAC5D,SAAqB,EACrB,EAAE;IACF,MAAM,KAAK,GAAG,SAAS,IAAI;QACzB,MAAM,EAAE,GAAG;QACX,IAAI,EAAE,CAAC,MAAM,IAAA,6BAAqB,GAAE,CAAC;KACtC,CAAC;IACF,MAAM,YAAY,GAAG,IAAA,cAAI,EAAC,oCAAoC,CAAC;SAC5D,OAAO,EAAE;SACT,GAAG,CAAC,EAAE,CAAC;SACP,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;IAEnC,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC;AAbW,QAAA,yCAAyC,6CAapD;AAEK,MAAM,wBAAwB,GAAG,CAAC,SAAqB,EAAE,EAAE;IAChE,MAAM,KAAK,GAAG,SAAS,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC;IAC3C,MAAM,YAAY,GAAG,IAAA,cAAI,EAAC,gBAAgB,CAAC;SACxC,OAAO,EAAE;SACT,GAAG,CAAC,KAAK,CAAC;SACV,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAEvB,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC;AARW,QAAA,wBAAwB,4BAQnC","sourcesContent":["import nock from 'nock';\n\nimport encryption from '../encryption';\nimport { Env } from '../env';\nimport { STORAGE_URL } from '../user-storage';\n\ntype MockReply = {\n status: nock.StatusCode;\n body?: nock.Body;\n};\n\n// Example mock notifications storage entry (wildcard)\nconst MOCK_STORAGE_URL = STORAGE_URL(\n Env.DEV,\n 'notifications/notification_settings',\n);\nconst MOCK_STORAGE_URL_ALL_FEATURE_ENTRIES = STORAGE_URL(\n Env.DEV,\n 'notifications',\n);\n\nexport const MOCK_STORAGE_KEY = 'MOCK_STORAGE_KEY';\n// TODO: Either fix this lint violation or explain why it's necessary to ignore.\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const MOCK_NOTIFICATIONS_DATA = { is_compact: false };\nexport const MOCK_NOTIFICATIONS_DATA_ENCRYPTED = async () =>\n await encryption.encryptString(\n JSON.stringify(MOCK_NOTIFICATIONS_DATA),\n MOCK_STORAGE_KEY,\n );\n\nexport const MOCK_STORAGE_RESPONSE = async () => ({\n HashedKey: '8485d2c14c333ebca415140a276adaf546619b0efc204586b73a5d400a18a5e2',\n Data: await MOCK_NOTIFICATIONS_DATA_ENCRYPTED(),\n});\n\nexport const handleMockUserStorageGet = async (mockReply?: MockReply) => {\n const reply = mockReply ?? {\n status: 200,\n body: await MOCK_STORAGE_RESPONSE(),\n };\n const mockEndpoint = nock(MOCK_STORAGE_URL)\n .persist()\n .get(/.*/u)\n .reply(reply.status, reply.body);\n\n return mockEndpoint;\n};\n\nexport const handleMockUserStorageGetAllFeatureEntries = async (\n mockReply?: MockReply,\n) => {\n const reply = mockReply ?? {\n status: 200,\n body: [await MOCK_STORAGE_RESPONSE()],\n };\n const mockEndpoint = nock(MOCK_STORAGE_URL_ALL_FEATURE_ENTRIES)\n .persist()\n .get('')\n .reply(reply.status, reply.body);\n\n return mockEndpoint;\n};\n\nexport const handleMockUserStoragePut = (mockReply?: MockReply) => {\n const reply = mockReply ?? { status: 204 };\n const mockEndpoint = nock(MOCK_STORAGE_URL)\n .persist()\n .put(/.*/u)\n .reply(reply.status);\n\n return mockEndpoint;\n};\n"]}
@@ -10,7 +10,7 @@ import encryption from "../encryption.mjs";
10
10
  import { Env } from "../env.mjs";
11
11
  import { STORAGE_URL } from "../user-storage.mjs";
12
12
  // Example mock notifications storage entry (wildcard)
13
- const MOCK_STORAGE_URL = STORAGE_URL(Env.DEV, 'notifications/notificationSettings');
13
+ const MOCK_STORAGE_URL = STORAGE_URL(Env.DEV, 'notifications/notification_settings');
14
14
  const MOCK_STORAGE_URL_ALL_FEATURE_ENTRIES = STORAGE_URL(Env.DEV, 'notifications');
15
15
  export const MOCK_STORAGE_KEY = 'MOCK_STORAGE_KEY';
16
16
  // TODO: Either fix this lint violation or explain why it's necessary to ignore.
@@ -1 +1 @@
1
- {"version":3,"file":"mock-userstorage.mjs","sourceRoot":"","sources":["../../../src/sdk/__fixtures__/mock-userstorage.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,KAAI,aAAa;;AAExB,OAAO,UAAU,0BAAsB;AACvC,OAAO,EAAE,GAAG,EAAE,mBAAe;AAC7B,OAAO,EAAE,WAAW,EAAE,4BAAwB;AAO9C,sDAAsD;AACtD,MAAM,gBAAgB,GAAG,WAAW,CAClC,GAAG,CAAC,GAAG,EACP,oCAAoC,CACrC,CAAC;AACF,MAAM,oCAAoC,GAAG,WAAW,CACtD,GAAG,CAAC,GAAG,EACP,eAAe,CAChB,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG,kBAAkB,CAAC;AACnD,gFAAgF;AAChF,gEAAgE;AAChE,MAAM,CAAC,MAAM,uBAAuB,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC;AAC7D,MAAM,CAAC,MAAM,iCAAiC,GAAG,KAAK,IAAI,EAAE,CAC1D,MAAM,UAAU,CAAC,aAAa,CAC5B,IAAI,CAAC,SAAS,CAAC,uBAAuB,CAAC,EACvC,gBAAgB,CACjB,CAAC;AAEJ,MAAM,CAAC,MAAM,qBAAqB,GAAG,KAAK,IAAI,EAAE,CAAC,CAAC;IAChD,SAAS,EAAE,kEAAkE;IAC7E,IAAI,EAAE,MAAM,iCAAiC,EAAE;CAChD,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,wBAAwB,GAAG,KAAK,EAAE,SAAqB,EAAE,EAAE;IACtE,MAAM,KAAK,GAAG,SAAS,IAAI;QACzB,MAAM,EAAE,GAAG;QACX,IAAI,EAAE,MAAM,qBAAqB,EAAE;KACpC,CAAC;IACF,MAAM,YAAY,GAAG,IAAI,CAAC,gBAAgB,CAAC;SACxC,OAAO,EAAE;SACT,GAAG,CAAC,KAAK,CAAC;SACV,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;IAEnC,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,yCAAyC,GAAG,KAAK,EAC5D,SAAqB,EACrB,EAAE;IACF,MAAM,KAAK,GAAG,SAAS,IAAI;QACzB,MAAM,EAAE,GAAG;QACX,IAAI,EAAE,CAAC,MAAM,qBAAqB,EAAE,CAAC;KACtC,CAAC;IACF,MAAM,YAAY,GAAG,IAAI,CAAC,oCAAoC,CAAC;SAC5D,OAAO,EAAE;SACT,GAAG,CAAC,EAAE,CAAC;SACP,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;IAEnC,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,SAAqB,EAAE,EAAE;IAChE,MAAM,KAAK,GAAG,SAAS,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC;IAC3C,MAAM,YAAY,GAAG,IAAI,CAAC,gBAAgB,CAAC;SACxC,OAAO,EAAE;SACT,GAAG,CAAC,KAAK,CAAC;SACV,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAEvB,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC","sourcesContent":["import nock from 'nock';\n\nimport encryption from '../encryption';\nimport { Env } from '../env';\nimport { STORAGE_URL } from '../user-storage';\n\ntype MockReply = {\n status: nock.StatusCode;\n body?: nock.Body;\n};\n\n// Example mock notifications storage entry (wildcard)\nconst MOCK_STORAGE_URL = STORAGE_URL(\n Env.DEV,\n 'notifications/notificationSettings',\n);\nconst MOCK_STORAGE_URL_ALL_FEATURE_ENTRIES = STORAGE_URL(\n Env.DEV,\n 'notifications',\n);\n\nexport const MOCK_STORAGE_KEY = 'MOCK_STORAGE_KEY';\n// TODO: Either fix this lint violation or explain why it's necessary to ignore.\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const MOCK_NOTIFICATIONS_DATA = { is_compact: false };\nexport const MOCK_NOTIFICATIONS_DATA_ENCRYPTED = async () =>\n await encryption.encryptString(\n JSON.stringify(MOCK_NOTIFICATIONS_DATA),\n MOCK_STORAGE_KEY,\n );\n\nexport const MOCK_STORAGE_RESPONSE = async () => ({\n HashedKey: '8485d2c14c333ebca415140a276adaf546619b0efc204586b73a5d400a18a5e2',\n Data: await MOCK_NOTIFICATIONS_DATA_ENCRYPTED(),\n});\n\nexport const handleMockUserStorageGet = async (mockReply?: MockReply) => {\n const reply = mockReply ?? {\n status: 200,\n body: await MOCK_STORAGE_RESPONSE(),\n };\n const mockEndpoint = nock(MOCK_STORAGE_URL)\n .persist()\n .get(/.*/u)\n .reply(reply.status, reply.body);\n\n return mockEndpoint;\n};\n\nexport const handleMockUserStorageGetAllFeatureEntries = async (\n mockReply?: MockReply,\n) => {\n const reply = mockReply ?? {\n status: 200,\n body: [await MOCK_STORAGE_RESPONSE()],\n };\n const mockEndpoint = nock(MOCK_STORAGE_URL_ALL_FEATURE_ENTRIES)\n .persist()\n .get('')\n .reply(reply.status, reply.body);\n\n return mockEndpoint;\n};\n\nexport const handleMockUserStoragePut = (mockReply?: MockReply) => {\n const reply = mockReply ?? { status: 204 };\n const mockEndpoint = nock(MOCK_STORAGE_URL)\n .persist()\n .put(/.*/u)\n .reply(reply.status);\n\n return mockEndpoint;\n};\n"]}
1
+ {"version":3,"file":"mock-userstorage.mjs","sourceRoot":"","sources":["../../../src/sdk/__fixtures__/mock-userstorage.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,KAAI,aAAa;;AAExB,OAAO,UAAU,0BAAsB;AACvC,OAAO,EAAE,GAAG,EAAE,mBAAe;AAC7B,OAAO,EAAE,WAAW,EAAE,4BAAwB;AAO9C,sDAAsD;AACtD,MAAM,gBAAgB,GAAG,WAAW,CAClC,GAAG,CAAC,GAAG,EACP,qCAAqC,CACtC,CAAC;AACF,M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,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;IAEnC,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,SAAqB,EAAE,EAAE;IAChE,MAAM,KAAK,GAAG,SAAS,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC;IAC3C,MAAM,YAAY,GAAG,IAAI,CAAC,gBAAgB,CAAC;SACxC,OAAO,EAAE;SACT,GAAG,CAAC,KAAK,CAAC;SACV,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAEvB,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC","sourcesContent":["import nock from 'nock';\n\nimport encryption from '../encryption';\nimport { Env } from '../env';\nimport { STORAGE_URL } from '../user-storage';\n\ntype MockReply = {\n status: nock.StatusCode;\n body?: nock.Body;\n};\n\n// Example mock notifications storage entry (wildcard)\nconst MOCK_STORAGE_URL = STORAGE_URL(\n Env.DEV,\n 'notifications/notification_settings',\n);\nconst MOCK_STORAGE_URL_ALL_FEATURE_ENTRIES = STORAGE_URL(\n Env.DEV,\n 'notifications',\n);\n\nexport const MOCK_STORAGE_KEY = 'MOCK_STORAGE_KEY';\n// TODO: Either fix this lint violation or explain why it's necessary to ignore.\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const MOCK_NOTIFICATIONS_DATA = { is_compact: false };\nexport const MOCK_NOTIFICATIONS_DATA_ENCRYPTED = async () =>\n await encryption.encryptString(\n JSON.stringify(MOCK_NOTIFICATIONS_DATA),\n MOCK_STORAGE_KEY,\n );\n\nexport const MOCK_STORAGE_RESPONSE = async () => ({\n HashedKey: '8485d2c14c333ebca415140a276adaf546619b0efc204586b73a5d400a18a5e2',\n Data: await MOCK_NOTIFICATIONS_DATA_ENCRYPTED(),\n});\n\nexport const handleMockUserStorageGet = async (mockReply?: MockReply) => {\n const reply = mockReply ?? {\n status: 200,\n body: await MOCK_STORAGE_RESPONSE(),\n };\n const mockEndpoint = nock(MOCK_STORAGE_URL)\n .persist()\n .get(/.*/u)\n .reply(reply.status, reply.body);\n\n return mockEndpoint;\n};\n\nexport const handleMockUserStorageGetAllFeatureEntries = async (\n mockReply?: MockReply,\n) => {\n const reply = mockReply ?? {\n status: 200,\n body: [await MOCK_STORAGE_RESPONSE()],\n };\n const mockEndpoint = nock(MOCK_STORAGE_URL_ALL_FEATURE_ENTRIES)\n .persist()\n .get('')\n .reply(reply.status, reply.body);\n\n return mockEndpoint;\n};\n\nexport const handleMockUserStoragePut = (mockReply?: MockReply) => {\n const reply = mockReply ?? { status: 204 };\n const mockEndpoint = nock(MOCK_STORAGE_URL)\n .persist()\n .put(/.*/u)\n .reply(reply.status);\n\n return mockEndpoint;\n};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask/profile-sync-controller",
3
- "version": "0.7.0",
3
+ "version": "0.8.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",