@metamask-previews/notification-services-controller 10.0.0-preview-69122ec → 10.0.0-preview-53749f1

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 (136) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/NotificationServicesController/NotificationServicesController.cjs +67 -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 +68 -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/mocks/index.cjs +0 -2
  19. package/dist/NotificationServicesController/mocks/index.cjs.map +1 -1
  20. package/dist/NotificationServicesController/mocks/index.d.cts +0 -2
  21. package/dist/NotificationServicesController/mocks/index.d.cts.map +1 -1
  22. package/dist/NotificationServicesController/mocks/index.d.mts +0 -2
  23. package/dist/NotificationServicesController/mocks/index.d.mts.map +1 -1
  24. package/dist/NotificationServicesController/mocks/index.mjs +0 -2
  25. package/dist/NotificationServicesController/mocks/index.mjs.map +1 -1
  26. package/dist/NotificationServicesController/mocks/mockResponses.cjs +9 -9
  27. package/dist/NotificationServicesController/mocks/mockResponses.cjs.map +1 -1
  28. package/dist/NotificationServicesController/mocks/mockResponses.d.cts +7 -4
  29. package/dist/NotificationServicesController/mocks/mockResponses.d.cts.map +1 -1
  30. package/dist/NotificationServicesController/mocks/mockResponses.d.mts +7 -4
  31. package/dist/NotificationServicesController/mocks/mockResponses.d.mts.map +1 -1
  32. package/dist/NotificationServicesController/mocks/mockResponses.mjs +7 -7
  33. package/dist/NotificationServicesController/mocks/mockResponses.mjs.map +1 -1
  34. package/dist/NotificationServicesController/processors/process-notifications.cjs +4 -1
  35. package/dist/NotificationServicesController/processors/process-notifications.cjs.map +1 -1
  36. package/dist/NotificationServicesController/processors/process-notifications.d.cts +623 -0
  37. package/dist/NotificationServicesController/processors/process-notifications.d.cts.map +1 -1
  38. package/dist/NotificationServicesController/processors/process-notifications.d.mts +623 -0
  39. package/dist/NotificationServicesController/processors/process-notifications.d.mts.map +1 -1
  40. package/dist/NotificationServicesController/processors/process-notifications.mjs +2 -0
  41. package/dist/NotificationServicesController/processors/process-notifications.mjs.map +1 -1
  42. package/dist/NotificationServicesController/services/onchain-notifications.cjs +50 -142
  43. package/dist/NotificationServicesController/services/onchain-notifications.cjs.map +1 -1
  44. package/dist/NotificationServicesController/services/onchain-notifications.d.cts +23 -31
  45. package/dist/NotificationServicesController/services/onchain-notifications.d.cts.map +1 -1
  46. package/dist/NotificationServicesController/services/onchain-notifications.d.mts +23 -31
  47. package/dist/NotificationServicesController/services/onchain-notifications.d.mts.map +1 -1
  48. package/dist/NotificationServicesController/services/onchain-notifications.mjs +48 -139
  49. package/dist/NotificationServicesController/services/onchain-notifications.mjs.map +1 -1
  50. package/dist/NotificationServicesController/types/index.cjs.map +1 -1
  51. package/dist/NotificationServicesController/types/index.d.cts +0 -1
  52. package/dist/NotificationServicesController/types/index.d.cts.map +1 -1
  53. package/dist/NotificationServicesController/types/index.d.mts +0 -1
  54. package/dist/NotificationServicesController/types/index.d.mts.map +1 -1
  55. package/dist/NotificationServicesController/types/index.mjs.map +1 -1
  56. package/dist/NotificationServicesController/utils/utils.cjs +1 -350
  57. package/dist/NotificationServicesController/utils/utils.cjs.map +1 -1
  58. package/dist/NotificationServicesController/utils/utils.d.cts +0 -141
  59. package/dist/NotificationServicesController/utils/utils.d.cts.map +1 -1
  60. package/dist/NotificationServicesController/utils/utils.d.mts +0 -141
  61. package/dist/NotificationServicesController/utils/utils.d.mts.map +1 -1
  62. package/dist/NotificationServicesController/utils/utils.mjs +0 -337
  63. package/dist/NotificationServicesController/utils/utils.mjs.map +1 -1
  64. package/dist/NotificationServicesPushController/NotificationServicesPushController.cjs +20 -14
  65. package/dist/NotificationServicesPushController/NotificationServicesPushController.cjs.map +1 -1
  66. package/dist/NotificationServicesPushController/NotificationServicesPushController.d.cts +6 -5
  67. package/dist/NotificationServicesPushController/NotificationServicesPushController.d.cts.map +1 -1
  68. package/dist/NotificationServicesPushController/NotificationServicesPushController.d.mts +6 -5
  69. package/dist/NotificationServicesPushController/NotificationServicesPushController.d.mts.map +1 -1
  70. package/dist/NotificationServicesPushController/NotificationServicesPushController.mjs +21 -15
  71. package/dist/NotificationServicesPushController/NotificationServicesPushController.mjs.map +1 -1
  72. package/dist/NotificationServicesPushController/mocks/mockResponse.cjs +1 -16
  73. package/dist/NotificationServicesPushController/mocks/mockResponse.cjs.map +1 -1
  74. package/dist/NotificationServicesPushController/mocks/mockResponse.d.cts +0 -7
  75. package/dist/NotificationServicesPushController/mocks/mockResponse.d.cts.map +1 -1
  76. package/dist/NotificationServicesPushController/mocks/mockResponse.d.mts +0 -7
  77. package/dist/NotificationServicesPushController/mocks/mockResponse.d.mts.map +1 -1
  78. package/dist/NotificationServicesPushController/mocks/mockResponse.mjs +0 -14
  79. package/dist/NotificationServicesPushController/mocks/mockResponse.mjs.map +1 -1
  80. package/dist/NotificationServicesPushController/services/endpoints.cjs +1 -1
  81. package/dist/NotificationServicesPushController/services/endpoints.cjs.map +1 -1
  82. package/dist/NotificationServicesPushController/services/endpoints.d.cts +1 -1
  83. package/dist/NotificationServicesPushController/services/endpoints.d.cts.map +1 -1
  84. package/dist/NotificationServicesPushController/services/endpoints.d.mts +1 -1
  85. package/dist/NotificationServicesPushController/services/endpoints.d.mts.map +1 -1
  86. package/dist/NotificationServicesPushController/services/endpoints.mjs +1 -1
  87. package/dist/NotificationServicesPushController/services/endpoints.mjs.map +1 -1
  88. package/dist/NotificationServicesPushController/services/services.cjs +18 -41
  89. package/dist/NotificationServicesPushController/services/services.cjs.map +1 -1
  90. package/dist/NotificationServicesPushController/services/services.d.cts +19 -33
  91. package/dist/NotificationServicesPushController/services/services.d.cts.map +1 -1
  92. package/dist/NotificationServicesPushController/services/services.d.mts +19 -33
  93. package/dist/NotificationServicesPushController/services/services.d.mts.map +1 -1
  94. package/dist/NotificationServicesPushController/services/services.mjs +17 -39
  95. package/dist/NotificationServicesPushController/services/services.mjs.map +1 -1
  96. package/package.json +3 -3
  97. package/dist/NotificationServicesController/constants/constants.cjs +0 -7
  98. package/dist/NotificationServicesController/constants/constants.cjs.map +0 -1
  99. package/dist/NotificationServicesController/constants/constants.d.cts +0 -3
  100. package/dist/NotificationServicesController/constants/constants.d.cts.map +0 -1
  101. package/dist/NotificationServicesController/constants/constants.d.mts +0 -3
  102. package/dist/NotificationServicesController/constants/constants.d.mts.map +0 -1
  103. package/dist/NotificationServicesController/constants/constants.mjs +0 -4
  104. package/dist/NotificationServicesController/constants/constants.mjs.map +0 -1
  105. package/dist/NotificationServicesController/mocks/mock-notification-trigger.cjs +0 -22
  106. package/dist/NotificationServicesController/mocks/mock-notification-trigger.cjs.map +0 -1
  107. package/dist/NotificationServicesController/mocks/mock-notification-trigger.d.cts +0 -9
  108. package/dist/NotificationServicesController/mocks/mock-notification-trigger.d.cts.map +0 -1
  109. package/dist/NotificationServicesController/mocks/mock-notification-trigger.d.mts +0 -9
  110. package/dist/NotificationServicesController/mocks/mock-notification-trigger.d.mts.map +0 -1
  111. package/dist/NotificationServicesController/mocks/mock-notification-trigger.mjs +0 -18
  112. package/dist/NotificationServicesController/mocks/mock-notification-trigger.mjs.map +0 -1
  113. package/dist/NotificationServicesController/mocks/mock-notification-user-storage.cjs +0 -82
  114. package/dist/NotificationServicesController/mocks/mock-notification-user-storage.cjs.map +0 -1
  115. package/dist/NotificationServicesController/mocks/mock-notification-user-storage.d.cts +0 -35
  116. package/dist/NotificationServicesController/mocks/mock-notification-user-storage.d.cts.map +0 -1
  117. package/dist/NotificationServicesController/mocks/mock-notification-user-storage.d.mts +0 -35
  118. package/dist/NotificationServicesController/mocks/mock-notification-user-storage.d.mts.map +0 -1
  119. package/dist/NotificationServicesController/mocks/mock-notification-user-storage.mjs +0 -76
  120. package/dist/NotificationServicesController/mocks/mock-notification-user-storage.mjs.map +0 -1
  121. package/dist/NotificationServicesController/types/user-storage/index.cjs +0 -3
  122. package/dist/NotificationServicesController/types/user-storage/index.cjs.map +0 -1
  123. package/dist/NotificationServicesController/types/user-storage/index.d.cts +0 -2
  124. package/dist/NotificationServicesController/types/user-storage/index.d.cts.map +0 -1
  125. package/dist/NotificationServicesController/types/user-storage/index.d.mts +0 -2
  126. package/dist/NotificationServicesController/types/user-storage/index.d.mts.map +0 -1
  127. package/dist/NotificationServicesController/types/user-storage/index.mjs +0 -2
  128. package/dist/NotificationServicesController/types/user-storage/index.mjs.map +0 -1
  129. package/dist/NotificationServicesController/types/user-storage/user-storage.cjs +0 -3
  130. package/dist/NotificationServicesController/types/user-storage/user-storage.cjs.map +0 -1
  131. package/dist/NotificationServicesController/types/user-storage/user-storage.d.cts +0 -26
  132. package/dist/NotificationServicesController/types/user-storage/user-storage.d.cts.map +0 -1
  133. package/dist/NotificationServicesController/types/user-storage/user-storage.d.mts +0 -26
  134. package/dist/NotificationServicesController/types/user-storage/user-storage.d.mts.map +0 -1
  135. package/dist/NotificationServicesController/types/user-storage/user-storage.mjs +0 -2
  136. package/dist/NotificationServicesController/types/user-storage/user-storage.mjs.map +0 -1
@@ -23,31 +23,29 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.updateTriggerPushNotifications = exports.deactivatePushNotifications = exports.activatePushNotifications = exports.updateLinksAPI = void 0;
26
+ exports.deactivatePushNotifications = exports.activatePushNotifications = exports.updateLinksAPI = void 0;
27
27
  const endpoints = __importStar(require("./endpoints.cjs"));
28
28
  /**
29
29
  * Updates the push notification links on a remote API.
30
30
  *
31
- * @param bearerToken - The JSON Web Token used for authorization.
32
- * @param triggers - An array of trigger identifiers.
33
- * @param regTokens - An array of registration tokens.
31
+ * @param params - params for invoking update reg token
34
32
  * @returns A promise that resolves with true if the update was successful, false otherwise.
35
33
  */
36
- async function updateLinksAPI(bearerToken, triggers, regTokens) {
34
+ async function updateLinksAPI(params) {
37
35
  try {
38
36
  const body = {
39
- trigger_ids: triggers,
40
- registration_tokens: regTokens,
37
+ addresses: params.addresses,
38
+ registration_token: params.regToken,
41
39
  };
42
40
  const response = await fetch(endpoints.REGISTRATION_TOKENS_ENDPOINT, {
43
41
  method: 'POST',
44
42
  headers: {
45
- Authorization: `Bearer ${bearerToken}`,
43
+ Authorization: `Bearer ${params.bearerToken}`,
46
44
  'Content-Type': 'application/json',
47
45
  },
48
46
  body: JSON.stringify(body),
49
47
  });
50
- return response.status === 200;
48
+ return response.ok;
51
49
  }
52
50
  catch {
53
51
  return false;
@@ -61,14 +59,21 @@ exports.updateLinksAPI = updateLinksAPI;
61
59
  * @returns A promise that resolves with an object containing the success status and the BearerToken token.
62
60
  */
63
61
  async function activatePushNotifications(params) {
64
- const { bearerToken, triggers, env, createRegToken, platform, locale } = params;
62
+ const { env, createRegToken } = params;
65
63
  const regToken = await createRegToken(env).catch(() => null);
66
64
  if (!regToken) {
67
65
  return null;
68
66
  }
69
- await updateLinksAPI(bearerToken, triggers, [
70
- { token: regToken, platform, locale },
71
- ]);
67
+ await updateLinksAPI({
68
+ bearerToken: params.bearerToken,
69
+ addresses: params.addresses,
70
+ regToken: {
71
+ token: regToken,
72
+ platform: params.regToken.platform,
73
+ locale: params.regToken.locale,
74
+ oldToken: params.regToken.oldToken,
75
+ },
76
+ });
72
77
  return regToken;
73
78
  }
74
79
  exports.activatePushNotifications = activatePushNotifications;
@@ -92,32 +97,4 @@ async function deactivatePushNotifications(params) {
92
97
  return true;
93
98
  }
94
99
  exports.deactivatePushNotifications = deactivatePushNotifications;
95
- /**
96
- * Updates the triggers linked to push notifications for a given registration token.
97
- * If the provided registration token does not exist or is not in the current set of registration tokens,
98
- * a new registration token is created and used for the update.
99
- *
100
- * @param params - Update Push Params
101
- * @returns A promise that resolves with an object containing:
102
- * - isTriggersLinkedToPushNotifications: boolean indicating if the triggers were successfully updated.
103
- * - fcmToken: the new or existing Firebase Cloud Messaging token used for the update, if applicable.
104
- */
105
- async function updateTriggerPushNotifications(params) {
106
- const { bearerToken, triggers, createRegToken, platform, locale, deleteRegToken, env, } = params;
107
- await deleteRegToken(env);
108
- const newRegToken = await createRegToken(env);
109
- if (!newRegToken) {
110
- throw new Error('Failed to create a new registration token');
111
- }
112
- const linksNotUpdated = await updateLinksAPI(bearerToken, triggers, [
113
- { token: newRegToken, platform, locale },
114
- ]);
115
- if (!linksNotUpdated) {
116
- throw new Error('Failed to create links to new reg token');
117
- }
118
- return {
119
- fcmToken: newRegToken,
120
- };
121
- }
122
- exports.updateTriggerPushNotifications = updateTriggerPushNotifications;
123
100
  //# sourceMappingURL=services.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"services.cjs","sourceRoot":"","sources":["../../../src/NotificationServicesPushController/services/services.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2DAAyC;AAqBzC;;;;;;;GAOG;AACI,KAAK,UAAU,cAAc,CAClC,WAAmB,EACnB,QAAkB,EAClB,SAAqB;IAErB,IAAI;QACF,MAAM,IAAI,GAAgB;YACxB,WAAW,EAAE,QAAQ;YACrB,mBAAmB,EAAE,SAAS;SAC/B,CAAC;QACF,MAAM,QAAQ,GAAG,M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D,kEAgBC;AAiBD;;;;;;;;;GASG;AACI,KAAK,UAAU,8BAA8B,CAClD,MAA4C;IAI5C,MAAM,EACJ,WAAW,EACX,QAAQ,EACR,cAAc,EACd,QAAQ,EACR,MAAM,EACN,cAAc,EACd,GAAG,GACJ,GAAG,MAAM,CAAC;IAEX,MAAM,cAAc,CAAC,GAAG,CAAC,CAAC;IAC1B,MAAM,WAAW,GAAG,MAAM,cAAc,CAAC,GAAG,CAAC,CAAC;IAC9C,IAAI,CAAC,WAAW,EAAE;QAChB,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;KAC9D;IAED,MAAM,eAAe,GAAG,MAAM,cAAc,CAAC,WAAW,EAAE,QAAQ,EAAE;QAClE,EAAE,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,EAAE;KACzC,CAAC,CAAC;IACH,IAAI,CAAC,eAAe,EAAE;QACpB,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;KAC5D;IAED,OAAO;QACL,QAAQ,EAAE,WAAW;KACtB,CAAC;AACJ,CAAC;AA/BD,wEA+BC","sourcesContent":["import * as endpoints from './endpoints';\nimport type { PushNotificationEnv } from '../types';\nimport type {\n CreateRegToken,\n DeleteRegToken,\n} from '../types/push-service-interface';\n\nexport type RegToken = {\n token: string;\n platform: 'extension' | 'mobile' | 'portfolio';\n locale: string;\n};\n\n/**\n * Links API Response Shape\n */\nexport type LinksResult = {\n trigger_ids: string[];\n registration_tokens: RegToken[];\n};\n\n/**\n * Updates the push notification links on a remote API.\n *\n * @param bearerToken - The JSON Web Token used for authorization.\n * @param triggers - An array of trigger identifiers.\n * @param regTokens - An array of registration tokens.\n * @returns A promise that resolves with true if the update was successful, false otherwise.\n */\nexport async function updateLinksAPI(\n bearerToken: string,\n triggers: string[],\n regTokens: RegToken[],\n): Promise<boolean> {\n try {\n const body: LinksResult = {\n trigger_ids: triggers,\n registration_tokens: regTokens,\n };\n const response = await fetch(endpoints.REGISTRATION_TOKENS_ENDPOINT, {\n method: 'POST',\n headers: {\n Authorization: `Bearer ${bearerToken}`,\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(body),\n });\n return response.status === 200;\n } catch {\n return false;\n }\n}\n\ntype ActivatePushNotificationsParams = {\n // Push Links\n bearerToken: string;\n triggers: string[];\n\n // Push Registration\n env: PushNotificationEnv;\n createRegToken: CreateRegToken;\n platform: 'extension' | 'mobile' | 'portfolio';\n locale: string;\n};\n\n/**\n * Enables push notifications by registering the device and linking triggers.\n *\n * @param params - Activate Push Params\n * @returns A promise that resolves with an object containing the success status and the BearerToken token.\n */\nexport async function activatePushNotifications(\n params: ActivatePushNotificationsParams,\n): Promise<string | null> {\n const { bearerToken, triggers, env, createRegToken, platform, locale } =\n params;\n\n const regToken = await createRegToken(env).catch(() => null);\n if (!regToken) {\n return null;\n }\n\n await updateLinksAPI(bearerToken, triggers, [\n { token: regToken, platform, locale },\n ]);\n return regToken;\n}\n\ntype DeactivatePushNotificationsParams = {\n // Push Links\n regToken: string;\n\n // Push Un-registration\n env: PushNotificationEnv;\n deleteRegToken: DeleteRegToken;\n};\n\n/**\n * Disables push notifications by removing the registration token\n * We do not need to unlink triggers, and remove old reg tokens (this is cleaned up in the back-end)\n *\n * @param params - Deactivate Push Params\n * @returns A promise that resolves with true if push notifications were successfully disabled, false otherwise.\n */\nexport async function deactivatePushNotifications(\n params: DeactivatePushNotificationsParams,\n): Promise<boolean> {\n const { regToken, env, deleteRegToken } = params;\n\n // if we don't have a reg token, then we can early return\n if (!regToken) {\n return true;\n }\n\n const isTokenRemovedFromFCM = await deleteRegToken(env);\n if (!isTokenRemovedFromFCM) {\n return false;\n }\n\n return true;\n}\n\ntype UpdateTriggerPushNotificationsParams = {\n // Push Links\n bearerToken: string;\n triggers: string[];\n\n // Push Registration\n env: PushNotificationEnv;\n createRegToken: CreateRegToken;\n platform: 'extension' | 'mobile' | 'portfolio';\n locale: string;\n\n // Push Un-registration\n deleteRegToken: DeleteRegToken;\n};\n\n/**\n * Updates the triggers linked to push notifications for a given registration token.\n * If the provided registration token does not exist or is not in the current set of registration tokens,\n * a new registration token is created and used for the update.\n *\n * @param params - Update Push Params\n * @returns A promise that resolves with an object containing:\n * - isTriggersLinkedToPushNotifications: boolean indicating if the triggers were successfully updated.\n * - fcmToken: the new or existing Firebase Cloud Messaging token used for the update, if applicable.\n */\nexport async function updateTriggerPushNotifications(\n params: UpdateTriggerPushNotificationsParams,\n): Promise<{\n fcmToken: string;\n}> {\n const {\n bearerToken,\n triggers,\n createRegToken,\n platform,\n locale,\n deleteRegToken,\n env,\n } = params;\n\n await deleteRegToken(env);\n const newRegToken = await createRegToken(env);\n if (!newRegToken) {\n throw new Error('Failed to create a new registration token');\n }\n\n const linksNotUpdated = await updateLinksAPI(bearerToken, triggers, [\n { token: newRegToken, platform, locale },\n ]);\n if (!linksNotUpdated) {\n throw new Error('Failed to create links to new reg token');\n }\n\n return {\n fcmToken: newRegToken,\n };\n}\n"]}
1
+ {"version":3,"file":"services.cjs","sourceRoot":"","sources":["../../../src/NotificationServicesPushController/services/services.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2DAAyC;AAiCzC;;;;;GAKG;AACI,KAAK,UAAU,cAAc,CAClC,MAA6B;IAE7B,IAAI;QACF,MAAM,IAAI,GAAqB;YAC7B,SAAS,EAAE,MAAM,CAAC,SAAS;YAC3B,kBAAkB,EAAE,MAAM,CAAC,QAAQ;SACpC,CAAC;QACF,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,SAAS,CAAC,4BAA4B,EAAE;YACnE,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACP,aAAa,EAAE,UAAU,MAAM,CAAC,WAAW,EAAE;gBAC7C,cAAc,EAAE,kBAAkB;aACnC;YACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;SAC3B,CAAC,CAAC;QACH,OAAO,QAAQ,CAAC,EAAE,CAAC;KACpB;IAAC,MAAM;QACN,OAAO,KAAK,CAAC;KACd;AACH,CAAC;AApBD,wCAoBC;AAaD;;;;;GAKG;AACI,KAAK,UAAU,yBAAyB,CAC7C,MAAuC;IAEvC,MAAM,EAAE,GAAG,EAAE,cAAc,EAAE,GAAG,MAAM,CAAC;IAEvC,MAAM,QAAQ,GAAG,MAAM,cAAc,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;IAC7D,IAAI,CAAC,QAAQ,EAAE;QACb,OAAO,IAAI,CAAC;KACb;IAED,MAAM,cAAc,CAAC;QACnB,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,SAAS,EAAE,MAAM,CAAC,SAAS;QAC3B,QAAQ,EAAE;YACR,KAAK,EAAE,QAAQ;YACf,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC,QAAQ;YAClC,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM;YAC9B,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC,QAAQ;SACnC;KACF,CAAC,CAAC;IAEH,OAAO,QAAQ,CAAC;AAClB,CAAC;AAtBD,8DAsBC;AAWD;;;;;;GAMG;AACI,KAAK,UAAU,2BAA2B,CAC/C,MAAyC;IAEzC,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAE,cAAc,EAAE,GAAG,MAAM,CAAC;IAEjD,yDAAyD;IACzD,IAAI,CAAC,QAAQ,EAAE;QACb,OAAO,IAAI,CAAC;KACb;IAED,MAAM,qBAAqB,GAAG,MAAM,cAAc,CAAC,GAAG,CAAC,CAAC;IACxD,IAAI,CAAC,qBAAqB,EAAE;QAC1B,OAAO,KAAK,CAAC;KACd;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAhBD,kEAgBC","sourcesContent":["import * as endpoints from './endpoints';\nimport type { PushNotificationEnv } from '../types';\nimport type {\n CreateRegToken,\n DeleteRegToken,\n} from '../types/push-service-interface';\n\nexport type RegToken = {\n token: string;\n platform: 'extension' | 'mobile' | 'portfolio';\n locale: string;\n oldToken?: string;\n};\n\n/**\n * Links API Response Shape\n */\nexport type PushTokenRequest = {\n addresses: string[];\n registration_token: {\n token: string;\n platform: 'extension' | 'mobile' | 'portfolio';\n locale: string;\n oldToken?: string;\n };\n};\n\ntype UpdatePushTokenParams = {\n bearerToken: string;\n addresses: string[];\n regToken: RegToken;\n};\n\n/**\n * Updates the push notification links on a remote API.\n *\n * @param params - params for invoking update reg token\n * @returns A promise that resolves with true if the update was successful, false otherwise.\n */\nexport async function updateLinksAPI(\n params: UpdatePushTokenParams,\n): Promise<boolean> {\n try {\n const body: PushTokenRequest = {\n addresses: params.addresses,\n registration_token: params.regToken,\n };\n const response = await fetch(endpoints.REGISTRATION_TOKENS_ENDPOINT, {\n method: 'POST',\n headers: {\n Authorization: `Bearer ${params.bearerToken}`,\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(body),\n });\n return response.ok;\n } catch {\n return false;\n }\n}\n\ntype ActivatePushNotificationsParams = {\n // Create Push Token\n env: PushNotificationEnv;\n createRegToken: CreateRegToken;\n\n // Other Request Parameters\n bearerToken: string;\n addresses: string[];\n regToken: Pick<RegToken, 'locale' | 'platform' | 'oldToken'>;\n};\n\n/**\n * Enables push notifications by registering the device and linking triggers.\n *\n * @param params - Activate Push Params\n * @returns A promise that resolves with an object containing the success status and the BearerToken token.\n */\nexport async function activatePushNotifications(\n params: ActivatePushNotificationsParams,\n): Promise<string | null> {\n const { env, createRegToken } = params;\n\n const regToken = await createRegToken(env).catch(() => null);\n if (!regToken) {\n return null;\n }\n\n await updateLinksAPI({\n bearerToken: params.bearerToken,\n addresses: params.addresses,\n regToken: {\n token: regToken,\n platform: params.regToken.platform,\n locale: params.regToken.locale,\n oldToken: params.regToken.oldToken,\n },\n });\n\n return regToken;\n}\n\ntype DeactivatePushNotificationsParams = {\n // Push Links\n regToken: string;\n\n // Push Un-registration\n env: PushNotificationEnv;\n deleteRegToken: DeleteRegToken;\n};\n\n/**\n * Disables push notifications by removing the registration token\n * We do not need to unlink triggers, and remove old reg tokens (this is cleaned up in the back-end)\n *\n * @param params - Deactivate Push Params\n * @returns A promise that resolves with true if push notifications were successfully disabled, false otherwise.\n */\nexport async function deactivatePushNotifications(\n params: DeactivatePushNotificationsParams,\n): Promise<boolean> {\n const { regToken, env, deleteRegToken } = params;\n\n // if we don't have a reg token, then we can early return\n if (!regToken) {\n return true;\n }\n\n const isTokenRemovedFromFCM = await deleteRegToken(env);\n if (!isTokenRemovedFromFCM) {\n return false;\n }\n\n return true;\n}\n"]}
@@ -4,30 +4,38 @@ export type RegToken = {
4
4
  token: string;
5
5
  platform: 'extension' | 'mobile' | 'portfolio';
6
6
  locale: string;
7
+ oldToken?: string;
7
8
  };
8
9
  /**
9
10
  * Links API Response Shape
10
11
  */
11
- export type LinksResult = {
12
- trigger_ids: string[];
13
- registration_tokens: RegToken[];
12
+ export type PushTokenRequest = {
13
+ addresses: string[];
14
+ registration_token: {
15
+ token: string;
16
+ platform: 'extension' | 'mobile' | 'portfolio';
17
+ locale: string;
18
+ oldToken?: string;
19
+ };
20
+ };
21
+ type UpdatePushTokenParams = {
22
+ bearerToken: string;
23
+ addresses: string[];
24
+ regToken: RegToken;
14
25
  };
15
26
  /**
16
27
  * Updates the push notification links on a remote API.
17
28
  *
18
- * @param bearerToken - The JSON Web Token used for authorization.
19
- * @param triggers - An array of trigger identifiers.
20
- * @param regTokens - An array of registration tokens.
29
+ * @param params - params for invoking update reg token
21
30
  * @returns A promise that resolves with true if the update was successful, false otherwise.
22
31
  */
23
- export declare function updateLinksAPI(bearerToken: string, triggers: string[], regTokens: RegToken[]): Promise<boolean>;
32
+ export declare function updateLinksAPI(params: UpdatePushTokenParams): Promise<boolean>;
24
33
  type ActivatePushNotificationsParams = {
25
- bearerToken: string;
26
- triggers: string[];
27
34
  env: PushNotificationEnv;
28
35
  createRegToken: CreateRegToken;
29
- platform: 'extension' | 'mobile' | 'portfolio';
30
- locale: string;
36
+ bearerToken: string;
37
+ addresses: string[];
38
+ regToken: Pick<RegToken, 'locale' | 'platform' | 'oldToken'>;
31
39
  };
32
40
  /**
33
41
  * Enables push notifications by registering the device and linking triggers.
@@ -49,27 +57,5 @@ type DeactivatePushNotificationsParams = {
49
57
  * @returns A promise that resolves with true if push notifications were successfully disabled, false otherwise.
50
58
  */
51
59
  export declare function deactivatePushNotifications(params: DeactivatePushNotificationsParams): Promise<boolean>;
52
- type UpdateTriggerPushNotificationsParams = {
53
- bearerToken: string;
54
- triggers: string[];
55
- env: PushNotificationEnv;
56
- createRegToken: CreateRegToken;
57
- platform: 'extension' | 'mobile' | 'portfolio';
58
- locale: string;
59
- deleteRegToken: DeleteRegToken;
60
- };
61
- /**
62
- * Updates the triggers linked to push notifications for a given registration token.
63
- * If the provided registration token does not exist or is not in the current set of registration tokens,
64
- * a new registration token is created and used for the update.
65
- *
66
- * @param params - Update Push Params
67
- * @returns A promise that resolves with an object containing:
68
- * - isTriggersLinkedToPushNotifications: boolean indicating if the triggers were successfully updated.
69
- * - fcmToken: the new or existing Firebase Cloud Messaging token used for the update, if applicable.
70
- */
71
- export declare function updateTriggerPushNotifications(params: UpdateTriggerPushNotificationsParams): Promise<{
72
- fcmToken: string;
73
- }>;
74
60
  export {};
75
61
  //# sourceMappingURL=services.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"services.d.cts","sourceRoot":"","sources":["../../../src/NotificationServicesPushController/services/services.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,2BAAiB;AACpD,OAAO,KAAK,EACV,cAAc,EACd,cAAc,EACf,4CAAwC;AAEzC,MAAM,MAAM,QAAQ,GAAG;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,WAAW,GAAG,QAAQ,GAAG,WAAW,CAAC;IAC/C,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,WAAW,EAAE,MAAM,EAAE,CAAC;IAC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ClB,CAAC,CA2BD"}
1
+ {"version":3,"file":"services.d.cts","sourceRoot":"","sources":["../../../src/NotificationServicesPushController/services/services.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,2BAAiB;AACpD,OAAO,KAAK,EACV,cAAc,EACd,cAAc,EACf,4CAAwC;AAEzC,MAAM,MAAM,QAAQ,GAAG;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,WAAW,GAAG,QAAQ,GAAG,WAAW,CAAC;IAC/C,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,kBAAkB,EAAE;QAClB,KAAK,EAAE,MAAM,CAAC;QACd,QAAQ,EAAE,WAAW,GAAG,QAAQ,GAAG,WAAW,CAAC;QAC/C,MAAM,EAAE,MAAM,CAAC;QACf,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,CAAC;CACH,CAAC;AAEF,KAAK,qBAAqB,GAAG;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,QAAQ,EAAE,QAAQ,CAAC;CACpB,CAAC;AAEF;;;;;GAKG;AACH,wBAAsB,cAAc,CAClC,MAAM,EAAE,qBAAqB,GAC5B,OAAO,CAAC,OAAO,CAAC,CAkBlB;AAED,KAAK,+BAA+B,GAAG;IAErC,GAAG,EAAE,mBAAmB,CAAC;IACzB,cAAc,EAAE,cAAc,CAAC;IAG/B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,QAAQ,GAAG,UAAU,GAAG,UAAU,CAAC,CAAC;CAC9D,CAAC;AAEF;;;;;GAKG;AACH,wBAAsB,yBAAyB,CAC7C,MAAM,EAAE,+BAA+B,GACtC,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAoBxB;AAED,KAAK,iCAAiC,GAAG;IAEvC,QAAQ,EAAE,MAAM,CAAC;IAGjB,GAAG,EAAE,mBAAmB,CAAC;IACzB,cAAc,EAAE,cAAc,CAAC;CAChC,CAAC;AAEF;;;;;;GAMG;AACH,wBAAsB,2BAA2B,CAC/C,MAAM,EAAE,iCAAiC,GACxC,OAAO,CAAC,OAAO,CAAC,CAclB"}
@@ -4,30 +4,38 @@ export type RegToken = {
4
4
  token: string;
5
5
  platform: 'extension' | 'mobile' | 'portfolio';
6
6
  locale: string;
7
+ oldToken?: string;
7
8
  };
8
9
  /**
9
10
  * Links API Response Shape
10
11
  */
11
- export type LinksResult = {
12
- trigger_ids: string[];
13
- registration_tokens: RegToken[];
12
+ export type PushTokenRequest = {
13
+ addresses: string[];
14
+ registration_token: {
15
+ token: string;
16
+ platform: 'extension' | 'mobile' | 'portfolio';
17
+ locale: string;
18
+ oldToken?: string;
19
+ };
20
+ };
21
+ type UpdatePushTokenParams = {
22
+ bearerToken: string;
23
+ addresses: string[];
24
+ regToken: RegToken;
14
25
  };
15
26
  /**
16
27
  * Updates the push notification links on a remote API.
17
28
  *
18
- * @param bearerToken - The JSON Web Token used for authorization.
19
- * @param triggers - An array of trigger identifiers.
20
- * @param regTokens - An array of registration tokens.
29
+ * @param params - params for invoking update reg token
21
30
  * @returns A promise that resolves with true if the update was successful, false otherwise.
22
31
  */
23
- export declare function updateLinksAPI(bearerToken: string, triggers: string[], regTokens: RegToken[]): Promise<boolean>;
32
+ export declare function updateLinksAPI(params: UpdatePushTokenParams): Promise<boolean>;
24
33
  type ActivatePushNotificationsParams = {
25
- bearerToken: string;
26
- triggers: string[];
27
34
  env: PushNotificationEnv;
28
35
  createRegToken: CreateRegToken;
29
- platform: 'extension' | 'mobile' | 'portfolio';
30
- locale: string;
36
+ bearerToken: string;
37
+ addresses: string[];
38
+ regToken: Pick<RegToken, 'locale' | 'platform' | 'oldToken'>;
31
39
  };
32
40
  /**
33
41
  * Enables push notifications by registering the device and linking triggers.
@@ -49,27 +57,5 @@ type DeactivatePushNotificationsParams = {
49
57
  * @returns A promise that resolves with true if push notifications were successfully disabled, false otherwise.
50
58
  */
51
59
  export declare function deactivatePushNotifications(params: DeactivatePushNotificationsParams): Promise<boolean>;
52
- type UpdateTriggerPushNotificationsParams = {
53
- bearerToken: string;
54
- triggers: string[];
55
- env: PushNotificationEnv;
56
- createRegToken: CreateRegToken;
57
- platform: 'extension' | 'mobile' | 'portfolio';
58
- locale: string;
59
- deleteRegToken: DeleteRegToken;
60
- };
61
- /**
62
- * Updates the triggers linked to push notifications for a given registration token.
63
- * If the provided registration token does not exist or is not in the current set of registration tokens,
64
- * a new registration token is created and used for the update.
65
- *
66
- * @param params - Update Push Params
67
- * @returns A promise that resolves with an object containing:
68
- * - isTriggersLinkedToPushNotifications: boolean indicating if the triggers were successfully updated.
69
- * - fcmToken: the new or existing Firebase Cloud Messaging token used for the update, if applicable.
70
- */
71
- export declare function updateTriggerPushNotifications(params: UpdateTriggerPushNotificationsParams): Promise<{
72
- fcmToken: string;
73
- }>;
74
60
  export {};
75
61
  //# sourceMappingURL=services.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"services.d.mts","sourceRoot":"","sources":["../../../src/NotificationServicesPushController/services/services.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,2BAAiB;AACpD,OAAO,KAAK,EACV,cAAc,EACd,cAAc,EACf,4CAAwC;AAEzC,MAAM,MAAM,QAAQ,GAAG;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,WAAW,GAAG,QAAQ,GAAG,WAAW,CAAC;IAC/C,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,mBAAmB,EAAE,QAAQ,EAAE,CAAC;CACjC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,CAAC,CAoBxB;AAED,KAAK,iCAAiC,GAAG;IAEvC,QAAQ,EAAE,MAAM,CAAC;IAGjB,GAAG,EAAE,mBAAmB,CAAC;IACzB,cAAc,EAAE,cAAc,CAAC;CAChC,CAAC;AAEF;;;;;;GAMG;AACH,wBAAsB,2BAA2B,CAC/C,MAAM,EAAE,iCAAiC,GACxC,OAAO,CAAC,OAAO,CAAC,CAclB"}
@@ -2,26 +2,24 @@ import * as endpoints from "./endpoints.mjs";
2
2
  /**
3
3
  * Updates the push notification links on a remote API.
4
4
  *
5
- * @param bearerToken - The JSON Web Token used for authorization.
6
- * @param triggers - An array of trigger identifiers.
7
- * @param regTokens - An array of registration tokens.
5
+ * @param params - params for invoking update reg token
8
6
  * @returns A promise that resolves with true if the update was successful, false otherwise.
9
7
  */
10
- export async function updateLinksAPI(bearerToken, triggers, regTokens) {
8
+ export async function updateLinksAPI(params) {
11
9
  try {
12
10
  const body = {
13
- trigger_ids: triggers,
14
- registration_tokens: regTokens,
11
+ addresses: params.addresses,
12
+ registration_token: params.regToken,
15
13
  };
16
14
  const response = await fetch(endpoints.REGISTRATION_TOKENS_ENDPOINT, {
17
15
  method: 'POST',
18
16
  headers: {
19
- Authorization: `Bearer ${bearerToken}`,
17
+ Authorization: `Bearer ${params.bearerToken}`,
20
18
  'Content-Type': 'application/json',
21
19
  },
22
20
  body: JSON.stringify(body),
23
21
  });
24
- return response.status === 200;
22
+ return response.ok;
25
23
  }
26
24
  catch {
27
25
  return false;
@@ -34,14 +32,21 @@ export async function updateLinksAPI(bearerToken, triggers, regTokens) {
34
32
  * @returns A promise that resolves with an object containing the success status and the BearerToken token.
35
33
  */
36
34
  export async function activatePushNotifications(params) {
37
- const { bearerToken, triggers, env, createRegToken, platform, locale } = params;
35
+ const { env, createRegToken } = params;
38
36
  const regToken = await createRegToken(env).catch(() => null);
39
37
  if (!regToken) {
40
38
  return null;
41
39
  }
42
- await updateLinksAPI(bearerToken, triggers, [
43
- { token: regToken, platform, locale },
44
- ]);
40
+ await updateLinksAPI({
41
+ bearerToken: params.bearerToken,
42
+ addresses: params.addresses,
43
+ regToken: {
44
+ token: regToken,
45
+ platform: params.regToken.platform,
46
+ locale: params.regToken.locale,
47
+ oldToken: params.regToken.oldToken,
48
+ },
49
+ });
45
50
  return regToken;
46
51
  }
47
52
  /**
@@ -63,31 +68,4 @@ export async function deactivatePushNotifications(params) {
63
68
  }
64
69
  return true;
65
70
  }
66
- /**
67
- * Updates the triggers linked to push notifications for a given registration token.
68
- * If the provided registration token does not exist or is not in the current set of registration tokens,
69
- * a new registration token is created and used for the update.
70
- *
71
- * @param params - Update Push Params
72
- * @returns A promise that resolves with an object containing:
73
- * - isTriggersLinkedToPushNotifications: boolean indicating if the triggers were successfully updated.
74
- * - fcmToken: the new or existing Firebase Cloud Messaging token used for the update, if applicable.
75
- */
76
- export async function updateTriggerPushNotifications(params) {
77
- const { bearerToken, triggers, createRegToken, platform, locale, deleteRegToken, env, } = params;
78
- await deleteRegToken(env);
79
- const newRegToken = await createRegToken(env);
80
- if (!newRegToken) {
81
- throw new Error('Failed to create a new registration token');
82
- }
83
- const linksNotUpdated = await updateLinksAPI(bearerToken, triggers, [
84
- { token: newRegToken, platform, locale },
85
- ]);
86
- if (!linksNotUpdated) {
87
- throw new Error('Failed to create links to new reg token');
88
- }
89
- return {
90
- fcmToken: newRegToken,
91
- };
92
- }
93
71
  //# sourceMappingURL=services.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"services.mjs","sourceRoot":"","sources":["../../../src/NotificationServicesPushController/services/services.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,wBAAoB;AAqBzC;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,WAAmB,EACnB,QAAkB,EAClB,SAAqB;IAErB,IAAI;QACF,MAAM,IAAI,GAAgB;YACxB,WAAW,EAAE,QAAQ;YACrB,mBAAmB,EAAE,SAAS;SAC/B,CAAC;QACF,MAAM,QAAQ,GAAG,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;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,8BAA8B,CAClD,MAA4C;IAI5C,MAAM,EACJ,WAAW,EACX,QAAQ,EACR,cAAc,EACd,QAAQ,EACR,MAAM,EACN,cAAc,EACd,GAAG,GACJ,GAAG,MAAM,CAAC;IAEX,MAAM,cAAc,CAAC,GAAG,CAAC,CAAC;IAC1B,MAAM,WAAW,GAAG,MAAM,cAAc,CAAC,GAAG,CAAC,CAAC;IAC9C,IAAI,CAAC,WAAW,EAAE;QAChB,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;KAC9D;IAED,MAAM,eAAe,GAAG,MAAM,cAAc,CAAC,WAAW,EAAE,QAAQ,EAAE;QAClE,EAAE,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,EAAE;KACzC,CAAC,CAAC;IACH,IAAI,CAAC,eAAe,EAAE;QACpB,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;KAC5D;IAED,OAAO;QACL,QAAQ,EAAE,WAAW;KACtB,CAAC;AACJ,CAAC","sourcesContent":["import * as endpoints from './endpoints';\nimport type { PushNotificationEnv } from '../types';\nimport type {\n CreateRegToken,\n DeleteRegToken,\n} from '../types/push-service-interface';\n\nexport type RegToken = {\n token: string;\n platform: 'extension' | 'mobile' | 'portfolio';\n locale: string;\n};\n\n/**\n * Links API Response Shape\n */\nexport type LinksResult = {\n trigger_ids: string[];\n registration_tokens: RegToken[];\n};\n\n/**\n * Updates the push notification links on a remote API.\n *\n * @param bearerToken - The JSON Web Token used for authorization.\n * @param triggers - An array of trigger identifiers.\n * @param regTokens - An array of registration tokens.\n * @returns A promise that resolves with true if the update was successful, false otherwise.\n */\nexport async function updateLinksAPI(\n bearerToken: string,\n triggers: string[],\n regTokens: RegToken[],\n): Promise<boolean> {\n try {\n const body: LinksResult = {\n trigger_ids: triggers,\n registration_tokens: regTokens,\n };\n const response = await fetch(endpoints.REGISTRATION_TOKENS_ENDPOINT, {\n method: 'POST',\n headers: {\n Authorization: `Bearer ${bearerToken}`,\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(body),\n });\n return response.status === 200;\n } catch {\n return false;\n }\n}\n\ntype ActivatePushNotificationsParams = {\n // Push Links\n bearerToken: string;\n triggers: string[];\n\n // Push Registration\n env: PushNotificationEnv;\n createRegToken: CreateRegToken;\n platform: 'extension' | 'mobile' | 'portfolio';\n locale: string;\n};\n\n/**\n * Enables push notifications by registering the device and linking triggers.\n *\n * @param params - Activate Push Params\n * @returns A promise that resolves with an object containing the success status and the BearerToken token.\n */\nexport async function activatePushNotifications(\n params: ActivatePushNotificationsParams,\n): Promise<string | null> {\n const { bearerToken, triggers, env, createRegToken, platform, locale } =\n params;\n\n const regToken = await createRegToken(env).catch(() => null);\n if (!regToken) {\n return null;\n }\n\n await updateLinksAPI(bearerToken, triggers, [\n { token: regToken, platform, locale },\n ]);\n return regToken;\n}\n\ntype DeactivatePushNotificationsParams = {\n // Push Links\n regToken: string;\n\n // Push Un-registration\n env: PushNotificationEnv;\n deleteRegToken: DeleteRegToken;\n};\n\n/**\n * Disables push notifications by removing the registration token\n * We do not need to unlink triggers, and remove old reg tokens (this is cleaned up in the back-end)\n *\n * @param params - Deactivate Push Params\n * @returns A promise that resolves with true if push notifications were successfully disabled, false otherwise.\n */\nexport async function deactivatePushNotifications(\n params: DeactivatePushNotificationsParams,\n): Promise<boolean> {\n const { regToken, env, deleteRegToken } = params;\n\n // if we don't have a reg token, then we can early return\n if (!regToken) {\n return true;\n }\n\n const isTokenRemovedFromFCM = await deleteRegToken(env);\n if (!isTokenRemovedFromFCM) {\n return false;\n }\n\n return true;\n}\n\ntype UpdateTriggerPushNotificationsParams = {\n // Push Links\n bearerToken: string;\n triggers: string[];\n\n // Push Registration\n env: PushNotificationEnv;\n createRegToken: CreateRegToken;\n platform: 'extension' | 'mobile' | 'portfolio';\n locale: string;\n\n // Push Un-registration\n deleteRegToken: DeleteRegToken;\n};\n\n/**\n * Updates the triggers linked to push notifications for a given registration token.\n * If the provided registration token does not exist or is not in the current set of registration tokens,\n * a new registration token is created and used for the update.\n *\n * @param params - Update Push Params\n * @returns A promise that resolves with an object containing:\n * - isTriggersLinkedToPushNotifications: boolean indicating if the triggers were successfully updated.\n * - fcmToken: the new or existing Firebase Cloud Messaging token used for the update, if applicable.\n */\nexport async function updateTriggerPushNotifications(\n params: UpdateTriggerPushNotificationsParams,\n): Promise<{\n fcmToken: string;\n}> {\n const {\n bearerToken,\n triggers,\n createRegToken,\n platform,\n locale,\n deleteRegToken,\n env,\n } = params;\n\n await deleteRegToken(env);\n const newRegToken = await createRegToken(env);\n if (!newRegToken) {\n throw new Error('Failed to create a new registration token');\n }\n\n const linksNotUpdated = await updateLinksAPI(bearerToken, triggers, [\n { token: newRegToken, platform, locale },\n ]);\n if (!linksNotUpdated) {\n throw new Error('Failed to create links to new reg token');\n }\n\n return {\n fcmToken: newRegToken,\n };\n}\n"]}
1
+ {"version":3,"file":"services.mjs","sourceRoot":"","sources":["../../../src/NotificationServicesPushController/services/services.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,wBAAoB;AAiCzC;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,MAA6B;IAE7B,IAAI;QACF,MAAM,IAAI,GAAqB;YAC7B,SAAS,EAAE,MAAM,CAAC,SAAS;YAC3B,kBAAkB,EAAE,MAAM,CAAC,QAAQ;SACpC,CAAC;QACF,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,SAAS,CAAC,4BAA4B,EAAE;YACnE,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACP,aAAa,EAAE,UAAU,MAAM,CAAC,WAAW,EAAE;gBAC7C,cAAc,EAAE,kBAAkB;aACnC;YACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;SAC3B,CAAC,CAAC;QACH,OAAO,QAAQ,CAAC,EAAE,CAAC;KACpB;IAAC,MAAM;QACN,OAAO,KAAK,CAAC;KACd;AACH,CAAC;AAaD;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAC7C,MAAuC;IAEvC,MAAM,EAAE,GAAG,EAAE,cAAc,EAAE,GAAG,MAAM,CAAC;IAEvC,MAAM,QAAQ,GAAG,MAAM,cAAc,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;IAC7D,IAAI,CAAC,QAAQ,EAAE;QACb,OAAO,IAAI,CAAC;KACb;IAED,MAAM,cAAc,CAAC;QACnB,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,SAAS,EAAE,MAAM,CAAC,SAAS;QAC3B,QAAQ,EAAE;YACR,KAAK,EAAE,QAAQ;YACf,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC,QAAQ;YAClC,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM;YAC9B,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC,QAAQ;SACnC;KACF,CAAC,CAAC;IAEH,OAAO,QAAQ,CAAC;AAClB,CAAC;AAWD;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAC/C,MAAyC;IAEzC,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAE,cAAc,EAAE,GAAG,MAAM,CAAC;IAEjD,yDAAyD;IACzD,IAAI,CAAC,QAAQ,EAAE;QACb,OAAO,IAAI,CAAC;KACb;IAED,MAAM,qBAAqB,GAAG,MAAM,cAAc,CAAC,GAAG,CAAC,CAAC;IACxD,IAAI,CAAC,qBAAqB,EAAE;QAC1B,OAAO,KAAK,CAAC;KACd;IAED,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import * as endpoints from './endpoints';\nimport type { PushNotificationEnv } from '../types';\nimport type {\n CreateRegToken,\n DeleteRegToken,\n} from '../types/push-service-interface';\n\nexport type RegToken = {\n token: string;\n platform: 'extension' | 'mobile' | 'portfolio';\n locale: string;\n oldToken?: string;\n};\n\n/**\n * Links API Response Shape\n */\nexport type PushTokenRequest = {\n addresses: string[];\n registration_token: {\n token: string;\n platform: 'extension' | 'mobile' | 'portfolio';\n locale: string;\n oldToken?: string;\n };\n};\n\ntype UpdatePushTokenParams = {\n bearerToken: string;\n addresses: string[];\n regToken: RegToken;\n};\n\n/**\n * Updates the push notification links on a remote API.\n *\n * @param params - params for invoking update reg token\n * @returns A promise that resolves with true if the update was successful, false otherwise.\n */\nexport async function updateLinksAPI(\n params: UpdatePushTokenParams,\n): Promise<boolean> {\n try {\n const body: PushTokenRequest = {\n addresses: params.addresses,\n registration_token: params.regToken,\n };\n const response = await fetch(endpoints.REGISTRATION_TOKENS_ENDPOINT, {\n method: 'POST',\n headers: {\n Authorization: `Bearer ${params.bearerToken}`,\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(body),\n });\n return response.ok;\n } catch {\n return false;\n }\n}\n\ntype ActivatePushNotificationsParams = {\n // Create Push Token\n env: PushNotificationEnv;\n createRegToken: CreateRegToken;\n\n // Other Request Parameters\n bearerToken: string;\n addresses: string[];\n regToken: Pick<RegToken, 'locale' | 'platform' | 'oldToken'>;\n};\n\n/**\n * Enables push notifications by registering the device and linking triggers.\n *\n * @param params - Activate Push Params\n * @returns A promise that resolves with an object containing the success status and the BearerToken token.\n */\nexport async function activatePushNotifications(\n params: ActivatePushNotificationsParams,\n): Promise<string | null> {\n const { env, createRegToken } = params;\n\n const regToken = await createRegToken(env).catch(() => null);\n if (!regToken) {\n return null;\n }\n\n await updateLinksAPI({\n bearerToken: params.bearerToken,\n addresses: params.addresses,\n regToken: {\n token: regToken,\n platform: params.regToken.platform,\n locale: params.regToken.locale,\n oldToken: params.regToken.oldToken,\n },\n });\n\n return regToken;\n}\n\ntype DeactivatePushNotificationsParams = {\n // Push Links\n regToken: string;\n\n // Push Un-registration\n env: PushNotificationEnv;\n deleteRegToken: DeleteRegToken;\n};\n\n/**\n * Disables push notifications by removing the registration token\n * We do not need to unlink triggers, and remove old reg tokens (this is cleaned up in the back-end)\n *\n * @param params - Deactivate Push Params\n * @returns A promise that resolves with true if push notifications were successfully disabled, false otherwise.\n */\nexport async function deactivatePushNotifications(\n params: DeactivatePushNotificationsParams,\n): Promise<boolean> {\n const { regToken, env, deleteRegToken } = params;\n\n // if we don't have a reg token, then we can early return\n if (!regToken) {\n return true;\n }\n\n const isTokenRemovedFromFCM = await deleteRegToken(env);\n if (!isTokenRemovedFromFCM) {\n return false;\n }\n\n return true;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask-previews/notification-services-controller",
3
- "version": "10.0.0-preview-69122ec",
3
+ "version": "10.0.0-preview-53749f1",
4
4
  "description": "Manages New MetaMask decentralized Notification system",
5
5
  "keywords": [
6
6
  "MetaMask",
@@ -111,7 +111,7 @@
111
111
  "dependencies": {
112
112
  "@contentful/rich-text-html-renderer": "^16.5.2",
113
113
  "@metamask/base-controller": "^8.0.1",
114
- "@metamask/controller-utils": "^11.9.0",
114
+ "@metamask/controller-utils": "^11.10.0",
115
115
  "@metamask/utils": "^11.2.0",
116
116
  "bignumber.js": "^9.1.2",
117
117
  "firebase": "^11.2.0",
@@ -122,7 +122,7 @@
122
122
  "@lavamoat/allow-scripts": "^3.0.4",
123
123
  "@lavamoat/preinstall-always-fail": "^2.1.0",
124
124
  "@metamask/auto-changelog": "^3.4.4",
125
- "@metamask/keyring-controller": "^22.0.1",
125
+ "@metamask/keyring-controller": "^22.0.2",
126
126
  "@metamask/profile-sync-controller": "^17.0.0",
127
127
  "@types/jest": "^27.4.1",
128
128
  "@types/readable-stream": "^2.3.0",
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.USER_STORAGE_VERSION_KEY = exports.USER_STORAGE_VERSION = void 0;
4
- exports.USER_STORAGE_VERSION = '1';
5
- // Force cast. We don't really care about the type here since we treat it as a unique symbol
6
- exports.USER_STORAGE_VERSION_KEY = 'v';
7
- //# sourceMappingURL=constants.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.cjs","sourceRoot":"","sources":["../../../src/NotificationServicesController/constants/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,oBAAoB,GAAG,GAAG,CAAC;AAExC,4FAA4F;AAC/E,QAAA,wBAAwB,GAAkB,GAAY,CAAC","sourcesContent":["export const USER_STORAGE_VERSION = '1';\n\n// Force cast. We don't really care about the type here since we treat it as a unique symbol\nexport const USER_STORAGE_VERSION_KEY: unique symbol = 'v' as never;\n"]}
@@ -1,3 +0,0 @@
1
- export declare const USER_STORAGE_VERSION = "1";
2
- export declare const USER_STORAGE_VERSION_KEY: unique symbol;
3
- //# sourceMappingURL=constants.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.d.cts","sourceRoot":"","sources":["../../../src/NotificationServicesController/constants/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB,MAAM,CAAC;AAGxC,eAAO,MAAM,wBAAwB,EAAE,OAAO,MAAqB,CAAC"}
@@ -1,3 +0,0 @@
1
- export declare const USER_STORAGE_VERSION = "1";
2
- export declare const USER_STORAGE_VERSION_KEY: unique symbol;
3
- //# sourceMappingURL=constants.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.d.mts","sourceRoot":"","sources":["../../../src/NotificationServicesController/constants/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB,MAAM,CAAC;AAGxC,eAAO,MAAM,wBAAwB,EAAE,OAAO,MAAqB,CAAC"}
@@ -1,4 +0,0 @@
1
- export const USER_STORAGE_VERSION = '1';
2
- // Force cast. We don't really care about the type here since we treat it as a unique symbol
3
- export const USER_STORAGE_VERSION_KEY = 'v';
4
- //# sourceMappingURL=constants.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.mjs","sourceRoot":"","sources":["../../../src/NotificationServicesController/constants/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAG,CAAC;AAExC,4FAA4F;AAC5F,MAAM,CAAC,MAAM,wBAAwB,GAAkB,GAAY,CAAC","sourcesContent":["export const USER_STORAGE_VERSION = '1';\n\n// Force cast. We don't really care about the type here since we treat it as a unique symbol\nexport const USER_STORAGE_VERSION_KEY: unique symbol = 'v' as never;\n"]}
@@ -1,22 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createMockNotificationTrigger = void 0;
4
- const uuid_1 = require("uuid");
5
- /**
6
- * Mocking Utility - create a mock Notification Trigger
7
- *
8
- * @param override - provide any override configuration for the mock
9
- * @returns a mock Notification Trigger
10
- */
11
- function createMockNotificationTrigger(override) {
12
- return {
13
- id: (0, uuid_1.v4)(),
14
- address: '0xFAKE_ADDRESS',
15
- chainId: '1',
16
- kind: 'eth_sent',
17
- enabled: true,
18
- ...override,
19
- };
20
- }
21
- exports.createMockNotificationTrigger = createMockNotificationTrigger;
22
- //# sourceMappingURL=mock-notification-trigger.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mock-notification-trigger.cjs","sourceRoot":"","sources":["../../../src/NotificationServicesController/mocks/mock-notification-trigger.ts"],"names":[],"mappings":";;;AAAA,+BAAoC;AAIpC;;;;;GAKG;AACH,SAAgB,6BAA6B,CAC3C,QAAuC;IAEvC,OAAO;QACL,EAAE,EAAE,IAAA,SAAM,GAAE;QACZ,OAAO,EAAE,gBAAgB;QACzB,OAAO,EAAE,GAAG;QACZ,IAAI,EAAE,UAAU;QAChB,OAAO,EAAE,IAAI;QACb,GAAG,QAAQ;KACZ,CAAC;AACJ,CAAC;AAXD,sEAWC","sourcesContent":["import { v4 as uuidv4 } from 'uuid';\n\nimport type { NotificationTrigger } from '../utils/utils';\n\n/**\n * Mocking Utility - create a mock Notification Trigger\n *\n * @param override - provide any override configuration for the mock\n * @returns a mock Notification Trigger\n */\nexport function createMockNotificationTrigger(\n override?: Partial<NotificationTrigger>,\n): NotificationTrigger {\n return {\n id: uuidv4(),\n address: '0xFAKE_ADDRESS',\n chainId: '1',\n kind: 'eth_sent',\n enabled: true,\n ...override,\n };\n}\n"]}
@@ -1,9 +0,0 @@
1
- import type { NotificationTrigger } from "../utils/utils.cjs";
2
- /**
3
- * Mocking Utility - create a mock Notification Trigger
4
- *
5
- * @param override - provide any override configuration for the mock
6
- * @returns a mock Notification Trigger
7
- */
8
- export declare function createMockNotificationTrigger(override?: Partial<NotificationTrigger>): NotificationTrigger;
9
- //# sourceMappingURL=mock-notification-trigger.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mock-notification-trigger.d.cts","sourceRoot":"","sources":["../../../src/NotificationServicesController/mocks/mock-notification-trigger.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,2BAAuB;AAE1D;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAC3C,QAAQ,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,GACtC,mBAAmB,CASrB"}
@@ -1,9 +0,0 @@
1
- import type { NotificationTrigger } from "../utils/utils.mjs";
2
- /**
3
- * Mocking Utility - create a mock Notification Trigger
4
- *
5
- * @param override - provide any override configuration for the mock
6
- * @returns a mock Notification Trigger
7
- */
8
- export declare function createMockNotificationTrigger(override?: Partial<NotificationTrigger>): NotificationTrigger;
9
- //# sourceMappingURL=mock-notification-trigger.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mock-notification-trigger.d.mts","sourceRoot":"","sources":["../../../src/NotificationServicesController/mocks/mock-notification-trigger.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,2BAAuB;AAE1D;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAC3C,QAAQ,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,GACtC,mBAAmB,CASrB"}
@@ -1,18 +0,0 @@
1
- import { v4 as uuidv4 } from "uuid";
2
- /**
3
- * Mocking Utility - create a mock Notification Trigger
4
- *
5
- * @param override - provide any override configuration for the mock
6
- * @returns a mock Notification Trigger
7
- */
8
- export function createMockNotificationTrigger(override) {
9
- return {
10
- id: uuidv4(),
11
- address: '0xFAKE_ADDRESS',
12
- chainId: '1',
13
- kind: 'eth_sent',
14
- enabled: true,
15
- ...override,
16
- };
17
- }
18
- //# sourceMappingURL=mock-notification-trigger.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mock-notification-trigger.mjs","sourceRoot":"","sources":["../../../src/NotificationServicesController/mocks/mock-notification-trigger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,aAAa;AAIpC;;;;;GAKG;AACH,MAAM,UAAU,6BAA6B,CAC3C,QAAuC;IAEvC,OAAO;QACL,EAAE,EAAE,MAAM,EAAE;QACZ,OAAO,EAAE,gBAAgB;QACzB,OAAO,EAAE,GAAG;QACZ,IAAI,EAAE,UAAU;QAChB,OAAO,EAAE,IAAI;QACb,GAAG,QAAQ;KACZ,CAAC;AACJ,CAAC","sourcesContent":["import { v4 as uuidv4 } from 'uuid';\n\nimport type { NotificationTrigger } from '../utils/utils';\n\n/**\n * Mocking Utility - create a mock Notification Trigger\n *\n * @param override - provide any override configuration for the mock\n * @returns a mock Notification Trigger\n */\nexport function createMockNotificationTrigger(\n override?: Partial<NotificationTrigger>,\n): NotificationTrigger {\n return {\n id: uuidv4(),\n address: '0xFAKE_ADDRESS',\n chainId: '1',\n kind: 'eth_sent',\n enabled: true,\n ...override,\n };\n}\n"]}