@metamask/notification-services-controller 0.1.2 → 0.2.1

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 (94) hide show
  1. package/CHANGELOG.md +30 -1
  2. package/dist/NotificationServicesController/NotificationServicesController.js +4 -3
  3. package/dist/NotificationServicesController/NotificationServicesController.mjs +3 -2
  4. package/dist/NotificationServicesController/index.js +17 -16
  5. package/dist/NotificationServicesController/index.mjs +16 -15
  6. package/dist/NotificationServicesController/services/onchain-notifications.js +3 -2
  7. package/dist/NotificationServicesController/services/onchain-notifications.mjs +2 -1
  8. package/dist/NotificationServicesController/types/index.js +2 -2
  9. package/dist/NotificationServicesController/types/index.mjs +2 -2
  10. package/dist/NotificationServicesController/ui/constants.js +4 -2
  11. package/dist/NotificationServicesController/ui/constants.mjs +5 -3
  12. package/dist/NotificationServicesController/ui/index.js +5 -3
  13. package/dist/NotificationServicesController/ui/index.mjs +6 -4
  14. package/dist/NotificationServicesPushController/NotificationServicesPushController.js +14 -13
  15. package/dist/NotificationServicesPushController/NotificationServicesPushController.mjs +13 -12
  16. package/dist/NotificationServicesPushController/index.js +18 -17
  17. package/dist/NotificationServicesPushController/index.mjs +17 -16
  18. package/dist/NotificationServicesPushController/services/push/push-web.js +12 -11
  19. package/dist/NotificationServicesPushController/services/push/push-web.mjs +11 -10
  20. package/dist/NotificationServicesPushController/services/services.js +13 -12
  21. package/dist/NotificationServicesPushController/services/services.mjs +12 -11
  22. package/dist/NotificationServicesPushController/utils/get-notification-message.js +10 -9
  23. package/dist/NotificationServicesPushController/utils/get-notification-message.mjs +10 -9
  24. package/dist/NotificationServicesPushController/utils/index.js +10 -9
  25. package/dist/NotificationServicesPushController/utils/index.mjs +10 -9
  26. package/dist/{chunk-MT4VCZEE.js → chunk-2BCJRWFF.js} +6 -6
  27. package/dist/{chunk-4VVOTF2Y.mjs → chunk-4E76LF6X.mjs} +50 -5
  28. package/dist/chunk-4E76LF6X.mjs.map +1 -0
  29. package/dist/{chunk-GJHW5Z65.js → chunk-4HOEZMSV.js} +4 -4
  30. package/dist/{chunk-5IPZMRR5.mjs → chunk-5JDAO4ZC.mjs} +6 -4
  31. package/dist/{chunk-5IPZMRR5.mjs.map → chunk-5JDAO4ZC.mjs.map} +1 -1
  32. package/dist/{chunk-5TUHE2FM.js → chunk-6GXEFQ64.js} +11 -11
  33. package/dist/chunk-6GXEFQ64.js.map +1 -0
  34. package/dist/chunk-DINCLRZT.mjs +12 -0
  35. package/dist/chunk-DINCLRZT.mjs.map +1 -0
  36. package/dist/chunk-DT6SLUWJ.js +12 -0
  37. package/dist/chunk-DT6SLUWJ.js.map +1 -0
  38. package/dist/{chunk-2Z3NDVOV.js → chunk-FFKCMR6Q.js} +55 -10
  39. package/dist/chunk-FFKCMR6Q.js.map +1 -0
  40. package/dist/{chunk-EZHMYHBX.mjs → chunk-FN6GVBCU.mjs} +9 -11
  41. package/dist/chunk-FN6GVBCU.mjs.map +1 -0
  42. package/dist/{chunk-72H2V4J5.js → chunk-GDKHOBJT.js} +7 -3
  43. package/dist/chunk-GDKHOBJT.js.map +1 -0
  44. package/dist/{chunk-DNVD3CHQ.js → chunk-H73GATCU.js} +9 -11
  45. package/dist/chunk-H73GATCU.js.map +1 -0
  46. package/dist/{chunk-AQPBSNWA.js → chunk-IG3KWCQU.js} +6 -4
  47. package/dist/chunk-IG3KWCQU.js.map +1 -0
  48. package/dist/{chunk-R373BQEU.mjs → chunk-N4EKQQX7.mjs} +5 -5
  49. package/dist/{chunk-D7VP2FPR.js → chunk-P5DZ7JHL.js} +16 -16
  50. package/dist/{chunk-S2FM5DOS.js → chunk-QOG3RCXM.js} +40 -2
  51. package/dist/chunk-QOG3RCXM.js.map +1 -0
  52. package/dist/{chunk-ADYRLXWY.mjs → chunk-WGGW6VCR.mjs} +2 -2
  53. package/dist/{chunk-XVIUHFC3.mjs → chunk-X3ZU3HL7.mjs} +4 -4
  54. package/dist/{chunk-XVIUHFC3.mjs.map → chunk-X3ZU3HL7.mjs.map} +1 -1
  55. package/dist/{chunk-A5QFYBTR.mjs → chunk-YHVXD5WW.mjs} +7 -3
  56. package/dist/chunk-YHVXD5WW.mjs.map +1 -0
  57. package/dist/chunk-YZYQYIKS.mjs +67 -0
  58. package/dist/chunk-YZYQYIKS.mjs.map +1 -0
  59. package/dist/{chunk-YYWFWJTJ.mjs → chunk-Z5VM5N2S.mjs} +10 -10
  60. package/dist/index.js +16 -15
  61. package/dist/index.mjs +15 -14
  62. package/dist/shared/to-raw-notification.js +8 -0
  63. package/dist/shared/to-raw-notification.js.map +1 -0
  64. package/dist/shared/to-raw-notification.mjs +8 -0
  65. package/dist/shared/to-raw-notification.mjs.map +1 -0
  66. package/dist/tsconfig.build.tsbuildinfo +1 -1
  67. package/dist/types/NotificationServicesController/NotificationServicesController.d.ts +14 -5
  68. package/dist/types/NotificationServicesController/NotificationServicesController.d.ts.map +1 -1
  69. package/dist/types/NotificationServicesController/services/onchain-notifications.d.ts.map +1 -1
  70. package/dist/types/NotificationServicesController/types/on-chain-notification/on-chain-notification.d.ts +1 -0
  71. package/dist/types/NotificationServicesController/types/on-chain-notification/on-chain-notification.d.ts.map +1 -1
  72. package/dist/types/NotificationServicesController/ui/constants.d.ts +34 -0
  73. package/dist/types/NotificationServicesController/ui/constants.d.ts.map +1 -1
  74. package/dist/types/NotificationServicesPushController/services/push/push-web.d.ts.map +1 -1
  75. package/dist/types/shared/to-raw-notification.d.ts +11 -0
  76. package/dist/types/shared/to-raw-notification.d.ts.map +1 -0
  77. package/package.json +11 -11
  78. package/dist/chunk-2Z3NDVOV.js.map +0 -1
  79. package/dist/chunk-4VVOTF2Y.mjs.map +0 -1
  80. package/dist/chunk-5TUHE2FM.js.map +0 -1
  81. package/dist/chunk-72H2V4J5.js.map +0 -1
  82. package/dist/chunk-7SDGAI6Z.mjs +0 -29
  83. package/dist/chunk-7SDGAI6Z.mjs.map +0 -1
  84. package/dist/chunk-A5QFYBTR.mjs.map +0 -1
  85. package/dist/chunk-AQPBSNWA.js.map +0 -1
  86. package/dist/chunk-DNVD3CHQ.js.map +0 -1
  87. package/dist/chunk-EZHMYHBX.mjs.map +0 -1
  88. package/dist/chunk-S2FM5DOS.js.map +0 -1
  89. /package/dist/{chunk-MT4VCZEE.js.map → chunk-2BCJRWFF.js.map} +0 -0
  90. /package/dist/{chunk-GJHW5Z65.js.map → chunk-4HOEZMSV.js.map} +0 -0
  91. /package/dist/{chunk-R373BQEU.mjs.map → chunk-N4EKQQX7.mjs.map} +0 -0
  92. /package/dist/{chunk-D7VP2FPR.js.map → chunk-P5DZ7JHL.js.map} +0 -0
  93. /package/dist/{chunk-ADYRLXWY.mjs.map → chunk-WGGW6VCR.mjs.map} +0 -0
  94. /package/dist/{chunk-YYWFWJTJ.mjs.map → chunk-Z5VM5N2S.mjs.map} +0 -0
@@ -4,6 +4,9 @@
4
4
 
5
5
  var _chunkNOYP2T77js = require('./chunk-NOYP2T77.js');
6
6
 
7
+
8
+ var _chunkDT6SLUWJjs = require('./chunk-DT6SLUWJ.js');
9
+
7
10
  // src/NotificationServicesController/services/onchain-notifications.ts
8
11
  var _profilesynccontroller = require('@metamask/profile-sync-controller');
9
12
  var _loglevel = require('loglevel'); var _loglevel2 = _interopRequireDefault(_loglevel);
@@ -122,17 +125,12 @@ async function getOnChainNotifications(userStorage, bearerToken) {
122
125
  { trigger_ids: triggerIds }
123
126
  );
124
127
  const notifications = await response.json();
125
- const transformedNotifications = notifications.map(
126
- (n) => {
127
- if (!n.data?.kind) {
128
- return void 0;
129
- }
130
- return {
131
- ...n,
132
- type: n.data.kind
133
- };
128
+ const transformedNotifications = notifications.map((n) => {
129
+ if (!n.data?.kind) {
130
+ return void 0;
134
131
  }
135
- ).filter((n) => Boolean(n));
132
+ return _chunkDT6SLUWJjs.toRawOnChainNotification.call(void 0, n);
133
+ }).filter((n) => Boolean(n));
136
134
  onChainNotifications.push(...transformedNotifications);
137
135
  if (notifications.length < 100) {
138
136
  page = PAGE_LIMIT + 1;
@@ -184,4 +182,4 @@ async function markNotificationsAsRead(bearerToken, notificationIds) {
184
182
 
185
183
 
186
184
  exports.TRIGGER_API = TRIGGER_API; exports.NOTIFICATION_API = NOTIFICATION_API; exports.TRIGGER_API_BATCH_ENDPOINT = TRIGGER_API_BATCH_ENDPOINT; exports.NOTIFICATION_API_LIST_ENDPOINT = NOTIFICATION_API_LIST_ENDPOINT; exports.NOTIFICATION_API_LIST_ENDPOINT_PAGE_QUERY = NOTIFICATION_API_LIST_ENDPOINT_PAGE_QUERY; exports.NOTIFICATION_API_MARK_ALL_AS_READ_ENDPOINT = NOTIFICATION_API_MARK_ALL_AS_READ_ENDPOINT; exports.createOnChainTriggers = createOnChainTriggers; exports.deleteOnChainTriggers = deleteOnChainTriggers; exports.getOnChainNotifications = getOnChainNotifications; exports.markNotificationsAsRead = markNotificationsAsRead;
187
- //# sourceMappingURL=chunk-DNVD3CHQ.js.map
185
+ //# sourceMappingURL=chunk-H73GATCU.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/NotificationServicesController/services/onchain-notifications.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,SAAS,6BAA6B;AACtC,OAAO,SAAS;AAqBT,IAAM,cAAc;AACpB,IAAM,mBAAmB;AACzB,IAAM,6BAA6B,GAAG,WAAW;AACjD,IAAM,iCAAiC,GAAG,gBAAgB;AAC1D,IAAM,4CAA4C,CAAC,SACxD,GAAG,8BAA8B,SAAS,IAAI;AACzC,IAAM,6CAA6C,GAAG,gBAAgB;AAc7E,eAAsB,sBACpB,aACA,YACA,aACA,UACe;AAYf,QAAM,mBAA4C,SAAS,IAAI,CAAC,OAAO;AAAA,IACrE,IAAI,EAAE;AAAA,IACN,OAAO,sBAAsB,iBAAiB,EAAE,KAAK,UAAU;AAAA,IAC/D,QAAQ;AAAA,MACN,MAAM,EAAE;AAAA;AAAA,MAER,UAAU,OAAO,EAAE,OAAO;AAAA,MAC1B,SAAS,EAAE;AAAA,IACb;AAAA,EAC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AAS,KAAK;AACZ,UAAI;AAAA,QACF,yDAAyD,WAAW;AAAA,UAClE;AAAA,QACF,CAAC;AAAA,QACD;AAAA,MACF;AAAA,IAEF;AAAA,EACF;AAEA,SAAO;AACT;AAWA,eAAsB,wBACpB,aACA,iBACe;AACf,MAAI,gBAAgB,WAAW,GAAG;AAChC;AAAA,EACF;AAEA,MAAI;AACF,UAAM,WAAW,MAAM;AAAA,MACrB;AAAA,MACA;AAAA,MACA;AAAA,MACA,EAAE,KAAK,gBAAgB;AAAA,IACzB;AAEA,QAAI,SAAS,WAAW,KAAK;AAC3B,YAAM,YAAY,MAAM,SAAS,KAAK,EAAE,MAAM,MAAM,MAAS;AAC7D,YAAM,IAAI;AAAA,QACR,wCAAwC,WAAW,OAAiB;AAAA,MACtE;AAAA,IACF;AAAA,EACF,SAAS,KAAK;AACZ,QAAI,MAAM,wCAAwC,GAAG;AACrD,UAAM;AAAA,EACR;AACF","sourcesContent":["import { UserStorageController } from '@metamask/profile-sync-controller';\nimport log from 'loglevel';\n\nimport { toRawOnChainNotification } from '../../shared/to-raw-notification';\nimport type {\n OnChainRawNotification,\n UnprocessedOnChainRawNotification,\n} from '../types/on-chain-notification/on-chain-notification';\nimport type { UserStorage } from '../types/user-storage/user-storage';\nimport {\n makeApiCall,\n toggleUserStorageTriggerStatus,\n traverseUserStorageTriggers,\n} from '../utils/utils';\n\nexport type NotificationTrigger = {\n id: string;\n chainId: string;\n kind: string;\n address: string;\n};\n\nexport const TRIGGER_API = 'https://trigger.api.cx.metamask.io';\nexport const NOTIFICATION_API = 'https://notification.api.cx.metamask.io';\nexport const TRIGGER_API_BATCH_ENDPOINT = `${TRIGGER_API}/api/v1/triggers/batch`;\nexport const NOTIFICATION_API_LIST_ENDPOINT = `${NOTIFICATION_API}/api/v1/notifications`;\nexport const NOTIFICATION_API_LIST_ENDPOINT_PAGE_QUERY = (page: number) =>\n `${NOTIFICATION_API_LIST_ENDPOINT}?page=${page}&per_page=100`;\nexport const NOTIFICATION_API_MARK_ALL_AS_READ_ENDPOINT = `${NOTIFICATION_API}/api/v1/notifications/mark-as-read`;\n\n/**\n * Creates on-chain triggers based on the provided notification triggers.\n * This method generates a unique token for each trigger using the trigger ID and storage key,\n * proving ownership of the trigger being updated. It then makes an API call to create these triggers.\n * Upon successful creation, it updates the userStorage to reflect the new trigger status.\n *\n * @param userStorage - The user's storage object where triggers and their statuses are stored.\n * @param storageKey - A key used along with the trigger ID to generate a unique token for each trigger.\n * @param bearerToken - The JSON Web Token used for authentication in the API call.\n * @param triggers - An array of notification triggers to be created. Each trigger includes an ID, chain ID, kind, and address.\n * @returns A promise that resolves to void. Throws an error if the API call fails or if there's an issue creating the triggers.\n */\nexport async function createOnChainTriggers(\n userStorage: UserStorage,\n storageKey: string,\n bearerToken: string,\n triggers: NotificationTrigger[],\n): Promise<void> {\n type RequestPayloadTrigger = {\n id: string;\n // this is the trigger token, generated by using the uuid + storage key. It proves you own the trigger you are updating\n token: string;\n config: {\n kind: string;\n // eslint-disable-next-line @typescript-eslint/naming-convention\n chain_id: number;\n address: string;\n };\n };\n const triggersToCreate: RequestPayloadTrigger[] = triggers.map((t) => ({\n id: t.id,\n token: UserStorageController.createSHA256Hash(t.id + storageKey),\n config: {\n kind: t.kind,\n // eslint-disable-next-line @typescript-eslint/naming-convention\n chain_id: Number(t.chainId),\n address: t.address,\n },\n }));\n\n if (triggersToCreate.length === 0) {\n return;\n }\n\n const response = await makeApiCall(\n bearerToken,\n TRIGGER_API_BATCH_ENDPOINT,\n 'POST',\n triggersToCreate,\n );\n\n if (!response.ok) {\n const errorData = await response.json().catch(() => undefined);\n log.error('Error creating triggers:', errorData);\n throw new Error('OnChain Notifications - unable to create triggers');\n }\n\n // If the trigger creation was fine\n // then update the userStorage\n for (const trigger of triggersToCreate) {\n toggleUserStorageTriggerStatus(\n userStorage,\n trigger.config.address,\n String(trigger.config.chain_id),\n trigger.id,\n true,\n );\n }\n}\n\n/**\n * Deletes on-chain triggers based on the provided UUIDs.\n * This method generates a unique token for each trigger using the UUID and storage key,\n * proving ownership of the trigger being deleted. It then makes an API call to delete these triggers.\n * Upon successful deletion, it updates the userStorage to remove the deleted trigger statuses.\n *\n * @param userStorage - The user's storage object where triggers and their statuses are stored.\n * @param storageKey - A key used along with the UUID to generate a unique token for each trigger.\n * @param bearerToken - The JSON Web Token used for authentication in the API call.\n * @param uuids - An array of UUIDs representing the triggers to be deleted.\n * @returns A promise that resolves to the updated UserStorage object. Throws an error if the API call fails or if there's an issue deleting the triggers.\n */\nexport async function deleteOnChainTriggers(\n userStorage: UserStorage,\n storageKey: string,\n bearerToken: string,\n uuids: string[],\n): Promise<UserStorage> {\n const triggersToDelete = uuids.map((uuid) => ({\n id: uuid,\n token: UserStorageController.createSHA256Hash(uuid + storageKey),\n }));\n\n try {\n const response = await makeApiCall(\n bearerToken,\n TRIGGER_API_BATCH_ENDPOINT,\n 'DELETE',\n triggersToDelete,\n );\n\n if (!response.ok) {\n throw new Error(\n `Failed to delete on-chain notifications for uuids ${uuids.join(', ')}`,\n );\n }\n\n // Update the state of the deleted trigger to false\n for (const uuid of uuids) {\n for (const address in userStorage) {\n if (address in userStorage) {\n for (const chainId in userStorage[address]) {\n if (userStorage?.[address]?.[chainId]?.[uuid]) {\n delete userStorage[address][chainId][uuid];\n }\n }\n }\n }\n }\n\n // Follow-up cleanup, if an address had no triggers whatsoever, then we can delete the address\n const isEmpty = (obj = {}) => Object.keys(obj).length === 0;\n for (const address in userStorage) {\n if (address in userStorage) {\n for (const chainId in userStorage[address]) {\n // Chain isEmpty Check\n if (isEmpty(userStorage?.[address]?.[chainId])) {\n delete userStorage[address][chainId];\n }\n }\n\n // Address isEmpty Check\n if (isEmpty(userStorage?.[address])) {\n delete userStorage[address];\n }\n }\n }\n } catch (err) {\n log.error(\n `Error deleting on-chain notifications for uuids ${uuids.join(', ')}:`,\n err,\n );\n throw err;\n }\n\n return userStorage;\n}\n\n/**\n * Fetches on-chain notifications for the given user storage and BearerToken.\n * This method iterates through the userStorage to find enabled triggers and fetches notifications for those triggers.\n * It makes paginated API calls to the notifications service, transforming and aggregating the notifications into a single array.\n * The process stops either when all pages have been fetched or when a page has less than 100 notifications, indicating the end of the data.\n *\n * @param userStorage - The user's storage object containing trigger information.\n * @param bearerToken - The JSON Web Token used for authentication in the API call.\n * @returns A promise that resolves to an array of OnChainRawNotification objects. If no triggers are enabled or an error occurs, it may return an empty array.\n */\nexport async function getOnChainNotifications(\n userStorage: UserStorage,\n bearerToken: string,\n): Promise<OnChainRawNotification[]> {\n const triggerIds = traverseUserStorageTriggers(userStorage, {\n mapTrigger: (t) => {\n if (!t.enabled) {\n return undefined;\n }\n return t.id;\n },\n });\n\n if (triggerIds.length === 0) {\n return [];\n }\n\n const onChainNotifications: OnChainRawNotification[] = [];\n const PAGE_LIMIT = 2;\n for (let page = 1; page <= PAGE_LIMIT; page++) {\n try {\n const response = await makeApiCall(\n bearerToken,\n NOTIFICATION_API_LIST_ENDPOINT_PAGE_QUERY(page),\n 'POST',\n // eslint-disable-next-line @typescript-eslint/naming-convention\n { trigger_ids: triggerIds },\n );\n\n const notifications =\n (await response.json()) as UnprocessedOnChainRawNotification[];\n\n // Transform and sort notifications\n const transformedNotifications = notifications\n .map((n): OnChainRawNotification | undefined => {\n if (!n.data?.kind) {\n return undefined;\n }\n\n return toRawOnChainNotification(n);\n })\n .filter((n): n is OnChainRawNotification => Boolean(n));\n\n onChainNotifications.push(...transformedNotifications);\n\n // if less than 100 notifications on page, then means we reached end\n if (notifications.length < 100) {\n page = PAGE_LIMIT + 1;\n break;\n }\n } catch (err) {\n log.error(\n `Error fetching on-chain notifications for trigger IDs ${triggerIds.join(\n ', ',\n )}:`,\n err,\n );\n // do nothing\n }\n }\n\n return onChainNotifications;\n}\n\n/**\n * Marks the specified notifications as read.\n * This method sends a POST request to the notifications service to mark the provided notification IDs as read.\n * If the operation is successful, it completes without error. If the operation fails, it throws an error with details.\n *\n * @param bearerToken - The JSON Web Token used for authentication in the API call.\n * @param notificationIds - An array of notification IDs to be marked as read.\n * @returns A promise that resolves to void. The promise will reject if there's an error during the API call or if the response status is not 200.\n */\nexport async function markNotificationsAsRead(\n bearerToken: string,\n notificationIds: string[],\n): Promise<void> {\n if (notificationIds.length === 0) {\n return;\n }\n\n try {\n const response = await makeApiCall(\n bearerToken,\n NOTIFICATION_API_MARK_ALL_AS_READ_ENDPOINT,\n 'POST',\n { ids: notificationIds },\n );\n\n if (response.status !== 200) {\n const errorData = await response.json().catch(() => undefined);\n throw new Error(\n `Error marking notifications as read: ${errorData?.message as string}`,\n );\n }\n } catch (err) {\n log.error('Error marking notifications as read:', err);\n throw err;\n }\n}\n"]}
@@ -1,7 +1,8 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
3
 
4
- var _chunkS2FM5DOSjs = require('./chunk-S2FM5DOS.js');
4
+
5
+ var _chunkQOG3RCXMjs = require('./chunk-QOG3RCXM.js');
5
6
 
6
7
 
7
8
  var _chunkV6P5JEPTjs = require('./chunk-V6P5JEPT.js');
@@ -13,11 +14,12 @@ var _chunkIGY2S5BCjs = require('./chunk-IGY2S5BC.js');
13
14
  var ui_exports = {};
14
15
  _chunkIGY2S5BCjs.__export.call(void 0, ui_exports, {
15
16
  NOTIFICATION_CHAINS_ID: () => _chunkV6P5JEPTjs.NOTIFICATION_CHAINS_ID,
16
- NOTIFICATION_NETWORK_CURRENCY_NAME: () => _chunkS2FM5DOSjs.NOTIFICATION_NETWORK_CURRENCY_NAME,
17
- NOTIFICATION_NETWORK_CURRENCY_SYMBOL: () => _chunkS2FM5DOSjs.NOTIFICATION_NETWORK_CURRENCY_SYMBOL
17
+ NOTIFICATION_NETWORK_CURRENCY_NAME: () => _chunkQOG3RCXMjs.NOTIFICATION_NETWORK_CURRENCY_NAME,
18
+ NOTIFICATION_NETWORK_CURRENCY_SYMBOL: () => _chunkQOG3RCXMjs.NOTIFICATION_NETWORK_CURRENCY_SYMBOL,
19
+ SUPPORTED_NOTIFICATION_BLOCK_EXPLORERS: () => _chunkQOG3RCXMjs.SUPPORTED_NOTIFICATION_BLOCK_EXPLORERS
18
20
  });
19
21
 
20
22
 
21
23
 
22
24
  exports.ui_exports = ui_exports;
23
- //# sourceMappingURL=chunk-AQPBSNWA.js.map
25
+ //# sourceMappingURL=chunk-IG3KWCQU.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/NotificationServicesController/ui/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA","sourcesContent":["export * from './constants';\n"]}
@@ -1,13 +1,13 @@
1
- import {
2
- utils_exports
3
- } from "./chunk-DCADU5QI.mjs";
4
1
  import {
5
2
  types_exports
6
3
  } from "./chunk-IOMDG67D.mjs";
4
+ import {
5
+ utils_exports
6
+ } from "./chunk-DCADU5QI.mjs";
7
7
  import {
8
8
  NotificationServicesPushController,
9
9
  defaultState
10
- } from "./chunk-XVIUHFC3.mjs";
10
+ } from "./chunk-X3ZU3HL7.mjs";
11
11
  import {
12
12
  REGISTRATION_TOKENS_ENDPOINT
13
13
  } from "./chunk-IKWNHNJQ.mjs";
@@ -91,4 +91,4 @@ export {
91
91
  fixtures_exports,
92
92
  NotificationServicesPushController_exports
93
93
  };
94
- //# sourceMappingURL=chunk-R373BQEU.mjs.map
94
+ //# sourceMappingURL=chunk-N4EKQQX7.mjs.map
@@ -1,16 +1,19 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkAQPBSNWAjs = require('./chunk-AQPBSNWA.js');
3
+ var _chunk232HZSEVjs = require('./chunk-232HZSEV.js');
4
4
 
5
5
 
6
- var _chunkKWTSMLNDjs = require('./chunk-KWTSMLND.js');
6
+ var _chunkIG3KWCQUjs = require('./chunk-IG3KWCQU.js');
7
7
 
8
8
 
9
- var _chunk232HZSEVjs = require('./chunk-232HZSEV.js');
9
+ var _chunkQY4UST5Vjs = require('./chunk-QY4UST5V.js');
10
+
11
+
12
+ var _chunkKWTSMLNDjs = require('./chunk-KWTSMLND.js');
10
13
 
11
14
 
12
15
 
13
- var _chunk2Z3NDVOVjs = require('./chunk-2Z3NDVOV.js');
16
+ var _chunkFFKCMR6Qjs = require('./chunk-FFKCMR6Q.js');
14
17
 
15
18
 
16
19
  var _chunkHZEB53A6js = require('./chunk-HZEB53A6.js');
@@ -18,15 +21,12 @@ var _chunkHZEB53A6js = require('./chunk-HZEB53A6.js');
18
21
 
19
22
 
20
23
 
21
- var _chunkDNVD3CHQjs = require('./chunk-DNVD3CHQ.js');
24
+ var _chunkH73GATCUjs = require('./chunk-H73GATCU.js');
22
25
 
23
26
 
24
27
  var _chunkNOYP2T77js = require('./chunk-NOYP2T77.js');
25
28
 
26
29
 
27
- var _chunkQY4UST5Vjs = require('./chunk-QY4UST5V.js');
28
-
29
-
30
30
  var _chunkTLX5QQK5js = require('./chunk-TLX5QQK5.js');
31
31
 
32
32
 
@@ -36,12 +36,12 @@ var _chunkIGY2S5BCjs = require('./chunk-IGY2S5BC.js');
36
36
  var NotificationServicesController_exports = {};
37
37
  _chunkIGY2S5BCjs.__export.call(void 0, NotificationServicesController_exports, {
38
38
  Constants: () => _chunkQY4UST5Vjs.constants_exports,
39
- Controller: () => _chunk2Z3NDVOVjs.NotificationServicesController,
39
+ Controller: () => _chunkFFKCMR6Qjs.NotificationServicesController,
40
40
  Mocks: () => fixtures_exports,
41
41
  Processors: () => _chunkKWTSMLNDjs.processors_exports,
42
42
  Types: () => _chunk232HZSEVjs.types_exports,
43
- UI: () => _chunkAQPBSNWAjs.ui_exports,
44
- defaultState: () => _chunk2Z3NDVOVjs.defaultState
43
+ UI: () => _chunkIG3KWCQUjs.ui_exports,
44
+ defaultState: () => _chunkFFKCMR6Qjs.defaultState
45
45
  });
46
46
 
47
47
  // src/NotificationServicesController/__fixtures__/index.ts
@@ -894,14 +894,14 @@ var getMockFeatureAnnouncementResponse = () => {
894
894
  };
895
895
  var getMockBatchCreateTriggersResponse = () => {
896
896
  return {
897
- url: _chunkDNVD3CHQjs.TRIGGER_API_BATCH_ENDPOINT,
897
+ url: _chunkH73GATCUjs.TRIGGER_API_BATCH_ENDPOINT,
898
898
  requestMethod: "POST",
899
899
  response: null
900
900
  };
901
901
  };
902
902
  var getMockBatchDeleteTriggersResponse = () => {
903
903
  return {
904
- url: _chunkDNVD3CHQjs.TRIGGER_API_BATCH_ENDPOINT,
904
+ url: _chunkH73GATCUjs.TRIGGER_API_BATCH_ENDPOINT,
905
905
  requestMethod: "DELETE",
906
906
  response: null
907
907
  };
@@ -909,14 +909,14 @@ var getMockBatchDeleteTriggersResponse = () => {
909
909
  var MOCK_RAW_ON_CHAIN_NOTIFICATIONS = createMockRawOnChainNotifications();
910
910
  var getMockListNotificationsResponse = () => {
911
911
  return {
912
- url: _chunkDNVD3CHQjs.NOTIFICATION_API_LIST_ENDPOINT,
912
+ url: _chunkH73GATCUjs.NOTIFICATION_API_LIST_ENDPOINT,
913
913
  requestMethod: "POST",
914
914
  response: MOCK_RAW_ON_CHAIN_NOTIFICATIONS
915
915
  };
916
916
  };
917
917
  var getMockMarkNotificationsAsReadResponse = () => {
918
918
  return {
919
- url: _chunkDNVD3CHQjs.NOTIFICATION_API_MARK_ALL_AS_READ_ENDPOINT,
919
+ url: _chunkH73GATCUjs.NOTIFICATION_API_MARK_ALL_AS_READ_ENDPOINT,
920
920
  requestMethod: "POST",
921
921
  response: null
922
922
  };
@@ -926,4 +926,4 @@ var getMockMarkNotificationsAsReadResponse = () => {
926
926
 
927
927
 
928
928
  exports.fixtures_exports = fixtures_exports; exports.NotificationServicesController_exports = NotificationServicesController_exports;
929
- //# sourceMappingURL=chunk-D7VP2FPR.js.map
929
+ //# sourceMappingURL=chunk-P5DZ7JHL.js.map
@@ -21,9 +21,47 @@ var NOTIFICATION_NETWORK_CURRENCY_SYMBOL = {
21
21
  [_chunkV6P5JEPTjs.NOTIFICATION_CHAINS_ID.OPTIMISM]: "ETH",
22
22
  [_chunkV6P5JEPTjs.NOTIFICATION_CHAINS_ID.POLYGON]: "MATIC"
23
23
  };
24
+ var SUPPORTED_NOTIFICATION_BLOCK_EXPLORERS = {
25
+ // ETHEREUM
26
+ [_chunkV6P5JEPTjs.NOTIFICATION_CHAINS_ID.ETHEREUM]: {
27
+ url: "https://etherscan.io",
28
+ name: "Etherscan"
29
+ },
30
+ // OPTIMISM
31
+ [_chunkV6P5JEPTjs.NOTIFICATION_CHAINS_ID.OPTIMISM]: {
32
+ url: "https://optimistic.etherscan.io",
33
+ name: "Optimistic Etherscan"
34
+ },
35
+ // BSC
36
+ [_chunkV6P5JEPTjs.NOTIFICATION_CHAINS_ID.BSC]: {
37
+ url: "https://bscscan.com",
38
+ name: "BscScan"
39
+ },
40
+ // POLYGON
41
+ [_chunkV6P5JEPTjs.NOTIFICATION_CHAINS_ID.POLYGON]: {
42
+ url: "https://polygonscan.com",
43
+ name: "PolygonScan"
44
+ },
45
+ // ARBITRUM
46
+ [_chunkV6P5JEPTjs.NOTIFICATION_CHAINS_ID.ARBITRUM]: {
47
+ url: "https://arbiscan.io",
48
+ name: "Arbiscan"
49
+ },
50
+ // AVALANCHE
51
+ [_chunkV6P5JEPTjs.NOTIFICATION_CHAINS_ID.AVALANCHE]: {
52
+ url: "https://snowtrace.io",
53
+ name: "Snowtrace"
54
+ },
55
+ // LINEA
56
+ [_chunkV6P5JEPTjs.NOTIFICATION_CHAINS_ID.LINEA]: {
57
+ url: "https://lineascan.build",
58
+ name: "LineaScan"
59
+ }
60
+ };
61
+
24
62
 
25
63
 
26
64
 
27
65
 
28
- exports.NOTIFICATION_NETWORK_CURRENCY_NAME = NOTIFICATION_NETWORK_CURRENCY_NAME; exports.NOTIFICATION_NETWORK_CURRENCY_SYMBOL = NOTIFICATION_NETWORK_CURRENCY_SYMBOL;
29
- //# sourceMappingURL=chunk-S2FM5DOS.js.map
66
+ exports.NOTIFICATION_NETWORK_CURRENCY_NAME = NOTIFICATION_NETWORK_CURRENCY_NAME; exports.NOTIFICATION_NETWORK_CURRENCY_SYMBOL = NOTIFICATION_NETWORK_CURRENCY_SYMBOL; exports.SUPPORTED_NOTIFICATION_BLOCK_EXPLORERS = SUPPORTED_NOTIFICATION_BLOCK_EXPLORERS;
67
+ //# sourceMappingURL=chunk-QOG3RCXM.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/NotificationServicesController/ui/constants.ts"],"names":[],"mappings":";;;;;AAEO,IAAM,qCAAqC;AAAA,EAChD,CAAC,uBAAuB,QAAQ,GAAG;AAAA,EACnC,CAAC,uBAAuB,QAAQ,GAAG;AAAA,EACnC,CAAC,uBAAuB,SAAS,GAAG;AAAA,EACpC,CAAC,uBAAuB,GAAG,GAAG;AAAA,EAC9B,CAAC,uBAAuB,KAAK,GAAG;AAAA,EAChC,CAAC,uBAAuB,QAAQ,GAAG;AAAA,EACnC,CAAC,uBAAuB,OAAO,GAAG;AACpC;AAEO,IAAM,uCAAuC;AAAA,EAClD,CAAC,uBAAuB,QAAQ,GAAG;AAAA,EACnC,CAAC,uBAAuB,QAAQ,GAAG;AAAA,EACnC,CAAC,uBAAuB,SAAS,GAAG;AAAA,EACpC,CAAC,uBAAuB,GAAG,GAAG;AAAA,EAC9B,CAAC,uBAAuB,KAAK,GAAG;AAAA,EAChC,CAAC,uBAAuB,QAAQ,GAAG;AAAA,EACnC,CAAC,uBAAuB,OAAO,GAAG;AACpC;AAOO,IAAM,yCAAyC;AAAA;AAAA,EAEpD,CAAC,uBAAuB,QAAQ,GAAG;AAAA,IACjC,KAAK;AAAA,IACL,MAAM;AAAA,EACR;AAAA;AAAA,EAEA,CAAC,uBAAuB,QAAQ,GAAG;AAAA,IACjC,KAAK;AAAA,IACL,MAAM;AAAA,EACR;AAAA;AAAA,EAEA,CAAC,uBAAuB,GAAG,GAAG;AAAA,IAC5B,KAAK;AAAA,IACL,MAAM;AAAA,EACR;AAAA;AAAA,EAEA,CAAC,uBAAuB,OAAO,GAAG;AAAA,IAChC,KAAK;AAAA,IACL,MAAM;AAAA,EACR;AAAA;AAAA,EAEA,CAAC,uBAAuB,QAAQ,GAAG;AAAA,IACjC,KAAK;AAAA,IACL,MAAM;AAAA,EACR;AAAA;AAAA,EAEA,CAAC,uBAAuB,SAAS,GAAG;AAAA,IAClC,KAAK;AAAA,IACL,MAAM;AAAA,EACR;AAAA;AAAA,EAEA,CAAC,uBAAuB,KAAK,GAAG;AAAA,IAC9B,KAAK;AAAA,IACL,MAAM;AAAA,EACR;AACF","sourcesContent":["import { NOTIFICATION_CHAINS_ID } from '../constants/notification-schema';\n\nexport const NOTIFICATION_NETWORK_CURRENCY_NAME = {\n [NOTIFICATION_CHAINS_ID.ETHEREUM]: 'Ethereum',\n [NOTIFICATION_CHAINS_ID.ARBITRUM]: 'Arbitrum',\n [NOTIFICATION_CHAINS_ID.AVALANCHE]: 'Avalanche',\n [NOTIFICATION_CHAINS_ID.BSC]: 'Binance',\n [NOTIFICATION_CHAINS_ID.LINEA]: 'Linea',\n [NOTIFICATION_CHAINS_ID.OPTIMISM]: 'Optimism',\n [NOTIFICATION_CHAINS_ID.POLYGON]: 'Polygon',\n} as const;\n\nexport const NOTIFICATION_NETWORK_CURRENCY_SYMBOL = {\n [NOTIFICATION_CHAINS_ID.ETHEREUM]: 'ETH',\n [NOTIFICATION_CHAINS_ID.ARBITRUM]: 'ETH',\n [NOTIFICATION_CHAINS_ID.AVALANCHE]: 'AVAX',\n [NOTIFICATION_CHAINS_ID.BSC]: 'BNB',\n [NOTIFICATION_CHAINS_ID.LINEA]: 'ETH',\n [NOTIFICATION_CHAINS_ID.OPTIMISM]: 'ETH',\n [NOTIFICATION_CHAINS_ID.POLYGON]: 'MATIC',\n};\n\nexport type BlockExplorerConfig = {\n url: string;\n name: string;\n};\n\nexport const SUPPORTED_NOTIFICATION_BLOCK_EXPLORERS = {\n // ETHEREUM\n [NOTIFICATION_CHAINS_ID.ETHEREUM]: {\n url: 'https://etherscan.io',\n name: 'Etherscan',\n },\n // OPTIMISM\n [NOTIFICATION_CHAINS_ID.OPTIMISM]: {\n url: 'https://optimistic.etherscan.io',\n name: 'Optimistic Etherscan',\n },\n // BSC\n [NOTIFICATION_CHAINS_ID.BSC]: {\n url: 'https://bscscan.com',\n name: 'BscScan',\n },\n // POLYGON\n [NOTIFICATION_CHAINS_ID.POLYGON]: {\n url: 'https://polygonscan.com',\n name: 'PolygonScan',\n },\n // ARBITRUM\n [NOTIFICATION_CHAINS_ID.ARBITRUM]: {\n url: 'https://arbiscan.io',\n name: 'Arbiscan',\n },\n // AVALANCHE\n [NOTIFICATION_CHAINS_ID.AVALANCHE]: {\n url: 'https://snowtrace.io',\n name: 'Snowtrace',\n },\n // LINEA\n [NOTIFICATION_CHAINS_ID.LINEA]: {\n url: 'https://lineascan.build',\n name: 'LineaScan',\n },\n} satisfies Record<string, BlockExplorerConfig>;\n\nexport { NOTIFICATION_CHAINS_ID } from '../constants/notification-schema';\n"]}
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  listenToPushNotificationsClicked,
3
3
  listenToPushNotificationsReceived
4
- } from "./chunk-A5QFYBTR.mjs";
4
+ } from "./chunk-YHVXD5WW.mjs";
5
5
  import {
6
6
  REGISTRATION_TOKENS_ENDPOINT
7
7
  } from "./chunk-IKWNHNJQ.mjs";
@@ -146,4 +146,4 @@ export {
146
146
  updateTriggerPushNotifications,
147
147
  listenToPushNotifications
148
148
  };
149
- //# sourceMappingURL=chunk-ADYRLXWY.mjs.map
149
+ //# sourceMappingURL=chunk-WGGW6VCR.mjs.map
@@ -3,11 +3,11 @@ import {
3
3
  deactivatePushNotifications,
4
4
  listenToPushNotifications,
5
5
  updateTriggerPushNotifications
6
- } from "./chunk-ADYRLXWY.mjs";
6
+ } from "./chunk-WGGW6VCR.mjs";
7
7
  import {
8
8
  createRegToken,
9
9
  deleteRegToken
10
- } from "./chunk-A5QFYBTR.mjs";
10
+ } from "./chunk-YHVXD5WW.mjs";
11
11
  import {
12
12
  __privateAdd,
13
13
  __privateGet,
@@ -77,7 +77,7 @@ var NotificationServicesPushController = class extends BaseController {
77
77
  if (!regToken) {
78
78
  return;
79
79
  }
80
- __privateSet(this, _pushListenerUnsubscribe, await listenToPushNotifications({
80
+ __privateGet(this, _pushListenerUnsubscribe) ?? __privateSet(this, _pushListenerUnsubscribe, await listenToPushNotifications({
81
81
  env: __privateGet(this, _env),
82
82
  listenToPushReceived: async (n) => {
83
83
  this.messagingSystem.publish(
@@ -213,4 +213,4 @@ export {
213
213
  defaultState,
214
214
  NotificationServicesPushController
215
215
  };
216
- //# sourceMappingURL=chunk-XVIUHFC3.mjs.map
216
+ //# sourceMappingURL=chunk-X3ZU3HL7.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/NotificationServicesPushController/NotificationServicesPushController.ts"],"sourcesContent":["import type {\n RestrictedControllerMessenger,\n ControllerGetStateAction,\n} from '@metamask/base-controller';\nimport { BaseController } from '@metamask/base-controller';\nimport type { AuthenticationController } from '@metamask/profile-sync-controller';\nimport log from 'loglevel';\n\nimport type { Types } from '../NotificationServicesController';\nimport { createRegToken, deleteRegToken } from './services/push/push-web';\nimport {\n activatePushNotifications,\n deactivatePushNotifications,\n listenToPushNotifications,\n updateTriggerPushNotifications,\n} from './services/services';\nimport type { PushNotificationEnv } from './types';\n\nconst controllerName = 'NotificationServicesPushController';\n\nexport type NotificationServicesPushControllerState = {\n fcmToken: string;\n};\n\nexport type NotificationServicesPushControllerEnablePushNotificationsAction = {\n type: `${typeof controllerName}:enablePushNotifications`;\n handler: NotificationServicesPushController['enablePushNotifications'];\n};\n\nexport type NotificationServicesPushControllerDisablePushNotificationsAction = {\n type: `${typeof controllerName}:disablePushNotifications`;\n handler: NotificationServicesPushController['disablePushNotifications'];\n};\nexport type NotificationServicesPushControllerUpdateTriggerPushNotificationsAction =\n {\n type: `${typeof controllerName}:updateTriggerPushNotifications`;\n handler: NotificationServicesPushController['updateTriggerPushNotifications'];\n };\n\nexport type Actions =\n | NotificationServicesPushControllerEnablePushNotificationsAction\n | NotificationServicesPushControllerDisablePushNotificationsAction\n | NotificationServicesPushControllerUpdateTriggerPushNotificationsAction\n | ControllerGetStateAction<'state', NotificationServicesPushControllerState>;\n\nexport type AllowedActions =\n AuthenticationController.AuthenticationControllerGetBearerToken;\n\nexport type NotificationServicesPushControllerOnNewNotificationEvent = {\n type: `${typeof controllerName}:onNewNotifications`;\n payload: [Types.INotification];\n};\n\nexport type NotificationServicesPushControllerPushNotificationClicked = {\n type: `${typeof controllerName}:pushNotificationClicked`;\n payload: [Types.INotification];\n};\n\nexport type AllowedEvents =\n | NotificationServicesPushControllerOnNewNotificationEvent\n | NotificationServicesPushControllerPushNotificationClicked;\n\nexport type NotificationServicesPushControllerMessenger =\n RestrictedControllerMessenger<\n typeof controllerName,\n Actions | AllowedActions,\n AllowedEvents,\n AllowedActions['type'],\n AllowedEvents['type']\n >;\n\nexport const defaultState: NotificationServicesPushControllerState = {\n fcmToken: '',\n};\nconst metadata = {\n fcmToken: {\n persist: true,\n anonymous: true,\n },\n};\n\ntype ControllerConfig = {\n /**\n * Config to turn on/off push notifications.\n * This is currently linked to MV3 builds on extension.\n */\n isPushEnabled: boolean;\n\n /**\n * Must handle when a push notification is received.\n * You must call `registration.showNotification` or equivalent to show the notification on web/mobile\n */\n onPushNotificationReceived: (\n notification: Types.INotification,\n ) => void | Promise<void>;\n\n /**\n * Must handle when a push notification is clicked.\n * You must call `event.notification.close();` or equivalent for closing and opening notification in a new window.\n */\n onPushNotificationClicked: (\n event: NotificationEvent,\n notification?: Types.INotification,\n ) => void;\n\n /**\n * determine the config used for push notification services\n */\n platform: 'extension' | 'mobile';\n};\n\n/**\n * Manages push notifications for the application, including enabling, disabling, and updating triggers for push notifications.\n * This controller integrates with Firebase Cloud Messaging (FCM) to handle the registration and management of push notifications.\n * It is responsible for registering and unregistering the service worker that listens for push notifications,\n * managing the FCM token, and communicating with the server to register or unregister the device for push notifications.\n * Additionally, it provides functionality to update the server with new UUIDs that should trigger push notifications.\n *\n * @augments {BaseController<typeof controllerName, NotificationServicesPushControllerState, NotificationServicesPushControllerMessenger>}\n */\nexport default class NotificationServicesPushController extends BaseController<\n typeof controllerName,\n NotificationServicesPushControllerState,\n NotificationServicesPushControllerMessenger\n> {\n #pushListenerUnsubscribe: (() => void) | undefined = undefined;\n\n #env: PushNotificationEnv;\n\n #config: ControllerConfig;\n\n constructor({\n messenger,\n state,\n env,\n config,\n }: {\n messenger: NotificationServicesPushControllerMessenger;\n state: NotificationServicesPushControllerState;\n env: PushNotificationEnv;\n config: ControllerConfig;\n }) {\n super({\n messenger,\n metadata,\n name: controllerName,\n state: { ...defaultState, ...state },\n });\n\n this.#env = env;\n this.#config = config;\n\n this.#registerMessageHandlers();\n }\n\n #registerMessageHandlers(): void {\n this.messagingSystem.registerActionHandler(\n 'NotificationServicesPushController:enablePushNotifications',\n this.enablePushNotifications.bind(this),\n );\n this.messagingSystem.registerActionHandler(\n 'NotificationServicesPushController:disablePushNotifications',\n this.disablePushNotifications.bind(this),\n );\n this.messagingSystem.registerActionHandler(\n 'NotificationServicesPushController:updateTriggerPushNotifications',\n this.updateTriggerPushNotifications.bind(this),\n );\n }\n\n async #getAndAssertBearerToken() {\n const bearerToken = await this.messagingSystem.call(\n 'AuthenticationController:getBearerToken',\n );\n if (!bearerToken) {\n log.error(\n 'Failed to enable push notifications: BearerToken token is missing.',\n );\n throw new Error('BearerToken token is missing');\n }\n\n return bearerToken;\n }\n\n /**\n * Enables push notifications for the application.\n *\n * This method sets up the necessary infrastructure for handling push notifications by:\n * 1. Registering the service worker to listen for messages.\n * 2. Fetching the Firebase Cloud Messaging (FCM) token from Firebase.\n * 3. Sending the FCM token to the server responsible for sending notifications, to register the device.\n *\n * @param UUIDs - An array of UUIDs to enable push notifications for.\n */\n async enablePushNotifications(UUIDs: string[]) {\n if (!this.#config.isPushEnabled) {\n return;\n }\n\n const bearerToken = await this.#getAndAssertBearerToken();\n\n try {\n // Activate Push Notifications\n const regToken = await activatePushNotifications({\n bearerToken,\n triggers: UUIDs,\n env: this.#env,\n createRegToken,\n platform: this.#config.platform,\n });\n\n if (!regToken) {\n return;\n }\n\n this.#pushListenerUnsubscribe = await listenToPushNotifications({\n env: this.#env,\n listenToPushReceived: async (n) => {\n this.messagingSystem.publish(\n 'NotificationServicesPushController:onNewNotifications',\n n,\n );\n await this.#config.onPushNotificationReceived(n);\n },\n listenToPushClicked: (e, n) => {\n if (n) {\n this.messagingSystem.publish(\n 'NotificationServicesPushController:pushNotificationClicked',\n n,\n );\n }\n\n this.#config.onPushNotificationClicked(e);\n },\n });\n\n // Update state\n this.update((state) => {\n state.fcmToken = regToken;\n });\n } catch (error) {\n log.error('Failed to enable push notifications:', error);\n throw new Error('Failed to enable push notifications');\n }\n }\n\n /**\n * Disables push notifications for the application.\n * This method handles the process of disabling push notifications by:\n * 1. Unregistering the service worker to stop listening for messages.\n * 2. Sending a request to the server to unregister the device using the FCM token.\n * 3. Removing the FCM token from the state to complete the process.\n *\n * @param UUIDs - An array of UUIDs for which push notifications should be disabled.\n */\n async disablePushNotifications(UUIDs: string[]) {\n if (!this.#config.isPushEnabled) {\n return;\n }\n\n const bearerToken = await this.#getAndAssertBearerToken();\n let isPushNotificationsDisabled: boolean;\n\n try {\n // Send a request to the server to unregister the token/device\n isPushNotificationsDisabled = await deactivatePushNotifications({\n bearerToken,\n triggers: UUIDs,\n env: this.#env,\n deleteRegToken,\n regToken: this.state.fcmToken,\n });\n } catch (error) {\n const errorMessage = `Failed to disable push notifications: ${\n error as string\n }`;\n log.error(errorMessage);\n throw new Error(errorMessage);\n }\n\n // Remove the FCM token from the state\n if (!isPushNotificationsDisabled) {\n return;\n }\n\n // Unsubscribe from push notifications\n this.#pushListenerUnsubscribe?.();\n\n // Update State\n if (isPushNotificationsDisabled) {\n this.update((state) => {\n state.fcmToken = '';\n });\n }\n }\n\n /**\n * Updates the triggers for push notifications.\n * This method is responsible for updating the server with the new set of UUIDs that should trigger push notifications.\n * It uses the current FCM token and a BearerToken for authentication.\n *\n * @param UUIDs - An array of UUIDs that should trigger push notifications.\n */\n async updateTriggerPushNotifications(UUIDs: string[]) {\n if (!this.#config.isPushEnabled) {\n return;\n }\n\n const bearerToken = await this.#getAndAssertBearerToken();\n\n try {\n const { fcmToken } = await updateTriggerPushNotifications({\n bearerToken,\n triggers: UUIDs,\n env: this.#env,\n createRegToken,\n deleteRegToken,\n platform: this.#config.platform,\n regToken: this.state.fcmToken,\n });\n\n // update the state with the new FCM token\n if (fcmToken) {\n this.update((state) => {\n state.fcmToken = fcmToken;\n });\n }\n } catch (error) {\n const errorMessage = `Failed to update triggers for push notifications: ${\n error as string\n }`;\n log.error(errorMessage);\n throw new Error(errorMessage);\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAIA,SAAS,sBAAsB;AAE/B,OAAO,SAAS;AAYhB,IAAM,iBAAiB;AAqDhB,IAAM,eAAwD;AAAA,EACnE,UAAU;AACZ;AACA,IAAM,WAAW;AAAA,EACf,UAAU;AAAA,IACR,SAAS;AAAA,IACT,WAAW;AAAA,EACb;AACF;AA/EA;AAwHA,IAAqB,qCAArB,cAAgE,eAI9D;AAAA,EAOA,YAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,GAKG;AACD,UAAM;AAAA,MACJ;AAAA,MACA;AAAA,MACA,MAAM;AAAA,MACN,OAAO,EAAE,GAAG,cAAc,GAAG,MAAM;AAAA,IACrC,CAAC;AAQH;AAeA,uBAAM;AA7CN,iDAAqD;AAErD;AAEA;AAoBE,uBAAK,MAAO;AACZ,uBAAK,SAAU;AAEf,0BAAK,sDAAL;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAyCA,MAAM,wBAAwB,OAAiB;AAC7C,QAAI,CAAC,mBAAK,SAAQ,eAAe;AAC/B;AAAA,IACF;AAEA,UAAM,cAAc,MAAM,sBAAK,sDAAL;AAE1B,QAAI;AAEF,YAAM,WAAW,MAAM,0BAA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AChD;AAEA,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../src/NotificationServicesPushController/NotificationServicesPushController.ts"],"sourcesContent":["import type {\n RestrictedControllerMessenger,\n ControllerGetStateAction,\n} from '@metamask/base-controller';\nimport { BaseController } from '@metamask/base-controller';\nimport type { AuthenticationController } from '@metamask/profile-sync-controller';\nimport log from 'loglevel';\n\nimport type { Types } from '../NotificationServicesController';\nimport { createRegToken, deleteRegToken } from './services/push/push-web';\nimport {\n activatePushNotifications,\n deactivatePushNotifications,\n listenToPushNotifications,\n updateTriggerPushNotifications,\n} from './services/services';\nimport type { PushNotificationEnv } from './types';\n\nconst controllerName = 'NotificationServicesPushController';\n\nexport type NotificationServicesPushControllerState = {\n fcmToken: string;\n};\n\nexport type NotificationServicesPushControllerEnablePushNotificationsAction = {\n type: `${typeof controllerName}:enablePushNotifications`;\n handler: NotificationServicesPushController['enablePushNotifications'];\n};\n\nexport type NotificationServicesPushControllerDisablePushNotificationsAction = {\n type: `${typeof controllerName}:disablePushNotifications`;\n handler: NotificationServicesPushController['disablePushNotifications'];\n};\nexport type NotificationServicesPushControllerUpdateTriggerPushNotificationsAction =\n {\n type: `${typeof controllerName}:updateTriggerPushNotifications`;\n handler: NotificationServicesPushController['updateTriggerPushNotifications'];\n };\n\nexport type Actions =\n | NotificationServicesPushControllerEnablePushNotificationsAction\n | NotificationServicesPushControllerDisablePushNotificationsAction\n | NotificationServicesPushControllerUpdateTriggerPushNotificationsAction\n | ControllerGetStateAction<'state', NotificationServicesPushControllerState>;\n\nexport type AllowedActions =\n AuthenticationController.AuthenticationControllerGetBearerToken;\n\nexport type NotificationServicesPushControllerOnNewNotificationEvent = {\n type: `${typeof controllerName}:onNewNotifications`;\n payload: [Types.INotification];\n};\n\nexport type NotificationServicesPushControllerPushNotificationClicked = {\n type: `${typeof controllerName}:pushNotificationClicked`;\n payload: [Types.INotification];\n};\n\nexport type AllowedEvents =\n | NotificationServicesPushControllerOnNewNotificationEvent\n | NotificationServicesPushControllerPushNotificationClicked;\n\nexport type NotificationServicesPushControllerMessenger =\n RestrictedControllerMessenger<\n typeof controllerName,\n Actions | AllowedActions,\n AllowedEvents,\n AllowedActions['type'],\n AllowedEvents['type']\n >;\n\nexport const defaultState: NotificationServicesPushControllerState = {\n fcmToken: '',\n};\nconst metadata = {\n fcmToken: {\n persist: true,\n anonymous: true,\n },\n};\n\ntype ControllerConfig = {\n /**\n * Config to turn on/off push notifications.\n * This is currently linked to MV3 builds on extension.\n */\n isPushEnabled: boolean;\n\n /**\n * Must handle when a push notification is received.\n * You must call `registration.showNotification` or equivalent to show the notification on web/mobile\n */\n onPushNotificationReceived: (\n notification: Types.INotification,\n ) => void | Promise<void>;\n\n /**\n * Must handle when a push notification is clicked.\n * You must call `event.notification.close();` or equivalent for closing and opening notification in a new window.\n */\n onPushNotificationClicked: (\n event: NotificationEvent,\n notification?: Types.INotification,\n ) => void;\n\n /**\n * determine the config used for push notification services\n */\n platform: 'extension' | 'mobile';\n};\n\n/**\n * Manages push notifications for the application, including enabling, disabling, and updating triggers for push notifications.\n * This controller integrates with Firebase Cloud Messaging (FCM) to handle the registration and management of push notifications.\n * It is responsible for registering and unregistering the service worker that listens for push notifications,\n * managing the FCM token, and communicating with the server to register or unregister the device for push notifications.\n * Additionally, it provides functionality to update the server with new UUIDs that should trigger push notifications.\n *\n * @augments {BaseController<typeof controllerName, NotificationServicesPushControllerState, NotificationServicesPushControllerMessenger>}\n */\nexport default class NotificationServicesPushController extends BaseController<\n typeof controllerName,\n NotificationServicesPushControllerState,\n NotificationServicesPushControllerMessenger\n> {\n #pushListenerUnsubscribe: (() => void) | undefined = undefined;\n\n #env: PushNotificationEnv;\n\n #config: ControllerConfig;\n\n constructor({\n messenger,\n state,\n env,\n config,\n }: {\n messenger: NotificationServicesPushControllerMessenger;\n state: NotificationServicesPushControllerState;\n env: PushNotificationEnv;\n config: ControllerConfig;\n }) {\n super({\n messenger,\n metadata,\n name: controllerName,\n state: { ...defaultState, ...state },\n });\n\n this.#env = env;\n this.#config = config;\n\n this.#registerMessageHandlers();\n }\n\n #registerMessageHandlers(): void {\n this.messagingSystem.registerActionHandler(\n 'NotificationServicesPushController:enablePushNotifications',\n this.enablePushNotifications.bind(this),\n );\n this.messagingSystem.registerActionHandler(\n 'NotificationServicesPushController:disablePushNotifications',\n this.disablePushNotifications.bind(this),\n );\n this.messagingSystem.registerActionHandler(\n 'NotificationServicesPushController:updateTriggerPushNotifications',\n this.updateTriggerPushNotifications.bind(this),\n );\n }\n\n async #getAndAssertBearerToken() {\n const bearerToken = await this.messagingSystem.call(\n 'AuthenticationController:getBearerToken',\n );\n if (!bearerToken) {\n log.error(\n 'Failed to enable push notifications: BearerToken token is missing.',\n );\n throw new Error('BearerToken token is missing');\n }\n\n return bearerToken;\n }\n\n /**\n * Enables push notifications for the application.\n *\n * This method sets up the necessary infrastructure for handling push notifications by:\n * 1. Registering the service worker to listen for messages.\n * 2. Fetching the Firebase Cloud Messaging (FCM) token from Firebase.\n * 3. Sending the FCM token to the server responsible for sending notifications, to register the device.\n *\n * @param UUIDs - An array of UUIDs to enable push notifications for.\n */\n async enablePushNotifications(UUIDs: string[]) {\n if (!this.#config.isPushEnabled) {\n return;\n }\n\n const bearerToken = await this.#getAndAssertBearerToken();\n\n try {\n // Activate Push Notifications\n const regToken = await activatePushNotifications({\n bearerToken,\n triggers: UUIDs,\n env: this.#env,\n createRegToken,\n platform: this.#config.platform,\n });\n\n if (!regToken) {\n return;\n }\n\n this.#pushListenerUnsubscribe ??= await listenToPushNotifications({\n env: this.#env,\n listenToPushReceived: async (n) => {\n this.messagingSystem.publish(\n 'NotificationServicesPushController:onNewNotifications',\n n,\n );\n await this.#config.onPushNotificationReceived(n);\n },\n listenToPushClicked: (e, n) => {\n if (n) {\n this.messagingSystem.publish(\n 'NotificationServicesPushController:pushNotificationClicked',\n n,\n );\n }\n\n this.#config.onPushNotificationClicked(e);\n },\n });\n\n // Update state\n this.update((state) => {\n state.fcmToken = regToken;\n });\n } catch (error) {\n log.error('Failed to enable push notifications:', error);\n throw new Error('Failed to enable push notifications');\n }\n }\n\n /**\n * Disables push notifications for the application.\n * This method handles the process of disabling push notifications by:\n * 1. Unregistering the service worker to stop listening for messages.\n * 2. Sending a request to the server to unregister the device using the FCM token.\n * 3. Removing the FCM token from the state to complete the process.\n *\n * @param UUIDs - An array of UUIDs for which push notifications should be disabled.\n */\n async disablePushNotifications(UUIDs: string[]) {\n if (!this.#config.isPushEnabled) {\n return;\n }\n\n const bearerToken = await this.#getAndAssertBearerToken();\n let isPushNotificationsDisabled: boolean;\n\n try {\n // Send a request to the server to unregister the token/device\n isPushNotificationsDisabled = await deactivatePushNotifications({\n bearerToken,\n triggers: UUIDs,\n env: this.#env,\n deleteRegToken,\n regToken: this.state.fcmToken,\n });\n } catch (error) {\n const errorMessage = `Failed to disable push notifications: ${\n error as string\n }`;\n log.error(errorMessage);\n throw new Error(errorMessage);\n }\n\n // Remove the FCM token from the state\n if (!isPushNotificationsDisabled) {\n return;\n }\n\n // Unsubscribe from push notifications\n this.#pushListenerUnsubscribe?.();\n\n // Update State\n if (isPushNotificationsDisabled) {\n this.update((state) => {\n state.fcmToken = '';\n });\n }\n }\n\n /**\n * Updates the triggers for push notifications.\n * This method is responsible for updating the server with the new set of UUIDs that should trigger push notifications.\n * It uses the current FCM token and a BearerToken for authentication.\n *\n * @param UUIDs - An array of UUIDs that should trigger push notifications.\n */\n async updateTriggerPushNotifications(UUIDs: string[]) {\n if (!this.#config.isPushEnabled) {\n return;\n }\n\n const bearerToken = await this.#getAndAssertBearerToken();\n\n try {\n const { fcmToken } = await updateTriggerPushNotifications({\n bearerToken,\n triggers: UUIDs,\n env: this.#env,\n createRegToken,\n deleteRegToken,\n platform: this.#config.platform,\n regToken: this.state.fcmToken,\n });\n\n // update the state with the new FCM token\n if (fcmToken) {\n this.update((state) => {\n state.fcmToken = fcmToken;\n });\n }\n } catch (error) {\n const errorMessage = `Failed to update triggers for push notifications: ${\n error as string\n }`;\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AA,QACxD;AAAA,QACA,UAAU;AAAA,QACV,KAAK,mBAAK;AAAA,QACV;AAAA,QACA;AAAA,QACA,UAAU,mBAAK,SAAQ;AAAA,QACvB,UAAU,KAAK,MAAM;AAAA,MACvB,CAAC;AAGD,UAAI,UAAU;AACZ,aAAK,OAAO,CAAC,UAAU;AACrB,gBAAM,WAAW;AAAA,QACnB,CAAC;AAAA,MACH;AAAA,IACF,SAAS,OAAO;AACd,YAAM,eAAe,qDACnB,KACF;AACA,UAAI,MAAM,YAAY;AACtB,YAAM,IAAI,MAAM,YAAY;AAAA,IAC9B;AAAA,EACF;AACF;AAlNE;AAEA;AAEA;AA0BA;AAAA,6BAAwB,WAAS;AAC/B,OAAK,gBAAgB;AAAA,IACnB;AAAA,IACA,KAAK,wBAAwB,KAAK,IAAI;AAAA,EACxC;AACA,OAAK,gBAAgB;AAAA,IACnB;AAAA,IACA,KAAK,yBAAyB,KAAK,IAAI;AAAA,EACzC;AACA,OAAK,gBAAgB;AAAA,IACnB;AAAA,IACA,KAAK,+BAA+B,KAAK,IAAI;AAAA,EAC/C;AACF;AAEM;AAAA,6BAAwB,iBAAG;AAC/B,QAAM,cAAc,MAAM,KAAK,gBAAgB;AAAA,IAC7C;AAAA,EACF;AACA,MAAI,CAAC,aAAa;AAChB,QAAI;AAAA,MACF;AAAA,IACF;AACA,UAAM,IAAI,MAAM,8BAA8B;AAAA,EAChD;AAEA,SAAO;AACT;","names":[]}
@@ -1,6 +1,9 @@
1
1
  import {
2
2
  processors_exports
3
3
  } from "./chunk-X42WN3FE.mjs";
4
+ import {
5
+ toRawOnChainNotification
6
+ } from "./chunk-DINCLRZT.mjs";
4
7
 
5
8
  // src/NotificationServicesPushController/services/push/push-web.ts
6
9
  import { getApp, initializeApp } from "firebase/app";
@@ -55,10 +58,11 @@ async function listenToPushNotificationsReceived(env, handler) {
55
58
  // eslint-disable-next-line @typescript-eslint/no-misused-promises
56
59
  async (payload) => {
57
60
  try {
58
- const notificationData = payload?.data?.data ? JSON.parse(payload?.data?.data) : void 0;
59
- if (!notificationData) {
61
+ const data = payload?.data?.data ? JSON.parse(payload?.data?.data) : void 0;
62
+ if (!data) {
60
63
  return;
61
64
  }
65
+ const notificationData = toRawOnChainNotification(data);
62
66
  const notification = processors_exports.processNotification(notificationData);
63
67
  await handler(notification);
64
68
  } catch (error) {
@@ -89,4 +93,4 @@ export {
89
93
  listenToPushNotificationsReceived,
90
94
  listenToPushNotificationsClicked
91
95
  };
92
- //# sourceMappingURL=chunk-A5QFYBTR.mjs.map
96
+ //# sourceMappingURL=chunk-YHVXD5WW.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/NotificationServicesPushController/services/push/push-web.ts"],"sourcesContent":["// We are defining that this file uses a webworker global scope.\n// eslint-disable-next-line spaced-comment\n/// <reference lib=\"webworker\" />\nimport type { FirebaseApp } from 'firebase/app';\nimport { getApp, initializeApp } from 'firebase/app';\nimport { getToken, deleteToken } from 'firebase/messaging';\nimport { getMessaging, onBackgroundMessage } from 'firebase/messaging/sw';\nimport type { Messaging, MessagePayload } from 'firebase/messaging/sw';\nimport log from 'loglevel';\n\nimport type { Types } from '../../../NotificationServicesController';\nimport { Processors } from '../../../NotificationServicesController';\nimport { toRawOnChainNotification } from '../../../shared/to-raw-notification';\nimport type { PushNotificationEnv } from '../../types/firebase';\n\ndeclare const self: ServiceWorkerGlobalScope;\n\nconst createFirebaseApp = async (\n env: PushNotificationEnv,\n): Promise<FirebaseApp> => {\n try {\n return getApp();\n } catch {\n const firebaseConfig = {\n apiKey: env.apiKey,\n authDomain: env.authDomain,\n storageBucket: env.storageBucket,\n projectId: env.projectId,\n messagingSenderId: env.messagingSenderId,\n appId: env.appId,\n measurementId: env.measurementId,\n };\n return initializeApp(firebaseConfig);\n }\n};\n\nconst getFirebaseMessaging = async (\n env: PushNotificationEnv,\n): Promise<Messaging> => {\n const app = await createFirebaseApp(env);\n return getMessaging(app);\n};\n\n/**\n * Creates a registration token for Firebase Cloud Messaging.\n *\n * @param env - env to configure push notifications\n * @returns A promise that resolves with the registration token or null if an error occurs.\n */\nexport async function createRegToken(\n env: PushNotificationEnv,\n): Promise<string | null> {\n try {\n const messaging = await getFirebaseMessaging(env);\n const token = await getToken(messaging, {\n serviceWorkerRegistration: self.registration,\n vapidKey: env.vapidKey,\n });\n return token;\n } catch {\n return null;\n }\n}\n\n/**\n * Deletes the Firebase Cloud Messaging registration token.\n *\n * @param env - env to configure push notifications\n * @returns A promise that resolves with true if the token was successfully deleted, false otherwise.\n */\nexport async function deleteRegToken(\n env: PushNotificationEnv,\n): Promise<boolean> {\n try {\n const messaging = await getFirebaseMessaging(env);\n await deleteToken(messaging);\n return true;\n } catch (error) {\n return false;\n }\n}\n\n/**\n * Service Worker Listener for when push notifications are received.\n * @param env - push notification environment\n * @param handler - handler to actually showing notification, MUST BE PROVEDED\n * @returns unsubscribe handler\n */\nexport async function listenToPushNotificationsReceived(\n env: PushNotificationEnv,\n handler: (notification: Types.INotification) => void | Promise<void>,\n) {\n const messaging = await getFirebaseMessaging(env);\n const unsubscribePushNotifications = onBackgroundMessage(\n messaging,\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n async (payload: MessagePayload) => {\n try {\n const data: Types.UnprocessedOnChainRawNotification | undefined =\n payload?.data?.data ? JSON.parse(payload?.data?.data) : undefined;\n\n if (!data) {\n return;\n }\n\n const notificationData = toRawOnChainNotification(data);\n const notification = Processors.processNotification(notificationData);\n await handler(notification);\n } catch (error) {\n // Do Nothing, cannot parse a bad notification\n log.error('Unable to send push notification:', {\n notification: payload?.data?.data,\n error,\n });\n throw new Error('Unable to send push notification');\n }\n },\n );\n\n const unsubscribe = () => unsubscribePushNotifications();\n return unsubscribe;\n}\n\n/**\n * Service Worker Listener for when a notification is clicked\n *\n * @param handler - listen to NotificationEvent from the service worker\n * @returns unsubscribe handler\n */\nexport function listenToPushNotificationsClicked(\n handler: (e: NotificationEvent, notification?: Types.INotification) => void,\n) {\n const clickHandler = (event: NotificationEvent) => {\n // Get Data\n const data: Types.INotification = event?.notification?.data;\n handler(event, data);\n };\n\n self.addEventListener('notificationclick', clickHandler);\n const unsubscribe = () =>\n self.removeEventListener('notificationclick', clickHandler);\n return unsubscribe;\n}\n"],"mappings":";;;;;;;;AAIA,SAAS,QAAQ,qBAAqB;AACtC,SAAS,UAAU,mBAAmB;AACtC,SAAS,cAAc,2BAA2B;AAElD,OAAO,SAAS;AAShB,IAAM,oBAAoB,OACxB,QACyB;AACzB,MAAI;AACF,WAAO,OAAO;AAAA,EAChB,QAAQ;AACN,UAAM,iBAAiB;AAAA,MACrB,QAAQ,IAAI;AAAA,MACZ,YAAY,IAAI;AAAA,MAChB,eAAe,IAAI;AAAA,MACnB,WAAW,IAAI;AAAA,MACf,mBAAmB,IAAI;AAAA,MACvB,OAAO,IAAI;AAAA,MACX,eAAe,IAAI;AAAA,IACrB;AACA,WAAO,cAAc,cAAc;AAAA,EACrC;AACF;AAEA,IAAM,uBAAuB,OAC3B,QACuB;AACvB,QAAM,MAAM,MAAM,kBAAkB,GAAG;AACvC,SAAO,aAAa,GAAG;AACzB;AAQA,eAAsB,eACpB,KACwB;AACxB,MAAI;AACF,UAAM,YAAY,MAAM,qBAAqB,GAAG;AAChD,UAAM,QAAQ,MAAM,SAAS,WAAW;AAAA,MACtC,2BAA2B,KAAK;AAAA,MAChC,UAAU,IAAI;AAAA,IAChB,CAAC;AACD,WAAO;AAAA,EACT,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAQA,eAAsB,eACpB,KACkB;AAClB,MAAI;AACF,UAAM,YAAY,MAAM,qBAAqB,GAAG;AAChD,UAAM,YAAY,SAAS;AAC3B,WAAO;AAAA,EACT,SAAS,OAAO;AACd,WAAO;AAAA,EACT;AACF;AAQA,eAAsB,kCACpB,KACA,SACA;AACA,QAAM,YAAY,MAAM,qBAAqB,GAAG;AAChD,QAAM,+BAA+B;AAAA,IACnC;AAAA;AAAA,IAEA,OAAO,YAA4B;AACjC,UAAI;AACF,cAAM,OACJ,SAAS,MAAM,OAAO,KAAK,MAAM,SAAS,MAAM,IAAI,IAAI;AAE1D,YAAI,CAAC,MAAM;AACT;AAAA,QACF;AAEA,cAAM,mBAAmB,yBAAyB,IAAI;AACtD,cAAM,eAAe,mBAAW,oBAAoB,gBAAgB;AACpE,cAAM,QAAQ,YAAY;AAAA,MAC5B,SAAS,OAAO;AAEd,YAAI,MAAM,qCAAqC;AAAA,UAC7C,cAAc,SAAS,MAAM;AAAA,UAC7B;AAAA,QACF,CAAC;AACD,cAAM,IAAI,MAAM,kCAAkC;AAAA,MACpD;AAAA,IACF;AAAA,EACF;AAEA,QAAM,cAAc,MAAM,6BAA6B;AACvD,SAAO;AACT;AAQO,SAAS,iCACd,SACA;AACA,QAAM,eAAe,CAAC,UAA6B;AAEjD,UAAM,OAA4B,OAAO,cAAc;AACvD,YAAQ,OAAO,IAAI;AAAA,EACrB;AAEA,OAAK,iBAAiB,qBAAqB,YAAY;AACvD,QAAM,cAAc,MAClB,KAAK,oBAAoB,qBAAqB,YAAY;AAC5D,SAAO;AACT;","names":[]}
@@ -0,0 +1,67 @@
1
+ import {
2
+ NOTIFICATION_CHAINS_ID
3
+ } from "./chunk-J4D2NH6Y.mjs";
4
+
5
+ // src/NotificationServicesController/ui/constants.ts
6
+ var NOTIFICATION_NETWORK_CURRENCY_NAME = {
7
+ [NOTIFICATION_CHAINS_ID.ETHEREUM]: "Ethereum",
8
+ [NOTIFICATION_CHAINS_ID.ARBITRUM]: "Arbitrum",
9
+ [NOTIFICATION_CHAINS_ID.AVALANCHE]: "Avalanche",
10
+ [NOTIFICATION_CHAINS_ID.BSC]: "Binance",
11
+ [NOTIFICATION_CHAINS_ID.LINEA]: "Linea",
12
+ [NOTIFICATION_CHAINS_ID.OPTIMISM]: "Optimism",
13
+ [NOTIFICATION_CHAINS_ID.POLYGON]: "Polygon"
14
+ };
15
+ var NOTIFICATION_NETWORK_CURRENCY_SYMBOL = {
16
+ [NOTIFICATION_CHAINS_ID.ETHEREUM]: "ETH",
17
+ [NOTIFICATION_CHAINS_ID.ARBITRUM]: "ETH",
18
+ [NOTIFICATION_CHAINS_ID.AVALANCHE]: "AVAX",
19
+ [NOTIFICATION_CHAINS_ID.BSC]: "BNB",
20
+ [NOTIFICATION_CHAINS_ID.LINEA]: "ETH",
21
+ [NOTIFICATION_CHAINS_ID.OPTIMISM]: "ETH",
22
+ [NOTIFICATION_CHAINS_ID.POLYGON]: "MATIC"
23
+ };
24
+ var SUPPORTED_NOTIFICATION_BLOCK_EXPLORERS = {
25
+ // ETHEREUM
26
+ [NOTIFICATION_CHAINS_ID.ETHEREUM]: {
27
+ url: "https://etherscan.io",
28
+ name: "Etherscan"
29
+ },
30
+ // OPTIMISM
31
+ [NOTIFICATION_CHAINS_ID.OPTIMISM]: {
32
+ url: "https://optimistic.etherscan.io",
33
+ name: "Optimistic Etherscan"
34
+ },
35
+ // BSC
36
+ [NOTIFICATION_CHAINS_ID.BSC]: {
37
+ url: "https://bscscan.com",
38
+ name: "BscScan"
39
+ },
40
+ // POLYGON
41
+ [NOTIFICATION_CHAINS_ID.POLYGON]: {
42
+ url: "https://polygonscan.com",
43
+ name: "PolygonScan"
44
+ },
45
+ // ARBITRUM
46
+ [NOTIFICATION_CHAINS_ID.ARBITRUM]: {
47
+ url: "https://arbiscan.io",
48
+ name: "Arbiscan"
49
+ },
50
+ // AVALANCHE
51
+ [NOTIFICATION_CHAINS_ID.AVALANCHE]: {
52
+ url: "https://snowtrace.io",
53
+ name: "Snowtrace"
54
+ },
55
+ // LINEA
56
+ [NOTIFICATION_CHAINS_ID.LINEA]: {
57
+ url: "https://lineascan.build",
58
+ name: "LineaScan"
59
+ }
60
+ };
61
+
62
+ export {
63
+ NOTIFICATION_NETWORK_CURRENCY_NAME,
64
+ NOTIFICATION_NETWORK_CURRENCY_SYMBOL,
65
+ SUPPORTED_NOTIFICATION_BLOCK_EXPLORERS
66
+ };
67
+ //# sourceMappingURL=chunk-YZYQYIKS.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/NotificationServicesController/ui/constants.ts"],"sourcesContent":["import { NOTIFICATION_CHAINS_ID } from '../constants/notification-schema';\n\nexport const NOTIFICATION_NETWORK_CURRENCY_NAME = {\n [NOTIFICATION_CHAINS_ID.ETHEREUM]: 'Ethereum',\n [NOTIFICATION_CHAINS_ID.ARBITRUM]: 'Arbitrum',\n [NOTIFICATION_CHAINS_ID.AVALANCHE]: 'Avalanche',\n [NOTIFICATION_CHAINS_ID.BSC]: 'Binance',\n [NOTIFICATION_CHAINS_ID.LINEA]: 'Linea',\n [NOTIFICATION_CHAINS_ID.OPTIMISM]: 'Optimism',\n [NOTIFICATION_CHAINS_ID.POLYGON]: 'Polygon',\n} as const;\n\nexport const NOTIFICATION_NETWORK_CURRENCY_SYMBOL = {\n [NOTIFICATION_CHAINS_ID.ETHEREUM]: 'ETH',\n [NOTIFICATION_CHAINS_ID.ARBITRUM]: 'ETH',\n [NOTIFICATION_CHAINS_ID.AVALANCHE]: 'AVAX',\n [NOTIFICATION_CHAINS_ID.BSC]: 'BNB',\n [NOTIFICATION_CHAINS_ID.LINEA]: 'ETH',\n [NOTIFICATION_CHAINS_ID.OPTIMISM]: 'ETH',\n [NOTIFICATION_CHAINS_ID.POLYGON]: 'MATIC',\n};\n\nexport type BlockExplorerConfig = {\n url: string;\n name: string;\n};\n\nexport const SUPPORTED_NOTIFICATION_BLOCK_EXPLORERS = {\n // ETHEREUM\n [NOTIFICATION_CHAINS_ID.ETHEREUM]: {\n url: 'https://etherscan.io',\n name: 'Etherscan',\n },\n // OPTIMISM\n [NOTIFICATION_CHAINS_ID.OPTIMISM]: {\n url: 'https://optimistic.etherscan.io',\n name: 'Optimistic Etherscan',\n },\n // BSC\n [NOTIFICATION_CHAINS_ID.BSC]: {\n url: 'https://bscscan.com',\n name: 'BscScan',\n },\n // POLYGON\n [NOTIFICATION_CHAINS_ID.POLYGON]: {\n url: 'https://polygonscan.com',\n name: 'PolygonScan',\n },\n // ARBITRUM\n [NOTIFICATION_CHAINS_ID.ARBITRUM]: {\n url: 'https://arbiscan.io',\n name: 'Arbiscan',\n },\n // AVALANCHE\n [NOTIFICATION_CHAINS_ID.AVALANCHE]: {\n url: 'https://snowtrace.io',\n name: 'Snowtrace',\n },\n // LINEA\n [NOTIFICATION_CHAINS_ID.LINEA]: {\n url: 'https://lineascan.build',\n name: 'LineaScan',\n },\n} satisfies Record<string, BlockExplorerConfig>;\n\nexport { NOTIFICATION_CHAINS_ID } from '../constants/notification-schema';\n"],"mappings":";;;;;AAEO,IAAM,qCAAqC;AAAA,EAChD,CAAC,uBAAuB,QAAQ,GAAG;AAAA,EACnC,CAAC,uBAAuB,QAAQ,GAAG;AAAA,EACnC,CAAC,uBAAuB,SAAS,GAAG;AAAA,EACpC,CAAC,uBAAuB,GAAG,GAAG;AAAA,EAC9B,CAAC,uBAAuB,KAAK,GAAG;AAAA,EAChC,CAAC,uBAAuB,QAAQ,GAAG;AAAA,EACnC,CAAC,uBAAuB,OAAO,GAAG;AACpC;AAEO,IAAM,uCAAuC;AAAA,EAClD,CAAC,uBAAuB,QAAQ,GAAG;AAAA,EACnC,CAAC,uBAAuB,QAAQ,GAAG;AAAA,EACnC,CAAC,uBAAuB,SAAS,GAAG;AAAA,EACpC,CAAC,uBAAuB,GAAG,GAAG;AAAA,EAC9B,CAAC,uBAAuB,KAAK,GAAG;AAAA,EAChC,CAAC,uBAAuB,QAAQ,GAAG;AAAA,EACnC,CAAC,uBAAuB,OAAO,GAAG;AACpC;AAOO,IAAM,yCAAyC;AAAA;AAAA,EAEpD,CAAC,uBAAuB,QAAQ,GAAG;AAAA,IACjC,KAAK;AAAA,IACL,MAAM;AAAA,EACR;AAAA;AAAA,EAEA,CAAC,uBAAuB,QAAQ,GAAG;AAAA,IACjC,KAAK;AAAA,IACL,MAAM;AAAA,EACR;AAAA;AAAA,EAEA,CAAC,uBAAuB,GAAG,GAAG;AAAA,IAC5B,KAAK;AAAA,IACL,MAAM;AAAA,EACR;AAAA;AAAA,EAEA,CAAC,uBAAuB,OAAO,GAAG;AAAA,IAChC,KAAK;AAAA,IACL,MAAM;AAAA,EACR;AAAA;AAAA,EAEA,CAAC,uBAAuB,QAAQ,GAAG;AAAA,IACjC,KAAK;AAAA,IACL,MAAM;AAAA,EACR;AAAA;AAAA,EAEA,CAAC,uBAAuB,SAAS,GAAG;AAAA,IAClC,KAAK;AAAA,IACL,MAAM;AAAA,EACR;AAAA;AAAA,EAEA,CAAC,uBAAuB,KAAK,GAAG;AAAA,IAC9B,KAAK;AAAA,IACL,MAAM;AAAA,EACR;AACF;","names":[]}
@@ -1,16 +1,19 @@
1
+ import {
2
+ types_exports
3
+ } from "./chunk-B4ECJJ5C.mjs";
1
4
  import {
2
5
  ui_exports
3
- } from "./chunk-5IPZMRR5.mjs";
6
+ } from "./chunk-5JDAO4ZC.mjs";
7
+ import {
8
+ constants_exports
9
+ } from "./chunk-ZHAD55AN.mjs";
4
10
  import {
5
11
  processors_exports
6
12
  } from "./chunk-X42WN3FE.mjs";
7
- import {
8
- types_exports
9
- } from "./chunk-B4ECJJ5C.mjs";
10
13
  import {
11
14
  NotificationServicesController,
12
15
  defaultState
13
- } from "./chunk-4VVOTF2Y.mjs";
16
+ } from "./chunk-4E76LF6X.mjs";
14
17
  import {
15
18
  FEATURE_ANNOUNCEMENT_API
16
19
  } from "./chunk-QFJZBLYQ.mjs";
@@ -18,13 +21,10 @@ import {
18
21
  NOTIFICATION_API_LIST_ENDPOINT,
19
22
  NOTIFICATION_API_MARK_ALL_AS_READ_ENDPOINT,
20
23
  TRIGGER_API_BATCH_ENDPOINT
21
- } from "./chunk-EZHMYHBX.mjs";
24
+ } from "./chunk-FN6GVBCU.mjs";
22
25
  import {
23
26
  initializeUserStorage
24
27
  } from "./chunk-ILPTPB4U.mjs";
25
- import {
26
- constants_exports
27
- } from "./chunk-ZHAD55AN.mjs";
28
28
  import {
29
29
  USER_STORAGE_VERSION_KEY
30
30
  } from "./chunk-6ZDVTRRT.mjs";
@@ -926,4 +926,4 @@ export {
926
926
  fixtures_exports,
927
927
  NotificationServicesController_exports
928
928
  };
929
- //# sourceMappingURL=chunk-YYWFWJTJ.mjs.map
929
+ //# sourceMappingURL=chunk-Z5VM5N2S.mjs.map
package/dist/index.js CHANGED
@@ -1,22 +1,21 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkMT4VCZEEjs = require('./chunk-MT4VCZEE.js');
3
+ var _chunk2BCJRWFFjs = require('./chunk-2BCJRWFF.js');
4
+ require('./chunk-7LWR54U7.js');
4
5
  require('./chunk-ENRKCWJ6.js');
5
6
  require('./chunk-BUT7X5F2.js');
6
7
  require('./chunk-EJ52BDLB.js');
7
- require('./chunk-7LWR54U7.js');
8
8
  require('./chunk-GETQWOTI.js');
9
- require('./chunk-5TUHE2FM.js');
10
- require('./chunk-GJHW5Z65.js');
11
- require('./chunk-72H2V4J5.js');
9
+ require('./chunk-6GXEFQ64.js');
10
+ require('./chunk-4HOEZMSV.js');
11
+ require('./chunk-GDKHOBJT.js');
12
12
  require('./chunk-B25TJ7KS.js');
13
13
 
14
14
 
15
- var _chunkD7VP2FPRjs = require('./chunk-D7VP2FPR.js');
16
- require('./chunk-AQPBSNWA.js');
17
- require('./chunk-S2FM5DOS.js');
18
- require('./chunk-KWTSMLND.js');
15
+ var _chunkP5DZ7JHLjs = require('./chunk-P5DZ7JHL.js');
19
16
  require('./chunk-232HZSEV.js');
17
+ require('./chunk-XZEVRYUE.js');
18
+ require('./chunk-3ZS2HAEG.js');
20
19
  require('./chunk-ZV3DFBO4.js');
21
20
  require('./chunk-DMH4NSLF.js');
22
21
  require('./chunk-IPI7BAW3.js');
@@ -25,21 +24,23 @@ require('./chunk-WRYFIWNK.js');
25
24
  require('./chunk-V5HMYDWE.js');
26
25
  require('./chunk-ZBNBZN5H.js');
27
26
  require('./chunk-PROWNV4M.js');
28
- require('./chunk-XZEVRYUE.js');
29
- require('./chunk-3ZS2HAEG.js');
30
- require('./chunk-2Z3NDVOV.js');
27
+ require('./chunk-IG3KWCQU.js');
28
+ require('./chunk-QOG3RCXM.js');
29
+ require('./chunk-QY4UST5V.js');
30
+ require('./chunk-KWTSMLND.js');
31
+ require('./chunk-FFKCMR6Q.js');
31
32
  require('./chunk-5FUMSWDD.js');
32
33
  require('./chunk-LYEXYTOI.js');
33
34
  require('./chunk-HZEB53A6.js');
34
35
  require('./chunk-52CALMRA.js');
35
- require('./chunk-DNVD3CHQ.js');
36
+ require('./chunk-H73GATCU.js');
36
37
  require('./chunk-NOYP2T77.js');
37
- require('./chunk-QY4UST5V.js');
38
38
  require('./chunk-V6P5JEPT.js');
39
+ require('./chunk-DT6SLUWJ.js');
39
40
  require('./chunk-TLX5QQK5.js');
40
41
  require('./chunk-IGY2S5BC.js');
41
42
 
42
43
 
43
44
 
44
- exports.NotificationServicesController = _chunkD7VP2FPRjs.NotificationServicesController_exports; exports.NotificationsServicesPushController = _chunkMT4VCZEEjs.NotificationServicesPushController_exports;
45
+ exports.NotificationServicesController = _chunkP5DZ7JHLjs.NotificationServicesController_exports; exports.NotificationsServicesPushController = _chunk2BCJRWFFjs.NotificationServicesPushController_exports;
45
46
  //# sourceMappingURL=index.js.map