@metamask-previews/notification-services-controller 10.0.0-preview-5dcecbb7 → 10.0.0-preview-8dfa2801

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.
Files changed (160) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/NotificationServicesController/NotificationServicesController.cjs +76 -188
  3. package/dist/NotificationServicesController/NotificationServicesController.cjs.map +1 -1
  4. package/dist/NotificationServicesController/NotificationServicesController.d.cts +10 -16
  5. package/dist/NotificationServicesController/NotificationServicesController.d.cts.map +1 -1
  6. package/dist/NotificationServicesController/NotificationServicesController.d.mts +10 -16
  7. package/dist/NotificationServicesController/NotificationServicesController.d.mts.map +1 -1
  8. package/dist/NotificationServicesController/NotificationServicesController.mjs +77 -189
  9. package/dist/NotificationServicesController/NotificationServicesController.mjs.map +1 -1
  10. package/dist/NotificationServicesController/constants/index.cjs +0 -1
  11. package/dist/NotificationServicesController/constants/index.cjs.map +1 -1
  12. package/dist/NotificationServicesController/constants/index.d.cts +0 -1
  13. package/dist/NotificationServicesController/constants/index.d.cts.map +1 -1
  14. package/dist/NotificationServicesController/constants/index.d.mts +0 -1
  15. package/dist/NotificationServicesController/constants/index.d.mts.map +1 -1
  16. package/dist/NotificationServicesController/constants/index.mjs +0 -1
  17. package/dist/NotificationServicesController/constants/index.mjs.map +1 -1
  18. package/dist/NotificationServicesController/constants/notification-schema.cjs +1 -0
  19. package/dist/NotificationServicesController/constants/notification-schema.cjs.map +1 -1
  20. package/dist/NotificationServicesController/constants/notification-schema.d.cts +1 -0
  21. package/dist/NotificationServicesController/constants/notification-schema.d.cts.map +1 -1
  22. package/dist/NotificationServicesController/constants/notification-schema.d.mts +1 -0
  23. package/dist/NotificationServicesController/constants/notification-schema.d.mts.map +1 -1
  24. package/dist/NotificationServicesController/constants/notification-schema.mjs +1 -0
  25. package/dist/NotificationServicesController/constants/notification-schema.mjs.map +1 -1
  26. package/dist/NotificationServicesController/mocks/index.cjs +0 -2
  27. package/dist/NotificationServicesController/mocks/index.cjs.map +1 -1
  28. package/dist/NotificationServicesController/mocks/index.d.cts +0 -2
  29. package/dist/NotificationServicesController/mocks/index.d.cts.map +1 -1
  30. package/dist/NotificationServicesController/mocks/index.d.mts +0 -2
  31. package/dist/NotificationServicesController/mocks/index.d.mts.map +1 -1
  32. package/dist/NotificationServicesController/mocks/index.mjs +0 -2
  33. package/dist/NotificationServicesController/mocks/index.mjs.map +1 -1
  34. package/dist/NotificationServicesController/mocks/mockResponses.cjs +9 -9
  35. package/dist/NotificationServicesController/mocks/mockResponses.cjs.map +1 -1
  36. package/dist/NotificationServicesController/mocks/mockResponses.d.cts +7 -4
  37. package/dist/NotificationServicesController/mocks/mockResponses.d.cts.map +1 -1
  38. package/dist/NotificationServicesController/mocks/mockResponses.d.mts +7 -4
  39. package/dist/NotificationServicesController/mocks/mockResponses.d.mts.map +1 -1
  40. package/dist/NotificationServicesController/mocks/mockResponses.mjs +7 -7
  41. package/dist/NotificationServicesController/mocks/mockResponses.mjs.map +1 -1
  42. package/dist/NotificationServicesController/processors/process-notifications.cjs +4 -1
  43. package/dist/NotificationServicesController/processors/process-notifications.cjs.map +1 -1
  44. package/dist/NotificationServicesController/processors/process-notifications.d.cts +623 -0
  45. package/dist/NotificationServicesController/processors/process-notifications.d.cts.map +1 -1
  46. package/dist/NotificationServicesController/processors/process-notifications.d.mts +623 -0
  47. package/dist/NotificationServicesController/processors/process-notifications.d.mts.map +1 -1
  48. package/dist/NotificationServicesController/processors/process-notifications.mjs +2 -0
  49. package/dist/NotificationServicesController/processors/process-notifications.mjs.map +1 -1
  50. package/dist/NotificationServicesController/services/notification-config-cache.cjs +72 -0
  51. package/dist/NotificationServicesController/services/notification-config-cache.cjs.map +1 -0
  52. package/dist/NotificationServicesController/services/notification-config-cache.d.cts +19 -0
  53. package/dist/NotificationServicesController/services/notification-config-cache.d.cts.map +1 -0
  54. package/dist/NotificationServicesController/services/notification-config-cache.d.mts +19 -0
  55. package/dist/NotificationServicesController/services/notification-config-cache.d.mts.map +1 -0
  56. package/dist/NotificationServicesController/services/notification-config-cache.mjs +68 -0
  57. package/dist/NotificationServicesController/services/notification-config-cache.mjs.map +1 -0
  58. package/dist/NotificationServicesController/services/onchain-notifications.cjs +67 -140
  59. package/dist/NotificationServicesController/services/onchain-notifications.cjs.map +1 -1
  60. package/dist/NotificationServicesController/services/onchain-notifications.d.cts +25 -31
  61. package/dist/NotificationServicesController/services/onchain-notifications.d.cts.map +1 -1
  62. package/dist/NotificationServicesController/services/onchain-notifications.d.mts +25 -31
  63. package/dist/NotificationServicesController/services/onchain-notifications.d.mts.map +1 -1
  64. package/dist/NotificationServicesController/services/onchain-notifications.mjs +65 -137
  65. package/dist/NotificationServicesController/services/onchain-notifications.mjs.map +1 -1
  66. package/dist/NotificationServicesController/types/index.cjs.map +1 -1
  67. package/dist/NotificationServicesController/types/index.d.cts +0 -1
  68. package/dist/NotificationServicesController/types/index.d.cts.map +1 -1
  69. package/dist/NotificationServicesController/types/index.d.mts +0 -1
  70. package/dist/NotificationServicesController/types/index.d.mts.map +1 -1
  71. package/dist/NotificationServicesController/types/index.mjs.map +1 -1
  72. package/dist/NotificationServicesController/ui/constants.cjs +6 -0
  73. package/dist/NotificationServicesController/ui/constants.cjs.map +1 -1
  74. package/dist/NotificationServicesController/ui/constants.d.cts +6 -0
  75. package/dist/NotificationServicesController/ui/constants.d.cts.map +1 -1
  76. package/dist/NotificationServicesController/ui/constants.d.mts +6 -0
  77. package/dist/NotificationServicesController/ui/constants.d.mts.map +1 -1
  78. package/dist/NotificationServicesController/ui/constants.mjs +6 -0
  79. package/dist/NotificationServicesController/ui/constants.mjs.map +1 -1
  80. package/dist/NotificationServicesController/utils/utils.cjs +1 -350
  81. package/dist/NotificationServicesController/utils/utils.cjs.map +1 -1
  82. package/dist/NotificationServicesController/utils/utils.d.cts +0 -141
  83. package/dist/NotificationServicesController/utils/utils.d.cts.map +1 -1
  84. package/dist/NotificationServicesController/utils/utils.d.mts +0 -141
  85. package/dist/NotificationServicesController/utils/utils.d.mts.map +1 -1
  86. package/dist/NotificationServicesController/utils/utils.mjs +0 -337
  87. package/dist/NotificationServicesController/utils/utils.mjs.map +1 -1
  88. package/dist/NotificationServicesPushController/NotificationServicesPushController.cjs +22 -15
  89. package/dist/NotificationServicesPushController/NotificationServicesPushController.cjs.map +1 -1
  90. package/dist/NotificationServicesPushController/NotificationServicesPushController.d.cts +6 -5
  91. package/dist/NotificationServicesPushController/NotificationServicesPushController.d.cts.map +1 -1
  92. package/dist/NotificationServicesPushController/NotificationServicesPushController.d.mts +6 -5
  93. package/dist/NotificationServicesPushController/NotificationServicesPushController.d.mts.map +1 -1
  94. package/dist/NotificationServicesPushController/NotificationServicesPushController.mjs +23 -16
  95. package/dist/NotificationServicesPushController/NotificationServicesPushController.mjs.map +1 -1
  96. package/dist/NotificationServicesPushController/mocks/mockResponse.cjs +1 -16
  97. package/dist/NotificationServicesPushController/mocks/mockResponse.cjs.map +1 -1
  98. package/dist/NotificationServicesPushController/mocks/mockResponse.d.cts +0 -7
  99. package/dist/NotificationServicesPushController/mocks/mockResponse.d.cts.map +1 -1
  100. package/dist/NotificationServicesPushController/mocks/mockResponse.d.mts +0 -7
  101. package/dist/NotificationServicesPushController/mocks/mockResponse.d.mts.map +1 -1
  102. package/dist/NotificationServicesPushController/mocks/mockResponse.mjs +0 -14
  103. package/dist/NotificationServicesPushController/mocks/mockResponse.mjs.map +1 -1
  104. package/dist/NotificationServicesPushController/services/endpoints.cjs +1 -1
  105. package/dist/NotificationServicesPushController/services/endpoints.cjs.map +1 -1
  106. package/dist/NotificationServicesPushController/services/endpoints.d.cts +1 -1
  107. package/dist/NotificationServicesPushController/services/endpoints.d.cts.map +1 -1
  108. package/dist/NotificationServicesPushController/services/endpoints.d.mts +1 -1
  109. package/dist/NotificationServicesPushController/services/endpoints.d.mts.map +1 -1
  110. package/dist/NotificationServicesPushController/services/endpoints.mjs +1 -1
  111. package/dist/NotificationServicesPushController/services/endpoints.mjs.map +1 -1
  112. package/dist/NotificationServicesPushController/services/services.cjs +18 -41
  113. package/dist/NotificationServicesPushController/services/services.cjs.map +1 -1
  114. package/dist/NotificationServicesPushController/services/services.d.cts +19 -33
  115. package/dist/NotificationServicesPushController/services/services.d.cts.map +1 -1
  116. package/dist/NotificationServicesPushController/services/services.d.mts +19 -33
  117. package/dist/NotificationServicesPushController/services/services.d.mts.map +1 -1
  118. package/dist/NotificationServicesPushController/services/services.mjs +17 -39
  119. package/dist/NotificationServicesPushController/services/services.mjs.map +1 -1
  120. package/package.json +1 -1
  121. package/dist/NotificationServicesController/constants/constants.cjs +0 -7
  122. package/dist/NotificationServicesController/constants/constants.cjs.map +0 -1
  123. package/dist/NotificationServicesController/constants/constants.d.cts +0 -3
  124. package/dist/NotificationServicesController/constants/constants.d.cts.map +0 -1
  125. package/dist/NotificationServicesController/constants/constants.d.mts +0 -3
  126. package/dist/NotificationServicesController/constants/constants.d.mts.map +0 -1
  127. package/dist/NotificationServicesController/constants/constants.mjs +0 -4
  128. package/dist/NotificationServicesController/constants/constants.mjs.map +0 -1
  129. package/dist/NotificationServicesController/mocks/mock-notification-trigger.cjs +0 -22
  130. package/dist/NotificationServicesController/mocks/mock-notification-trigger.cjs.map +0 -1
  131. package/dist/NotificationServicesController/mocks/mock-notification-trigger.d.cts +0 -9
  132. package/dist/NotificationServicesController/mocks/mock-notification-trigger.d.cts.map +0 -1
  133. package/dist/NotificationServicesController/mocks/mock-notification-trigger.d.mts +0 -9
  134. package/dist/NotificationServicesController/mocks/mock-notification-trigger.d.mts.map +0 -1
  135. package/dist/NotificationServicesController/mocks/mock-notification-trigger.mjs +0 -18
  136. package/dist/NotificationServicesController/mocks/mock-notification-trigger.mjs.map +0 -1
  137. package/dist/NotificationServicesController/mocks/mock-notification-user-storage.cjs +0 -82
  138. package/dist/NotificationServicesController/mocks/mock-notification-user-storage.cjs.map +0 -1
  139. package/dist/NotificationServicesController/mocks/mock-notification-user-storage.d.cts +0 -35
  140. package/dist/NotificationServicesController/mocks/mock-notification-user-storage.d.cts.map +0 -1
  141. package/dist/NotificationServicesController/mocks/mock-notification-user-storage.d.mts +0 -35
  142. package/dist/NotificationServicesController/mocks/mock-notification-user-storage.d.mts.map +0 -1
  143. package/dist/NotificationServicesController/mocks/mock-notification-user-storage.mjs +0 -76
  144. package/dist/NotificationServicesController/mocks/mock-notification-user-storage.mjs.map +0 -1
  145. package/dist/NotificationServicesController/types/user-storage/index.cjs +0 -3
  146. package/dist/NotificationServicesController/types/user-storage/index.cjs.map +0 -1
  147. package/dist/NotificationServicesController/types/user-storage/index.d.cts +0 -2
  148. package/dist/NotificationServicesController/types/user-storage/index.d.cts.map +0 -1
  149. package/dist/NotificationServicesController/types/user-storage/index.d.mts +0 -2
  150. package/dist/NotificationServicesController/types/user-storage/index.d.mts.map +0 -1
  151. package/dist/NotificationServicesController/types/user-storage/index.mjs +0 -2
  152. package/dist/NotificationServicesController/types/user-storage/index.mjs.map +0 -1
  153. package/dist/NotificationServicesController/types/user-storage/user-storage.cjs +0 -3
  154. package/dist/NotificationServicesController/types/user-storage/user-storage.cjs.map +0 -1
  155. package/dist/NotificationServicesController/types/user-storage/user-storage.d.cts +0 -26
  156. package/dist/NotificationServicesController/types/user-storage/user-storage.d.cts.map +0 -1
  157. package/dist/NotificationServicesController/types/user-storage/user-storage.d.mts +0 -26
  158. package/dist/NotificationServicesController/types/user-storage/user-storage.d.mts.map +0 -1
  159. package/dist/NotificationServicesController/types/user-storage/user-storage.mjs +0 -2
  160. package/dist/NotificationServicesController/types/user-storage/user-storage.mjs.map +0 -1
@@ -1,355 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.makeApiCall = exports.toggleUserStorageTriggerStatus = exports.upsertTriggerTypeTriggers = exports.upsertAddressTriggers = exports.getUUIDsForAccountByKinds = exports.getUUIDsForKinds = exports.getAllUUIDs = exports.getUUIDsForAccount = exports.inferEnabledKinds = exports.checkAccountsPresence = exports.traverseUserStorageTriggers = exports.cleanUserStorage = exports.initializeUserStorage = void 0;
4
- const controller_utils_1 = require("@metamask/controller-utils");
5
- const uuid_1 = require("uuid");
6
- const constants_1 = require("../constants/constants.cjs");
7
- const notification_schema_1 = require("../constants/notification-schema.cjs");
8
- /**
9
- * Extracts and returns the ID from a notification trigger.
10
- * This utility function is primarily used as a mapping function in `traverseUserStorageTriggers`
11
- * to convert a full trigger object into its ID string.
12
- *
13
- * @param trigger - The notification trigger from which the ID is extracted.
14
- * @returns The ID of the provided notification trigger.
15
- */
16
- const triggerToId = (trigger) => trigger.id;
17
- /**
18
- * A utility function that returns the input trigger without any transformation.
19
- * This function is used as the default mapping function in `traverseUserStorageTriggers`
20
- * when no custom mapping function is provided.
21
- *
22
- * @param trigger - The notification trigger to be returned as is.
23
- * @returns The same notification trigger that was passed in.
24
- */
25
- const triggerIdentity = (trigger) => trigger;
26
- /**
27
- * Create a completely new user storage object with the given accounts and state.
28
- * This method initializes the user storage with a version key and iterates over each account to populate it with triggers.
29
- * Each trigger is associated with supported chains, and for each chain, a unique identifier (UUID) is generated.
30
- * The trigger object contains a kind (`k`) indicating the type of trigger and an enabled state (`e`).
31
- * The kind and enabled state are stored with abbreviated keys to reduce the JSON size.
32
- *
33
- * This is used primarily for creating a new user storage (e.g. when first signing in/enabling notification profile syncing),
34
- * caution is needed in case you need to remove triggers that you don't want (due to notification setting filters)
35
- *
36
- * @param accounts - An array of account objects, each optionally containing an address.
37
- * @param state - A boolean indicating the initial enabled state for all triggers in the user storage.
38
- * @param shouldClean - prop to clean the initialized UserStorage (removing any invalid addresses). Only false for testing purposes.
39
- * @returns A `UserStorage` object populated with triggers for each account and chain.
40
- */
41
- function initializeUserStorage(accounts, state, shouldClean = true) {
42
- const userStorage = {
43
- [constants_1.USER_STORAGE_VERSION_KEY]: constants_1.USER_STORAGE_VERSION,
44
- };
45
- accounts.forEach((account) => {
46
- const address = account.address?.toLowerCase();
47
- if (!address) {
48
- return;
49
- }
50
- if (!userStorage[address]) {
51
- userStorage[address] = {};
52
- }
53
- Object.entries(notification_schema_1.TRIGGERS).forEach(([trigger, { supported_chains: supportedChains }]) => {
54
- supportedChains.forEach((chain) => {
55
- if (!userStorage[address]?.[chain]) {
56
- userStorage[address][chain] = {};
57
- }
58
- userStorage[address][chain][(0, uuid_1.v4)()] = {
59
- k: trigger,
60
- e: state, // use 'e' instead of 'enabled' to reduce the json weight
61
- };
62
- });
63
- });
64
- });
65
- if (shouldClean) {
66
- cleanUserStorage(userStorage);
67
- }
68
- return userStorage;
69
- }
70
- exports.initializeUserStorage = initializeUserStorage;
71
- /**
72
- * This is a fallback to ensure that we are not adding non-hex addresses, and the shape is valid.
73
- * Any invalid shapes will be removed.
74
- * NOTE - this method mutates and returns the cleaned User Storage.
75
- *
76
- * @param userStorage - notification user storage field we are to clean.
77
- * @returns a cleaned version of user storage.
78
- */
79
- function cleanUserStorage(userStorage) {
80
- const addresses = new Set();
81
- traverseUserStorageTriggers(userStorage, {
82
- mapTrigger: (t) => addresses.add(t.address),
83
- });
84
- addresses.forEach((addr) => {
85
- if (!(0, controller_utils_1.isValidHexAddress)(addr)) {
86
- delete userStorage[addr];
87
- }
88
- });
89
- return userStorage;
90
- }
91
- exports.cleanUserStorage = cleanUserStorage;
92
- /**
93
- * Iterates over user storage to find and optionally transform notification triggers.
94
- * This method allows for flexible retrieval and transformation of triggers based on provided options.
95
- *
96
- * @param userStorage - The user storage object containing notification triggers.
97
- * @param options - Optional parameters to filter and map triggers:
98
- * - `address`: If provided, only triggers for this address are considered.
99
- * - `mapTrigger`: A function to transform each trigger. If not provided, triggers are returned as is.
100
- * @returns An array of triggers, potentially transformed by the `mapTrigger` function.
101
- */
102
- function traverseUserStorageTriggers(userStorage, options) {
103
- const triggers = [];
104
- const mapTrigger = options?.mapTrigger ?? triggerIdentity;
105
- for (const address in userStorage) {
106
- if (address === constants_1.USER_STORAGE_VERSION_KEY) {
107
- continue;
108
- }
109
- if (options?.address && address !== options.address) {
110
- continue;
111
- }
112
- for (const chainId in userStorage[address]) {
113
- if (chainId in userStorage[address]) {
114
- for (const uuid in userStorage[address][chainId]) {
115
- if (uuid) {
116
- const mappedTrigger = mapTrigger({
117
- id: uuid,
118
- kind: userStorage[address]?.[chainId]?.[uuid]?.k,
119
- chainId,
120
- address,
121
- enabled: userStorage[address]?.[chainId]?.[uuid]?.e ?? false,
122
- });
123
- if (mappedTrigger) {
124
- triggers.push(mappedTrigger);
125
- }
126
- }
127
- }
128
- }
129
- }
130
- }
131
- return triggers;
132
- }
133
- exports.traverseUserStorageTriggers = traverseUserStorageTriggers;
134
- /**
135
- * Verifies the presence of specified accounts and their chains in the user storage.
136
- * This method checks if each provided account exists in the user storage and if all its supported chains are present.
137
- *
138
- * @param userStorage - The user storage object containing notification triggers.
139
- * @param accounts - An array of account addresses to check for presence.
140
- * @returns A record where each key is an account address and each value is a boolean indicating whether the account and all its supported chains are present in the user storage.
141
- */
142
- function checkAccountsPresence(userStorage, accounts) {
143
- const presenceRecord = {};
144
- // Initialize presence record for all accounts as false
145
- accounts.forEach((account) => {
146
- presenceRecord[account.toLowerCase()] = isAccountEnabled(account, userStorage);
147
- });
148
- return presenceRecord;
149
- }
150
- exports.checkAccountsPresence = checkAccountsPresence;
151
- /**
152
- * Internal method to check if a given account should be marked as enabled by introspecting user storage
153
- * Introspection: check if account exists; and also see if has all triggers in schema enabled
154
- *
155
- * @param accountAddress - address to check in user storage
156
- * @param userStorage - user storage object to traverse/introspect
157
- * @returns boolean if the account is enabled or disabled
158
- */
159
- function isAccountEnabled(accountAddress, userStorage) {
160
- const accountObject = userStorage[accountAddress?.toLowerCase()];
161
- // If the account address is not present in the userStorage, return true
162
- if (!accountObject) {
163
- return false;
164
- }
165
- // Check if all available chains are present
166
- for (const [triggerKind, triggerConfig] of Object.entries(notification_schema_1.TRIGGERS)) {
167
- for (const chain of triggerConfig.supported_chains) {
168
- if (!accountObject[chain]) {
169
- return false;
170
- }
171
- const triggerExists = Object.values(accountObject[chain]).some((obj) => obj.k === triggerKind);
172
- if (!triggerExists) {
173
- return false;
174
- }
175
- // Check if any trigger is disabled
176
- for (const uuid in accountObject[chain]) {
177
- if (!accountObject[chain][uuid].e) {
178
- return false;
179
- }
180
- }
181
- }
182
- }
183
- return true;
184
- }
185
- /**
186
- * Infers and returns an array of enabled notification trigger kinds from the user storage.
187
- * This method counts the occurrences of each kind of trigger and returns the kinds that are present.
188
- *
189
- * @param userStorage - The user storage object containing notification triggers.
190
- * @returns An array of trigger kinds (`TRIGGER_TYPES`) that are enabled in the user storage.
191
- */
192
- function inferEnabledKinds(userStorage) {
193
- const allSupportedKinds = new Set();
194
- traverseUserStorageTriggers(userStorage, {
195
- mapTrigger: (t) => {
196
- allSupportedKinds.add(t.kind);
197
- },
198
- });
199
- return Array.from(allSupportedKinds);
200
- }
201
- exports.inferEnabledKinds = inferEnabledKinds;
202
- /**
203
- * Retrieves all UUIDs associated with a specific account address from the user storage.
204
- * This function utilizes `traverseUserStorageTriggers` with a mapping function to extract
205
- * just the UUIDs of the notification triggers for the given address.
206
- *
207
- * @param userStorage - The user storage object containing notification triggers.
208
- * @param address - The specific account address to retrieve UUIDs for.
209
- * @returns An array of UUID strings associated with the given account address.
210
- */
211
- function getUUIDsForAccount(userStorage, address) {
212
- return traverseUserStorageTriggers(userStorage, {
213
- address,
214
- mapTrigger: triggerToId,
215
- });
216
- }
217
- exports.getUUIDsForAccount = getUUIDsForAccount;
218
- /**
219
- * Retrieves all UUIDs from the user storage, regardless of the account address or chain ID.
220
- * This method leverages `traverseUserStorageTriggers` with a specific mapping function (`triggerToId`)
221
- * to extract only the UUIDs from all notification triggers present in the user storage.
222
- *
223
- * @param userStorage - The user storage object containing notification triggers.
224
- * @returns An array of UUID strings from all notification triggers in the user storage.
225
- */
226
- function getAllUUIDs(userStorage) {
227
- return traverseUserStorageTriggers(userStorage, {
228
- mapTrigger: triggerToId,
229
- });
230
- }
231
- exports.getAllUUIDs = getAllUUIDs;
232
- /**
233
- * Retrieves UUIDs for notification triggers that match any of the specified kinds.
234
- * This method filters triggers based on their kind and returns an array of UUIDs for those that match the allowed kinds.
235
- * It utilizes `traverseUserStorageTriggers` with a custom mapping function that checks if a trigger's kind is in the allowed list.
236
- *
237
- * @param userStorage - The user storage object containing notification triggers.
238
- * @param allowedKinds - An array of kinds (as strings) to filter the triggers by.
239
- * @returns An array of UUID strings for triggers that match the allowed kinds.
240
- */
241
- function getUUIDsForKinds(userStorage, allowedKinds) {
242
- const kindsSet = new Set(allowedKinds);
243
- return traverseUserStorageTriggers(userStorage, {
244
- mapTrigger: (t) => (kindsSet.has(t.kind) ? t.id : undefined),
245
- });
246
- }
247
- exports.getUUIDsForKinds = getUUIDsForKinds;
248
- /**
249
- * Retrieves notification triggers for a specific account address that match any of the specified kinds.
250
- * This method filters triggers both by the account address and their kind, returning triggers that match the allowed kinds for the specified address.
251
- * It leverages `traverseUserStorageTriggers` with a custom mapping function to filter and return only the relevant triggers.
252
- *
253
- * @param userStorage - The user storage object containing notification triggers.
254
- * @param address - The specific account address for which to retrieve triggers.
255
- * @param allowedKinds - An array of trigger kinds (`TRIGGER_TYPES`) to filter the triggers by.
256
- * @returns An array of `NotificationTrigger` objects that match the allowed kinds for the specified account address.
257
- */
258
- function getUUIDsForAccountByKinds(userStorage, address, allowedKinds) {
259
- const allowedKindsSet = new Set(allowedKinds);
260
- return traverseUserStorageTriggers(userStorage, {
261
- address,
262
- mapTrigger: (trigger) => {
263
- if (allowedKindsSet.has(trigger.kind)) {
264
- return trigger;
265
- }
266
- return undefined;
267
- },
268
- });
269
- }
270
- exports.getUUIDsForAccountByKinds = getUUIDsForAccountByKinds;
271
- /**
272
- * Upserts (updates or inserts) notification triggers for a given account across all supported chains.
273
- * This method ensures that each supported trigger type exists for each chain associated with the account.
274
- * If a trigger type does not exist for a chain, it creates a new trigger with a unique UUID.
275
- *
276
- * @param _account - The account address for which to upsert triggers. The address is normalized to lowercase.
277
- * @param userStorage - The user storage object to be updated with new or existing triggers.
278
- * @returns The updated user storage object with upserted triggers for the specified account.
279
- */
280
- function upsertAddressTriggers(_account, userStorage) {
281
- // Ensure the account exists in userStorage
282
- const account = _account.toLowerCase();
283
- userStorage[account] = userStorage[account] || {};
284
- // Iterate over each trigger and its supported chains
285
- for (const [trigger, { supported_chains: supportedChains }] of Object.entries(notification_schema_1.TRIGGERS)) {
286
- for (const chain of supportedChains) {
287
- // Ensure the chain exists for the account
288
- userStorage[account][chain] = userStorage[account][chain] || {};
289
- // Check if the trigger exists for the chain
290
- const existingTrigger = Object.values(userStorage[account][chain]).find((obj) => obj.k === trigger);
291
- if (!existingTrigger) {
292
- // If the trigger doesn't exist, create a new one with a new UUID
293
- const uuid = (0, uuid_1.v4)();
294
- userStorage[account][chain][uuid] = {
295
- k: trigger,
296
- e: false,
297
- };
298
- }
299
- }
300
- }
301
- return userStorage;
302
- }
303
- exports.upsertAddressTriggers = upsertAddressTriggers;
304
- /**
305
- * Upserts (updates or inserts) notification triggers of a specific type across all accounts and chains in user storage.
306
- * This method ensures that a trigger of the specified type exists for each account and chain. If a trigger of the specified type
307
- * does not exist for an account and chain, it creates a new trigger with a unique UUID.
308
- *
309
- * @param triggerType - The type of trigger to upsert across all accounts and chains.
310
- * @param userStorage - The user storage object to be updated with new or existing triggers of the specified type.
311
- * @returns The updated user storage object with upserted triggers of the specified type for all accounts and chains.
312
- */
313
- function upsertTriggerTypeTriggers(triggerType, userStorage) {
314
- // Iterate over each account in userStorage
315
- Object.entries(userStorage).forEach(([account, chains]) => {
316
- if (account === constants_1.USER_STORAGE_VERSION_KEY) {
317
- return;
318
- }
319
- // Iterate over each chain for the account
320
- Object.entries(chains).forEach(([chain, triggers]) => {
321
- // Check if the trigger type exists for the chain
322
- const existingTrigger = Object.values(triggers).find((obj) => obj.k === triggerType);
323
- if (!existingTrigger) {
324
- // If the trigger type doesn't exist, create a new one with a new UUID
325
- const uuid = (0, uuid_1.v4)();
326
- userStorage[account][chain][uuid] = {
327
- k: triggerType,
328
- e: false,
329
- };
330
- }
331
- });
332
- });
333
- return userStorage;
334
- }
335
- exports.upsertTriggerTypeTriggers = upsertTriggerTypeTriggers;
336
- /**
337
- * Toggles the enabled status of a user storage trigger.
338
- *
339
- * @param userStorage - The user storage object.
340
- * @param address - The user's address.
341
- * @param chainId - The chain ID.
342
- * @param uuid - The unique identifier for the trigger.
343
- * @param enabled - The new enabled status.
344
- * @returns The updated user storage object.
345
- */
346
- function toggleUserStorageTriggerStatus(userStorage, address, chainId, uuid, enabled) {
347
- if (userStorage?.[address]?.[chainId]?.[uuid]) {
348
- userStorage[address][chainId][uuid].e = enabled;
349
- }
350
- return userStorage;
351
- }
352
- exports.toggleUserStorageTriggerStatus = toggleUserStorageTriggerStatus;
3
+ exports.makeApiCall = void 0;
353
4
  /**
354
5
  * Performs an API call with automatic retries on failure.
355
6
  *
@@ -1 +1 @@
1
- {"version":3,"file":"utils.cjs","sourceRoot":"","sources":["../../../src/NotificationServicesController/utils/utils.ts"],"names":[],"mappings":";;;AAAA,iEAA+D;AAC/D,+BAAoC;AAEpC,0DAGgC;AAEhC,8EAA4D;AAoB5D;;;;;;;GAOG;AACH,MAAM,WAAW,GAAG,CAAC,OAA4B,EAAU,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;AAEzE;;;;;;;GAOG;AACH,MAAM,eAAe,GAAG,CAAC,OAA4B,EAAuB,EAAE,CAC5E,OAAO,CAAC;AAEV;;;;;;;;;;;;;;GAcG;AACH,SAAgB,qBAAqB,CACnC,QAAgC,EAChC,KAAc,EACd,WAAW,GAAG,IAAI;IAElB,MAAM,WAAW,GAAgB;QAC/B,CAAC,oCAAwB,CAAC,EAAE,gCAAoB;KACjD,CAAC;IAEF,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC3B,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,EAAE,WAAW,EAAE,CAAC;QAC/C,IAAI,CAAC,OAAO,EAAE;YACZ,OAAO;SACR;QACD,IA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AChB,MAAyB,EACzB,IAAU;IAEV,MAAM,OAAO,GAAgB;QAC3B,MAAM;QACN,OAAO,EAAE;YACP,cAAc,EAAE,kBAAkB;YAClC,aAAa,EAAE,UAAU,WAAW,EAAE;SACvC;QACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;KAC3B,CAAC;IAEF,OAAO,MAAM,KAAK,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;AACxC,CAAC;AAhBD,kCAgBC","sourcesContent":["import { isValidHexAddress } from '@metamask/controller-utils';\nimport { v4 as uuidv4 } from 'uuid';\n\nimport {\n USER_STORAGE_VERSION_KEY,\n USER_STORAGE_VERSION,\n} from '../constants/constants';\nimport type { TRIGGER_TYPES } from '../constants/notification-schema';\nimport { TRIGGERS } from '../constants/notification-schema';\nimport type { UserStorage } from '../types/user-storage/user-storage';\n\nexport type NotificationTrigger = {\n id: string;\n chainId: string;\n kind: string;\n address: string;\n enabled: boolean;\n};\n\ntype MapTriggerFn<Result> = (\n trigger: NotificationTrigger,\n) => Result | undefined;\n\ntype TraverseTriggerOpts<Result> = {\n address?: string;\n mapTrigger?: MapTriggerFn<Result>;\n};\n\n/**\n * Extracts and returns the ID from a notification trigger.\n * This utility function is primarily used as a mapping function in `traverseUserStorageTriggers`\n * to convert a full trigger object into its ID string.\n *\n * @param trigger - The notification trigger from which the ID is extracted.\n * @returns The ID of the provided notification trigger.\n */\nconst triggerToId = (trigger: NotificationTrigger): string => trigger.id;\n\n/**\n * A utility function that returns the input trigger without any transformation.\n * This function is used as the default mapping function in `traverseUserStorageTriggers`\n * when no custom mapping function is provided.\n *\n * @param trigger - The notification trigger to be returned as is.\n * @returns The same notification trigger that was passed in.\n */\nconst triggerIdentity = (trigger: NotificationTrigger): NotificationTrigger =>\n trigger;\n\n/**\n * Create a completely new user storage object with the given accounts and state.\n * This method initializes the user storage with a version key and iterates over each account to populate it with triggers.\n * Each trigger is associated with supported chains, and for each chain, a unique identifier (UUID) is generated.\n * The trigger object contains a kind (`k`) indicating the type of trigger and an enabled state (`e`).\n * The kind and enabled state are stored with abbreviated keys to reduce the JSON size.\n *\n * This is used primarily for creating a new user storage (e.g. when first signing in/enabling notification profile syncing),\n * caution is needed in case you need to remove triggers that you don't want (due to notification setting filters)\n *\n * @param accounts - An array of account objects, each optionally containing an address.\n * @param state - A boolean indicating the initial enabled state for all triggers in the user storage.\n * @param shouldClean - prop to clean the initialized UserStorage (removing any invalid addresses). Only false for testing purposes.\n * @returns A `UserStorage` object populated with triggers for each account and chain.\n */\nexport function initializeUserStorage(\n accounts: { address?: string }[],\n state: boolean,\n shouldClean = true,\n): UserStorage {\n const userStorage: UserStorage = {\n [USER_STORAGE_VERSION_KEY]: USER_STORAGE_VERSION,\n };\n\n accounts.forEach((account) => {\n const address = account.address?.toLowerCase();\n if (!address) {\n return;\n }\n if (!userStorage[address]) {\n userStorage[address] = {};\n }\n\n Object.entries(TRIGGERS).forEach(\n ([trigger, { supported_chains: supportedChains }]) => {\n supportedChains.forEach((chain) => {\n if (!userStorage[address]?.[chain]) {\n userStorage[address][chain] = {};\n }\n\n userStorage[address][chain][uuidv4()] = {\n k: trigger as TRIGGER_TYPES, // use 'k' instead of 'kind' to reduce the json weight\n e: state, // use 'e' instead of 'enabled' to reduce the json weight\n };\n });\n },\n );\n });\n\n if (shouldClean) {\n cleanUserStorage(userStorage);\n }\n return userStorage;\n}\n\n/**\n * This is a fallback to ensure that we are not adding non-hex addresses, and the shape is valid.\n * Any invalid shapes will be removed.\n * NOTE - this method mutates and returns the cleaned User Storage.\n *\n * @param userStorage - notification user storage field we are to clean.\n * @returns a cleaned version of user storage.\n */\nexport function cleanUserStorage(userStorage: UserStorage) {\n const addresses = new Set<string>();\n traverseUserStorageTriggers(userStorage, {\n mapTrigger: (t) => addresses.add(t.address),\n });\n\n addresses.forEach((addr) => {\n if (!isValidHexAddress(addr)) {\n delete userStorage[addr];\n }\n });\n\n return userStorage;\n}\n\n/**\n * Iterates over user storage to find and optionally transform notification triggers.\n * This method allows for flexible retrieval and transformation of triggers based on provided options.\n *\n * @param userStorage - The user storage object containing notification triggers.\n * @param options - Optional parameters to filter and map triggers:\n * - `address`: If provided, only triggers for this address are considered.\n * - `mapTrigger`: A function to transform each trigger. If not provided, triggers are returned as is.\n * @returns An array of triggers, potentially transformed by the `mapTrigger` function.\n */\nexport function traverseUserStorageTriggers<\n ResultTriggers = NotificationTrigger,\n>(\n userStorage: UserStorage,\n options?: TraverseTriggerOpts<ResultTriggers>,\n): ResultTriggers[] {\n const triggers: ResultTriggers[] = [];\n const mapTrigger =\n options?.mapTrigger ?? (triggerIdentity as MapTriggerFn<ResultTriggers>);\n\n for (const address in userStorage) {\n if (address === (USER_STORAGE_VERSION_KEY as unknown as string)) {\n continue;\n }\n if (options?.address && address !== options.address) {\n continue;\n }\n\n for (const chainId in userStorage[address]) {\n if (chainId in userStorage[address]) {\n for (const uuid in userStorage[address][chainId]) {\n if (uuid) {\n const mappedTrigger = mapTrigger({\n id: uuid,\n kind: userStorage[address]?.[chainId]?.[uuid]?.k,\n chainId,\n address,\n enabled: userStorage[address]?.[chainId]?.[uuid]?.e ?? false,\n });\n if (mappedTrigger) {\n triggers.push(mappedTrigger);\n }\n }\n }\n }\n }\n }\n\n return triggers;\n}\n\n/**\n * Verifies the presence of specified accounts and their chains in the user storage.\n * This method checks if each provided account exists in the user storage and if all its supported chains are present.\n *\n * @param userStorage - The user storage object containing notification triggers.\n * @param accounts - An array of account addresses to check for presence.\n * @returns A record where each key is an account address and each value is a boolean indicating whether the account and all its supported chains are present in the user storage.\n */\nexport function checkAccountsPresence(\n userStorage: UserStorage,\n accounts: string[],\n): Record<string, boolean> {\n const presenceRecord: Record<string, boolean> = {};\n\n // Initialize presence record for all accounts as false\n accounts.forEach((account) => {\n presenceRecord[account.toLowerCase()] = isAccountEnabled(\n account,\n userStorage,\n );\n });\n\n return presenceRecord;\n}\n\n/**\n * Internal method to check if a given account should be marked as enabled by introspecting user storage\n * Introspection: check if account exists; and also see if has all triggers in schema enabled\n *\n * @param accountAddress - address to check in user storage\n * @param userStorage - user storage object to traverse/introspect\n * @returns boolean if the account is enabled or disabled\n */\nfunction isAccountEnabled(\n accountAddress: string,\n userStorage: UserStorage,\n): boolean {\n const accountObject = userStorage[accountAddress?.toLowerCase()];\n\n // If the account address is not present in the userStorage, return true\n if (!accountObject) {\n return false;\n }\n\n // Check if all available chains are present\n for (const [triggerKind, triggerConfig] of Object.entries(TRIGGERS)) {\n for (const chain of triggerConfig.supported_chains) {\n if (!accountObject[chain]) {\n return false;\n }\n\n const triggerExists = Object.values(accountObject[chain]).some(\n (obj) => obj.k === (triggerKind as TRIGGER_TYPES),\n );\n if (!triggerExists) {\n return false;\n }\n\n // Check if any trigger is disabled\n for (const uuid in accountObject[chain]) {\n if (!accountObject[chain][uuid].e) {\n return false;\n }\n }\n }\n }\n\n return true;\n}\n\n/**\n * Infers and returns an array of enabled notification trigger kinds from the user storage.\n * This method counts the occurrences of each kind of trigger and returns the kinds that are present.\n *\n * @param userStorage - The user storage object containing notification triggers.\n * @returns An array of trigger kinds (`TRIGGER_TYPES`) that are enabled in the user storage.\n */\nexport function inferEnabledKinds(userStorage: UserStorage): TRIGGER_TYPES[] {\n const allSupportedKinds = new Set<TRIGGER_TYPES>();\n\n traverseUserStorageTriggers(userStorage, {\n mapTrigger: (t) => {\n allSupportedKinds.add(t.kind as TRIGGER_TYPES);\n },\n });\n\n return Array.from(allSupportedKinds);\n}\n\n/**\n * Retrieves all UUIDs associated with a specific account address from the user storage.\n * This function utilizes `traverseUserStorageTriggers` with a mapping function to extract\n * just the UUIDs of the notification triggers for the given address.\n *\n * @param userStorage - The user storage object containing notification triggers.\n * @param address - The specific account address to retrieve UUIDs for.\n * @returns An array of UUID strings associated with the given account address.\n */\nexport function getUUIDsForAccount(\n userStorage: UserStorage,\n address: string,\n): string[] {\n return traverseUserStorageTriggers(userStorage, {\n address,\n mapTrigger: triggerToId,\n });\n}\n\n/**\n * Retrieves all UUIDs from the user storage, regardless of the account address or chain ID.\n * This method leverages `traverseUserStorageTriggers` with a specific mapping function (`triggerToId`)\n * to extract only the UUIDs from all notification triggers present in the user storage.\n *\n * @param userStorage - The user storage object containing notification triggers.\n * @returns An array of UUID strings from all notification triggers in the user storage.\n */\nexport function getAllUUIDs(userStorage: UserStorage): string[] {\n return traverseUserStorageTriggers(userStorage, {\n mapTrigger: triggerToId,\n });\n}\n\n/**\n * Retrieves UUIDs for notification triggers that match any of the specified kinds.\n * This method filters triggers based on their kind and returns an array of UUIDs for those that match the allowed kinds.\n * It utilizes `traverseUserStorageTriggers` with a custom mapping function that checks if a trigger's kind is in the allowed list.\n *\n * @param userStorage - The user storage object containing notification triggers.\n * @param allowedKinds - An array of kinds (as strings) to filter the triggers by.\n * @returns An array of UUID strings for triggers that match the allowed kinds.\n */\nexport function getUUIDsForKinds(\n userStorage: UserStorage,\n allowedKinds: string[],\n): string[] {\n const kindsSet = new Set(allowedKinds);\n\n return traverseUserStorageTriggers(userStorage, {\n mapTrigger: (t) => (kindsSet.has(t.kind) ? t.id : undefined),\n });\n}\n\n/**\n * Retrieves notification triggers for a specific account address that match any of the specified kinds.\n * This method filters triggers both by the account address and their kind, returning triggers that match the allowed kinds for the specified address.\n * It leverages `traverseUserStorageTriggers` with a custom mapping function to filter and return only the relevant triggers.\n *\n * @param userStorage - The user storage object containing notification triggers.\n * @param address - The specific account address for which to retrieve triggers.\n * @param allowedKinds - An array of trigger kinds (`TRIGGER_TYPES`) to filter the triggers by.\n * @returns An array of `NotificationTrigger` objects that match the allowed kinds for the specified account address.\n */\nexport function getUUIDsForAccountByKinds(\n userStorage: UserStorage,\n address: string,\n allowedKinds: TRIGGER_TYPES[],\n): NotificationTrigger[] {\n const allowedKindsSet = new Set(allowedKinds);\n return traverseUserStorageTriggers(userStorage, {\n address,\n mapTrigger: (trigger) => {\n if (allowedKindsSet.has(trigger.kind as TRIGGER_TYPES)) {\n return trigger;\n }\n return undefined;\n },\n });\n}\n\n/**\n * Upserts (updates or inserts) notification triggers for a given account across all supported chains.\n * This method ensures that each supported trigger type exists for each chain associated with the account.\n * If a trigger type does not exist for a chain, it creates a new trigger with a unique UUID.\n *\n * @param _account - The account address for which to upsert triggers. The address is normalized to lowercase.\n * @param userStorage - The user storage object to be updated with new or existing triggers.\n * @returns The updated user storage object with upserted triggers for the specified account.\n */\nexport function upsertAddressTriggers(\n _account: string,\n userStorage: UserStorage,\n): UserStorage {\n // Ensure the account exists in userStorage\n const account = _account.toLowerCase();\n userStorage[account] = userStorage[account] || {};\n\n // Iterate over each trigger and its supported chains\n for (const [trigger, { supported_chains: supportedChains }] of Object.entries(\n TRIGGERS,\n )) {\n for (const chain of supportedChains) {\n // Ensure the chain exists for the account\n userStorage[account][chain] = userStorage[account][chain] || {};\n\n // Check if the trigger exists for the chain\n const existingTrigger = Object.values(userStorage[account][chain]).find(\n (obj) => obj.k === (trigger as TRIGGER_TYPES),\n );\n\n if (!existingTrigger) {\n // If the trigger doesn't exist, create a new one with a new UUID\n const uuid = uuidv4();\n userStorage[account][chain][uuid] = {\n k: trigger as TRIGGER_TYPES,\n e: false,\n };\n }\n }\n }\n\n return userStorage;\n}\n\n/**\n * Upserts (updates or inserts) notification triggers of a specific type across all accounts and chains in user storage.\n * This method ensures that a trigger of the specified type exists for each account and chain. If a trigger of the specified type\n * does not exist for an account and chain, it creates a new trigger with a unique UUID.\n *\n * @param triggerType - The type of trigger to upsert across all accounts and chains.\n * @param userStorage - The user storage object to be updated with new or existing triggers of the specified type.\n * @returns The updated user storage object with upserted triggers of the specified type for all accounts and chains.\n */\nexport function upsertTriggerTypeTriggers(\n triggerType: TRIGGER_TYPES,\n userStorage: UserStorage,\n): UserStorage {\n // Iterate over each account in userStorage\n Object.entries(userStorage).forEach(([account, chains]) => {\n if (account === (USER_STORAGE_VERSION_KEY as unknown as string)) {\n return;\n }\n\n // Iterate over each chain for the account\n Object.entries(chains).forEach(([chain, triggers]) => {\n // Check if the trigger type exists for the chain\n const existingTrigger = Object.values(triggers).find(\n (obj) => obj.k === triggerType,\n );\n\n if (!existingTrigger) {\n // If the trigger type doesn't exist, create a new one with a new UUID\n const uuid = uuidv4();\n userStorage[account][chain][uuid] = {\n k: triggerType,\n e: false,\n };\n }\n });\n });\n\n return userStorage;\n}\n\n/**\n * Toggles the enabled status of a user storage trigger.\n *\n * @param userStorage - The user storage object.\n * @param address - The user's address.\n * @param chainId - The chain ID.\n * @param uuid - The unique identifier for the trigger.\n * @param enabled - The new enabled status.\n * @returns The updated user storage object.\n */\nexport function toggleUserStorageTriggerStatus(\n userStorage: UserStorage,\n address: string,\n chainId: string,\n uuid: string,\n enabled: boolean,\n): UserStorage {\n if (userStorage?.[address]?.[chainId]?.[uuid]) {\n userStorage[address][chainId][uuid].e = enabled;\n }\n\n return userStorage;\n}\n\n/**\n * Performs an API call with automatic retries on failure.\n *\n * @param bearerToken - The JSON Web Token for authorization.\n * @param endpoint - The URL of the API endpoint to call.\n * @param method - The HTTP method ('POST' or 'DELETE').\n * @param body - The body of the request. It should be an object that can be serialized to JSON.\n * @returns A Promise that resolves to the response of the fetch request.\n */\nexport async function makeApiCall<Body>(\n bearerToken: string,\n endpoint: string,\n method: 'POST' | 'DELETE',\n body: Body,\n): Promise<Response> {\n const options: RequestInit = {\n method,\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${bearerToken}`,\n },\n body: JSON.stringify(body),\n };\n\n return await fetch(endpoint, options);\n}\n"]}
1
+ {"version":3,"file":"utils.cjs","sourceRoot":"","sources":["../../../src/NotificationServicesController/utils/utils.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;GAQG;AACI,KAAK,UAAU,WAAW,CAC/B,WAAmB,EACnB,QAAgB,EAChB,MAAyB,EACzB,IAAU;IAEV,MAAM,OAAO,GAAgB;QAC3B,MAAM;QACN,OAAO,EAAE;YACP,cAAc,EAAE,kBAAkB;YAClC,aAAa,EAAE,UAAU,WAAW,EAAE;SACvC;QACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;KAC3B,CAAC;IAEF,OAAO,MAAM,KAAK,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;AACxC,CAAC;AAhBD,kCAgBC","sourcesContent":["/**\n * Performs an API call with automatic retries on failure.\n *\n * @param bearerToken - The JSON Web Token for authorization.\n * @param endpoint - The URL of the API endpoint to call.\n * @param method - The HTTP method ('POST' or 'DELETE').\n * @param body - The body of the request. It should be an object that can be serialized to JSON.\n * @returns A Promise that resolves to the response of the fetch request.\n */\nexport async function makeApiCall<Body>(\n bearerToken: string,\n endpoint: string,\n method: 'POST' | 'DELETE',\n body: Body,\n): Promise<Response> {\n const options: RequestInit = {\n method,\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${bearerToken}`,\n },\n body: JSON.stringify(body),\n };\n\n return await fetch(endpoint, options);\n}\n"]}
@@ -1,143 +1,3 @@
1
- import type { TRIGGER_TYPES } from "../constants/notification-schema.cjs";
2
- import type { UserStorage } from "../types/user-storage/user-storage.cjs";
3
- export type NotificationTrigger = {
4
- id: string;
5
- chainId: string;
6
- kind: string;
7
- address: string;
8
- enabled: boolean;
9
- };
10
- type MapTriggerFn<Result> = (trigger: NotificationTrigger) => Result | undefined;
11
- type TraverseTriggerOpts<Result> = {
12
- address?: string;
13
- mapTrigger?: MapTriggerFn<Result>;
14
- };
15
- /**
16
- * Create a completely new user storage object with the given accounts and state.
17
- * This method initializes the user storage with a version key and iterates over each account to populate it with triggers.
18
- * Each trigger is associated with supported chains, and for each chain, a unique identifier (UUID) is generated.
19
- * The trigger object contains a kind (`k`) indicating the type of trigger and an enabled state (`e`).
20
- * The kind and enabled state are stored with abbreviated keys to reduce the JSON size.
21
- *
22
- * This is used primarily for creating a new user storage (e.g. when first signing in/enabling notification profile syncing),
23
- * caution is needed in case you need to remove triggers that you don't want (due to notification setting filters)
24
- *
25
- * @param accounts - An array of account objects, each optionally containing an address.
26
- * @param state - A boolean indicating the initial enabled state for all triggers in the user storage.
27
- * @param shouldClean - prop to clean the initialized UserStorage (removing any invalid addresses). Only false for testing purposes.
28
- * @returns A `UserStorage` object populated with triggers for each account and chain.
29
- */
30
- export declare function initializeUserStorage(accounts: {
31
- address?: string;
32
- }[], state: boolean, shouldClean?: boolean): UserStorage;
33
- /**
34
- * This is a fallback to ensure that we are not adding non-hex addresses, and the shape is valid.
35
- * Any invalid shapes will be removed.
36
- * NOTE - this method mutates and returns the cleaned User Storage.
37
- *
38
- * @param userStorage - notification user storage field we are to clean.
39
- * @returns a cleaned version of user storage.
40
- */
41
- export declare function cleanUserStorage(userStorage: UserStorage): UserStorage;
42
- /**
43
- * Iterates over user storage to find and optionally transform notification triggers.
44
- * This method allows for flexible retrieval and transformation of triggers based on provided options.
45
- *
46
- * @param userStorage - The user storage object containing notification triggers.
47
- * @param options - Optional parameters to filter and map triggers:
48
- * - `address`: If provided, only triggers for this address are considered.
49
- * - `mapTrigger`: A function to transform each trigger. If not provided, triggers are returned as is.
50
- * @returns An array of triggers, potentially transformed by the `mapTrigger` function.
51
- */
52
- export declare function traverseUserStorageTriggers<ResultTriggers = NotificationTrigger>(userStorage: UserStorage, options?: TraverseTriggerOpts<ResultTriggers>): ResultTriggers[];
53
- /**
54
- * Verifies the presence of specified accounts and their chains in the user storage.
55
- * This method checks if each provided account exists in the user storage and if all its supported chains are present.
56
- *
57
- * @param userStorage - The user storage object containing notification triggers.
58
- * @param accounts - An array of account addresses to check for presence.
59
- * @returns A record where each key is an account address and each value is a boolean indicating whether the account and all its supported chains are present in the user storage.
60
- */
61
- export declare function checkAccountsPresence(userStorage: UserStorage, accounts: string[]): Record<string, boolean>;
62
- /**
63
- * Infers and returns an array of enabled notification trigger kinds from the user storage.
64
- * This method counts the occurrences of each kind of trigger and returns the kinds that are present.
65
- *
66
- * @param userStorage - The user storage object containing notification triggers.
67
- * @returns An array of trigger kinds (`TRIGGER_TYPES`) that are enabled in the user storage.
68
- */
69
- export declare function inferEnabledKinds(userStorage: UserStorage): TRIGGER_TYPES[];
70
- /**
71
- * Retrieves all UUIDs associated with a specific account address from the user storage.
72
- * This function utilizes `traverseUserStorageTriggers` with a mapping function to extract
73
- * just the UUIDs of the notification triggers for the given address.
74
- *
75
- * @param userStorage - The user storage object containing notification triggers.
76
- * @param address - The specific account address to retrieve UUIDs for.
77
- * @returns An array of UUID strings associated with the given account address.
78
- */
79
- export declare function getUUIDsForAccount(userStorage: UserStorage, address: string): string[];
80
- /**
81
- * Retrieves all UUIDs from the user storage, regardless of the account address or chain ID.
82
- * This method leverages `traverseUserStorageTriggers` with a specific mapping function (`triggerToId`)
83
- * to extract only the UUIDs from all notification triggers present in the user storage.
84
- *
85
- * @param userStorage - The user storage object containing notification triggers.
86
- * @returns An array of UUID strings from all notification triggers in the user storage.
87
- */
88
- export declare function getAllUUIDs(userStorage: UserStorage): string[];
89
- /**
90
- * Retrieves UUIDs for notification triggers that match any of the specified kinds.
91
- * This method filters triggers based on their kind and returns an array of UUIDs for those that match the allowed kinds.
92
- * It utilizes `traverseUserStorageTriggers` with a custom mapping function that checks if a trigger's kind is in the allowed list.
93
- *
94
- * @param userStorage - The user storage object containing notification triggers.
95
- * @param allowedKinds - An array of kinds (as strings) to filter the triggers by.
96
- * @returns An array of UUID strings for triggers that match the allowed kinds.
97
- */
98
- export declare function getUUIDsForKinds(userStorage: UserStorage, allowedKinds: string[]): string[];
99
- /**
100
- * Retrieves notification triggers for a specific account address that match any of the specified kinds.
101
- * This method filters triggers both by the account address and their kind, returning triggers that match the allowed kinds for the specified address.
102
- * It leverages `traverseUserStorageTriggers` with a custom mapping function to filter and return only the relevant triggers.
103
- *
104
- * @param userStorage - The user storage object containing notification triggers.
105
- * @param address - The specific account address for which to retrieve triggers.
106
- * @param allowedKinds - An array of trigger kinds (`TRIGGER_TYPES`) to filter the triggers by.
107
- * @returns An array of `NotificationTrigger` objects that match the allowed kinds for the specified account address.
108
- */
109
- export declare function getUUIDsForAccountByKinds(userStorage: UserStorage, address: string, allowedKinds: TRIGGER_TYPES[]): NotificationTrigger[];
110
- /**
111
- * Upserts (updates or inserts) notification triggers for a given account across all supported chains.
112
- * This method ensures that each supported trigger type exists for each chain associated with the account.
113
- * If a trigger type does not exist for a chain, it creates a new trigger with a unique UUID.
114
- *
115
- * @param _account - The account address for which to upsert triggers. The address is normalized to lowercase.
116
- * @param userStorage - The user storage object to be updated with new or existing triggers.
117
- * @returns The updated user storage object with upserted triggers for the specified account.
118
- */
119
- export declare function upsertAddressTriggers(_account: string, userStorage: UserStorage): UserStorage;
120
- /**
121
- * Upserts (updates or inserts) notification triggers of a specific type across all accounts and chains in user storage.
122
- * This method ensures that a trigger of the specified type exists for each account and chain. If a trigger of the specified type
123
- * does not exist for an account and chain, it creates a new trigger with a unique UUID.
124
- *
125
- * @param triggerType - The type of trigger to upsert across all accounts and chains.
126
- * @param userStorage - The user storage object to be updated with new or existing triggers of the specified type.
127
- * @returns The updated user storage object with upserted triggers of the specified type for all accounts and chains.
128
- */
129
- export declare function upsertTriggerTypeTriggers(triggerType: TRIGGER_TYPES, userStorage: UserStorage): UserStorage;
130
- /**
131
- * Toggles the enabled status of a user storage trigger.
132
- *
133
- * @param userStorage - The user storage object.
134
- * @param address - The user's address.
135
- * @param chainId - The chain ID.
136
- * @param uuid - The unique identifier for the trigger.
137
- * @param enabled - The new enabled status.
138
- * @returns The updated user storage object.
139
- */
140
- export declare function toggleUserStorageTriggerStatus(userStorage: UserStorage, address: string, chainId: string, uuid: string, enabled: boolean): UserStorage;
141
1
  /**
142
2
  * Performs an API call with automatic retries on failure.
143
3
  *
@@ -148,5 +8,4 @@ export declare function toggleUserStorageTriggerStatus(userStorage: UserStorage,
148
8
  * @returns A Promise that resolves to the response of the fetch request.
149
9
  */
150
10
  export declare function makeApiCall<Body>(bearerToken: string, endpoint: string, method: 'POST' | 'DELETE', body: Body): Promise<Response>;
151
- export {};
152
11
  //# sourceMappingURL=utils.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.cts","sourceRoot":"","sources":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G;AACH,wBAAgB,kBAAkB,CAChC,WAAW,EAAE,WAAW,EACxB,OAAO,EAAE,MAAM,GACd,MAAM,EAAE,CAKV;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM,EAAE,CAI9D;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAC9B,WAAW,EAAE,WAAW,EACxB,YAAY,EAAE,MAAM,EAAE,GACrB,MAAM,EAAE,CAMV;AAED;;;;;;;;;GASG;AACH,wBAAgB,yBAAyB,CACvC,WAAW,EAAE,WAAW,EACxB,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,aAAa,EAAE,GAC5B,mBAAmB,EAAE,CAWvB;AAED;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,WAAW,GACvB,WAAW,CA8Bb;AAED;;;;;;;;GAQG;AACH,wBAAgB,yBAAyB,CACvC,WAAW,EAAE,aAAa,EAC1B,WAAW,EAAE,WAAW,GACvB,WAAW,CA0Bb;AAED;;;;;;;;;GASG;AACH,wBAAgB,8BAA8B,CAC5C,WAAW,EAAE,WAAW,EACxB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,OAAO,GACf,WAAW,CAMb;AAED;;;;;;;;GAQG;AACH,wBAAsB,WAAW,CAAC,IAAI,EACpC,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,GAAG,QAAQ,EACzB,IAAI,EAAE,IAAI,GACT,OAAO,CAAC,QAAQ,CAAC,CAWnB"}
1
+ {"version":3,"file":"utils.d.cts","sourceRoot":"","sources":["../../../src/NotificationServicesController/utils/utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,wBAAsB,WAAW,CAAC,IAAI,EACpC,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,GAAG,QAAQ,EACzB,IAAI,EAAE,IAAI,GACT,OAAO,CAAC,QAAQ,CAAC,CAWnB"}