@metamask-previews/notification-services-controller 0.1.0-preview-509f7952 → 0.1.0-preview-129e011c

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 (50) hide show
  1. package/dist/NotificationServicesController/NotificationServicesController.js +2 -2
  2. package/dist/NotificationServicesController/NotificationServicesController.mjs +1 -1
  3. package/dist/NotificationServicesController/index.js +3 -3
  4. package/dist/NotificationServicesController/index.mjs +2 -2
  5. package/dist/NotificationServicesPushController/NotificationServicesPushController.js +6 -6
  6. package/dist/NotificationServicesPushController/NotificationServicesPushController.mjs +5 -5
  7. package/dist/NotificationServicesPushController/index.js +7 -7
  8. package/dist/NotificationServicesPushController/index.mjs +6 -6
  9. package/dist/NotificationServicesPushController/services/push/push-web.js +4 -4
  10. package/dist/NotificationServicesPushController/services/push/push-web.mjs +3 -3
  11. package/dist/NotificationServicesPushController/services/services.js +5 -5
  12. package/dist/NotificationServicesPushController/services/services.mjs +4 -4
  13. package/dist/NotificationServicesPushController/utils/get-notification-message.js +2 -2
  14. package/dist/NotificationServicesPushController/utils/get-notification-message.mjs +2 -2
  15. package/dist/NotificationServicesPushController/utils/index.js +2 -2
  16. package/dist/NotificationServicesPushController/utils/index.mjs +2 -2
  17. package/dist/{chunk-K75FPFTD.js → chunk-4KZO4UUC.js} +4 -4
  18. package/dist/{chunk-QUNLD7F2.mjs → chunk-52NKJDI2.mjs} +5 -4
  19. package/dist/chunk-52NKJDI2.mjs.map +1 -0
  20. package/dist/{chunk-O22GVG7K.js → chunk-DKQBDI4C.js} +11 -11
  21. package/dist/{chunk-5I4DIH6O.mjs → chunk-HCOBC2R5.mjs} +2 -2
  22. package/dist/{chunk-ATR6FRAX.mjs → chunk-LFD7J7KR.mjs} +3 -3
  23. package/dist/{chunk-ABJDEX2S.js → chunk-NJBJIZLR.js} +5 -4
  24. package/dist/chunk-NJBJIZLR.js.map +1 -0
  25. package/dist/{chunk-YETZSCGK.js → chunk-NMLYB3XT.js} +4 -4
  26. package/dist/{chunk-WTE64QEK.js → chunk-NXXY4CAP.js} +5 -5
  27. package/dist/{chunk-7ET5GUSY.mjs → chunk-ODZ6V4PH.mjs} +3 -3
  28. package/dist/{chunk-R6AIAXQV.mjs → chunk-RYAHBEX2.mjs} +5 -25
  29. package/dist/chunk-RYAHBEX2.mjs.map +1 -0
  30. package/dist/{chunk-5DA74RWP.mjs → chunk-TT56I53C.mjs} +2 -2
  31. package/dist/{chunk-YD3VVORT.js → chunk-YRWUXGL3.js} +5 -25
  32. package/dist/chunk-YRWUXGL3.js.map +1 -0
  33. package/dist/index.js +7 -7
  34. package/dist/index.mjs +6 -6
  35. package/dist/tsconfig.build.tsbuildinfo +1 -1
  36. package/dist/types/NotificationServicesController/NotificationServicesController.d.ts +0 -2
  37. package/dist/types/NotificationServicesController/NotificationServicesController.d.ts.map +1 -1
  38. package/package.json +1 -1
  39. package/dist/chunk-ABJDEX2S.js.map +0 -1
  40. package/dist/chunk-QUNLD7F2.mjs.map +0 -1
  41. package/dist/chunk-R6AIAXQV.mjs.map +0 -1
  42. package/dist/chunk-YD3VVORT.js.map +0 -1
  43. /package/dist/{chunk-K75FPFTD.js.map → chunk-4KZO4UUC.js.map} +0 -0
  44. /package/dist/{chunk-O22GVG7K.js.map → chunk-DKQBDI4C.js.map} +0 -0
  45. /package/dist/{chunk-5I4DIH6O.mjs.map → chunk-HCOBC2R5.mjs.map} +0 -0
  46. /package/dist/{chunk-ATR6FRAX.mjs.map → chunk-LFD7J7KR.mjs.map} +0 -0
  47. /package/dist/{chunk-YETZSCGK.js.map → chunk-NMLYB3XT.js.map} +0 -0
  48. /package/dist/{chunk-WTE64QEK.js.map → chunk-NXXY4CAP.js.map} +0 -0
  49. /package/dist/{chunk-7ET5GUSY.mjs.map → chunk-ODZ6V4PH.mjs.map} +0 -0
  50. /package/dist/{chunk-5DA74RWP.mjs.map → chunk-TT56I53C.mjs.map} +0 -0
@@ -1,7 +1,7 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
3
 
4
- var _chunkYD3VVORTjs = require('../chunk-YD3VVORT.js');
4
+ var _chunkYRWUXGL3js = require('../chunk-YRWUXGL3.js');
5
5
  require('../chunk-GFAESVZA.js');
6
6
  require('../chunk-LYEXYTOI.js');
7
7
  require('../chunk-ZMNXLHAC.js');
@@ -14,5 +14,5 @@ require('../chunk-V46WVGWN.js');
14
14
 
15
15
 
16
16
 
17
- exports.default = _chunkYD3VVORTjs.NotificationServicesController; exports.defaultState = _chunkYD3VVORTjs.defaultState;
17
+ exports.default = _chunkYRWUXGL3js.NotificationServicesController; exports.defaultState = _chunkYRWUXGL3js.defaultState;
18
18
  //# sourceMappingURL=NotificationServicesController.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  NotificationServicesController,
3
3
  defaultState
4
- } from "../chunk-R6AIAXQV.mjs";
4
+ } from "../chunk-RYAHBEX2.mjs";
5
5
  import "../chunk-RQWUD2FB.mjs";
6
6
  import "../chunk-BONB66A2.mjs";
7
7
  import "../chunk-EQWVJX6K.mjs";
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkK75FPFTDjs = require('../chunk-K75FPFTD.js');
3
+ var _chunk4KZO4UUCjs = require('../chunk-4KZO4UUC.js');
4
4
 
5
5
 
6
6
  var _chunkUPVIT75Fjs = require('../chunk-UPVIT75F.js');
@@ -20,7 +20,7 @@ require('../chunk-DMH4NSLF.js');
20
20
 
21
21
 
22
22
 
23
- var _chunkYD3VVORTjs = require('../chunk-YD3VVORT.js');
23
+ var _chunkYRWUXGL3js = require('../chunk-YRWUXGL3.js');
24
24
  require('../chunk-GFAESVZA.js');
25
25
  require('../chunk-LYEXYTOI.js');
26
26
  require('../chunk-ZMNXLHAC.js');
@@ -40,5 +40,5 @@ require('../chunk-V46WVGWN.js');
40
40
 
41
41
 
42
42
 
43
- exports.Constants = _chunkCQ6CGSKZjs.constants_exports; exports.Controller = _chunkYD3VVORTjs.NotificationServicesController; exports.Mocks = _chunkK75FPFTDjs.fixtures_exports; exports.Processors = _chunkUPVIT75Fjs.processors_exports; exports.Types = _chunk232HZSEVjs.types_exports; exports.defaultState = _chunkYD3VVORTjs.defaultState;
43
+ exports.Constants = _chunkCQ6CGSKZjs.constants_exports; exports.Controller = _chunkYRWUXGL3js.NotificationServicesController; exports.Mocks = _chunk4KZO4UUCjs.fixtures_exports; exports.Processors = _chunkUPVIT75Fjs.processors_exports; exports.Types = _chunk232HZSEVjs.types_exports; exports.defaultState = _chunkYRWUXGL3js.defaultState;
44
44
  //# sourceMappingURL=index.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  fixtures_exports
3
- } from "../chunk-5I4DIH6O.mjs";
3
+ } from "../chunk-HCOBC2R5.mjs";
4
4
  import {
5
5
  processors_exports
6
6
  } from "../chunk-QTK2RMF7.mjs";
@@ -20,7 +20,7 @@ import "../chunk-PNCS6GEX.mjs";
20
20
  import {
21
21
  NotificationServicesController,
22
22
  defaultState
23
- } from "../chunk-R6AIAXQV.mjs";
23
+ } from "../chunk-RYAHBEX2.mjs";
24
24
  import "../chunk-RQWUD2FB.mjs";
25
25
  import "../chunk-BONB66A2.mjs";
26
26
  import "../chunk-EQWVJX6K.mjs";
@@ -1,10 +1,10 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkO22GVG7Kjs = require('../chunk-O22GVG7K.js');
4
- require('../chunk-YETZSCGK.js');
5
- require('../chunk-ABJDEX2S.js');
3
+ var _chunkDKQBDI4Cjs = require('../chunk-DKQBDI4C.js');
4
+ require('../chunk-NMLYB3XT.js');
5
+ require('../chunk-NJBJIZLR.js');
6
6
  require('../chunk-B25TJ7KS.js');
7
- require('../chunk-K75FPFTD.js');
7
+ require('../chunk-4KZO4UUC.js');
8
8
  require('../chunk-UPVIT75F.js');
9
9
  require('../chunk-232HZSEV.js');
10
10
  require('../chunk-IPI7BAW3.js');
@@ -17,7 +17,7 @@ require('../chunk-XZEVRYUE.js');
17
17
  require('../chunk-3ZS2HAEG.js');
18
18
  require('../chunk-ZV3DFBO4.js');
19
19
  require('../chunk-DMH4NSLF.js');
20
- require('../chunk-YD3VVORT.js');
20
+ require('../chunk-YRWUXGL3.js');
21
21
  require('../chunk-GFAESVZA.js');
22
22
  require('../chunk-LYEXYTOI.js');
23
23
  require('../chunk-ZMNXLHAC.js');
@@ -30,5 +30,5 @@ require('../chunk-TLX5QQK5.js');
30
30
  require('../chunk-V46WVGWN.js');
31
31
 
32
32
 
33
- exports.default = _chunkO22GVG7Kjs.NotificationServicesPushController;
33
+ exports.default = _chunkDKQBDI4Cjs.NotificationServicesPushController;
34
34
  //# sourceMappingURL=NotificationServicesPushController.js.map
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  NotificationServicesPushController
3
- } from "../chunk-7ET5GUSY.mjs";
4
- import "../chunk-5DA74RWP.mjs";
5
- import "../chunk-QUNLD7F2.mjs";
3
+ } from "../chunk-ODZ6V4PH.mjs";
4
+ import "../chunk-TT56I53C.mjs";
5
+ import "../chunk-52NKJDI2.mjs";
6
6
  import "../chunk-IKWNHNJQ.mjs";
7
- import "../chunk-5I4DIH6O.mjs";
7
+ import "../chunk-HCOBC2R5.mjs";
8
8
  import "../chunk-QTK2RMF7.mjs";
9
9
  import "../chunk-B4ECJJ5C.mjs";
10
10
  import "../chunk-4QXAPVW3.mjs";
@@ -17,7 +17,7 @@ import "../chunk-U74Q3BRP.mjs";
17
17
  import "../chunk-G52DNXFH.mjs";
18
18
  import "../chunk-7RM3YNTD.mjs";
19
19
  import "../chunk-PNCS6GEX.mjs";
20
- import "../chunk-R6AIAXQV.mjs";
20
+ import "../chunk-RYAHBEX2.mjs";
21
21
  import "../chunk-RQWUD2FB.mjs";
22
22
  import "../chunk-BONB66A2.mjs";
23
23
  import "../chunk-EQWVJX6K.mjs";
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkWTE64QEKjs = require('../chunk-WTE64QEK.js');
3
+ var _chunkNXXY4CAPjs = require('../chunk-NXXY4CAP.js');
4
4
 
5
5
 
6
6
  var _chunkFFQNSBPUjs = require('../chunk-FFQNSBPU.js');
@@ -12,11 +12,11 @@ require('../chunk-PGMXFZ6Y.js');
12
12
  require('../chunk-EJ52BDLB.js');
13
13
 
14
14
 
15
- var _chunkO22GVG7Kjs = require('../chunk-O22GVG7K.js');
16
- require('../chunk-YETZSCGK.js');
17
- require('../chunk-ABJDEX2S.js');
15
+ var _chunkDKQBDI4Cjs = require('../chunk-DKQBDI4C.js');
16
+ require('../chunk-NMLYB3XT.js');
17
+ require('../chunk-NJBJIZLR.js');
18
18
  require('../chunk-B25TJ7KS.js');
19
- require('../chunk-K75FPFTD.js');
19
+ require('../chunk-4KZO4UUC.js');
20
20
  require('../chunk-UPVIT75F.js');
21
21
  require('../chunk-232HZSEV.js');
22
22
  require('../chunk-IPI7BAW3.js');
@@ -29,7 +29,7 @@ require('../chunk-XZEVRYUE.js');
29
29
  require('../chunk-3ZS2HAEG.js');
30
30
  require('../chunk-ZV3DFBO4.js');
31
31
  require('../chunk-DMH4NSLF.js');
32
- require('../chunk-YD3VVORT.js');
32
+ require('../chunk-YRWUXGL3.js');
33
33
  require('../chunk-GFAESVZA.js');
34
34
  require('../chunk-LYEXYTOI.js');
35
35
  require('../chunk-ZMNXLHAC.js');
@@ -45,5 +45,5 @@ require('../chunk-V46WVGWN.js');
45
45
 
46
46
 
47
47
 
48
- exports.Controller = _chunkO22GVG7Kjs.NotificationServicesPushController; exports.Mocks = _chunkWTE64QEKjs.fixtures_exports; exports.Types = _chunk7LWR54U7js.types_exports; exports.Utils = _chunkFFQNSBPUjs.utils_exports;
48
+ exports.Controller = _chunkDKQBDI4Cjs.NotificationServicesPushController; exports.Mocks = _chunkNXXY4CAPjs.fixtures_exports; exports.Types = _chunk7LWR54U7js.types_exports; exports.Utils = _chunkFFQNSBPUjs.utils_exports;
49
49
  //# sourceMappingURL=index.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  fixtures_exports
3
- } from "../chunk-ATR6FRAX.mjs";
3
+ } from "../chunk-LFD7J7KR.mjs";
4
4
  import {
5
5
  utils_exports
6
6
  } from "../chunk-JLHFZ2UG.mjs";
@@ -12,11 +12,11 @@ import "../chunk-SSWX2N73.mjs";
12
12
  import "../chunk-ODI2BTKS.mjs";
13
13
  import {
14
14
  NotificationServicesPushController
15
- } from "../chunk-7ET5GUSY.mjs";
16
- import "../chunk-5DA74RWP.mjs";
17
- import "../chunk-QUNLD7F2.mjs";
15
+ } from "../chunk-ODZ6V4PH.mjs";
16
+ import "../chunk-TT56I53C.mjs";
17
+ import "../chunk-52NKJDI2.mjs";
18
18
  import "../chunk-IKWNHNJQ.mjs";
19
- import "../chunk-5I4DIH6O.mjs";
19
+ import "../chunk-HCOBC2R5.mjs";
20
20
  import "../chunk-QTK2RMF7.mjs";
21
21
  import "../chunk-B4ECJJ5C.mjs";
22
22
  import "../chunk-4QXAPVW3.mjs";
@@ -29,7 +29,7 @@ import "../chunk-U74Q3BRP.mjs";
29
29
  import "../chunk-G52DNXFH.mjs";
30
30
  import "../chunk-7RM3YNTD.mjs";
31
31
  import "../chunk-PNCS6GEX.mjs";
32
- import "../chunk-R6AIAXQV.mjs";
32
+ import "../chunk-RYAHBEX2.mjs";
33
33
  import "../chunk-RQWUD2FB.mjs";
34
34
  import "../chunk-BONB66A2.mjs";
35
35
  import "../chunk-EQWVJX6K.mjs";
@@ -3,8 +3,8 @@
3
3
 
4
4
 
5
5
 
6
- var _chunkABJDEX2Sjs = require('../../../chunk-ABJDEX2S.js');
7
- require('../../../chunk-K75FPFTD.js');
6
+ var _chunkNJBJIZLRjs = require('../../../chunk-NJBJIZLR.js');
7
+ require('../../../chunk-4KZO4UUC.js');
8
8
  require('../../../chunk-UPVIT75F.js');
9
9
  require('../../../chunk-232HZSEV.js');
10
10
  require('../../../chunk-IPI7BAW3.js');
@@ -17,7 +17,7 @@ require('../../../chunk-XZEVRYUE.js');
17
17
  require('../../../chunk-3ZS2HAEG.js');
18
18
  require('../../../chunk-ZV3DFBO4.js');
19
19
  require('../../../chunk-DMH4NSLF.js');
20
- require('../../../chunk-YD3VVORT.js');
20
+ require('../../../chunk-YRWUXGL3.js');
21
21
  require('../../../chunk-GFAESVZA.js');
22
22
  require('../../../chunk-LYEXYTOI.js');
23
23
  require('../../../chunk-ZMNXLHAC.js');
@@ -33,5 +33,5 @@ require('../../../chunk-V46WVGWN.js');
33
33
 
34
34
 
35
35
 
36
- exports.createRegToken = _chunkABJDEX2Sjs.createRegToken; exports.deleteRegToken = _chunkABJDEX2Sjs.deleteRegToken; exports.listenToPushNotificationsClicked = _chunkABJDEX2Sjs.listenToPushNotificationsClicked; exports.listenToPushNotificationsReceived = _chunkABJDEX2Sjs.listenToPushNotificationsReceived;
36
+ exports.createRegToken = _chunkNJBJIZLRjs.createRegToken; exports.deleteRegToken = _chunkNJBJIZLRjs.deleteRegToken; exports.listenToPushNotificationsClicked = _chunkNJBJIZLRjs.listenToPushNotificationsClicked; exports.listenToPushNotificationsReceived = _chunkNJBJIZLRjs.listenToPushNotificationsReceived;
37
37
  //# sourceMappingURL=push-web.js.map
@@ -3,8 +3,8 @@ import {
3
3
  deleteRegToken,
4
4
  listenToPushNotificationsClicked,
5
5
  listenToPushNotificationsReceived
6
- } from "../../../chunk-QUNLD7F2.mjs";
7
- import "../../../chunk-5I4DIH6O.mjs";
6
+ } from "../../../chunk-52NKJDI2.mjs";
7
+ import "../../../chunk-HCOBC2R5.mjs";
8
8
  import "../../../chunk-QTK2RMF7.mjs";
9
9
  import "../../../chunk-B4ECJJ5C.mjs";
10
10
  import "../../../chunk-4QXAPVW3.mjs";
@@ -17,7 +17,7 @@ import "../../../chunk-U74Q3BRP.mjs";
17
17
  import "../../../chunk-G52DNXFH.mjs";
18
18
  import "../../../chunk-7RM3YNTD.mjs";
19
19
  import "../../../chunk-PNCS6GEX.mjs";
20
- import "../../../chunk-R6AIAXQV.mjs";
20
+ import "../../../chunk-RYAHBEX2.mjs";
21
21
  import "../../../chunk-RQWUD2FB.mjs";
22
22
  import "../../../chunk-BONB66A2.mjs";
23
23
  import "../../../chunk-EQWVJX6K.mjs";
@@ -5,10 +5,10 @@
5
5
 
6
6
 
7
7
 
8
- var _chunkYETZSCGKjs = require('../../chunk-YETZSCGK.js');
9
- require('../../chunk-ABJDEX2S.js');
8
+ var _chunkNMLYB3XTjs = require('../../chunk-NMLYB3XT.js');
9
+ require('../../chunk-NJBJIZLR.js');
10
10
  require('../../chunk-B25TJ7KS.js');
11
- require('../../chunk-K75FPFTD.js');
11
+ require('../../chunk-4KZO4UUC.js');
12
12
  require('../../chunk-UPVIT75F.js');
13
13
  require('../../chunk-232HZSEV.js');
14
14
  require('../../chunk-IPI7BAW3.js');
@@ -21,7 +21,7 @@ require('../../chunk-XZEVRYUE.js');
21
21
  require('../../chunk-3ZS2HAEG.js');
22
22
  require('../../chunk-ZV3DFBO4.js');
23
23
  require('../../chunk-DMH4NSLF.js');
24
- require('../../chunk-YD3VVORT.js');
24
+ require('../../chunk-YRWUXGL3.js');
25
25
  require('../../chunk-GFAESVZA.js');
26
26
  require('../../chunk-LYEXYTOI.js');
27
27
  require('../../chunk-ZMNXLHAC.js');
@@ -39,5 +39,5 @@ require('../../chunk-V46WVGWN.js');
39
39
 
40
40
 
41
41
 
42
- exports.activatePushNotifications = _chunkYETZSCGKjs.activatePushNotifications; exports.deactivatePushNotifications = _chunkYETZSCGKjs.deactivatePushNotifications; exports.getPushNotificationLinks = _chunkYETZSCGKjs.getPushNotificationLinks; exports.listenToPushNotifications = _chunkYETZSCGKjs.listenToPushNotifications; exports.updateLinksAPI = _chunkYETZSCGKjs.updateLinksAPI; exports.updateTriggerPushNotifications = _chunkYETZSCGKjs.updateTriggerPushNotifications;
42
+ exports.activatePushNotifications = _chunkNMLYB3XTjs.activatePushNotifications; exports.deactivatePushNotifications = _chunkNMLYB3XTjs.deactivatePushNotifications; exports.getPushNotificationLinks = _chunkNMLYB3XTjs.getPushNotificationLinks; exports.listenToPushNotifications = _chunkNMLYB3XTjs.listenToPushNotifications; exports.updateLinksAPI = _chunkNMLYB3XTjs.updateLinksAPI; exports.updateTriggerPushNotifications = _chunkNMLYB3XTjs.updateTriggerPushNotifications;
43
43
  //# sourceMappingURL=services.js.map
@@ -5,10 +5,10 @@ import {
5
5
  listenToPushNotifications,
6
6
  updateLinksAPI,
7
7
  updateTriggerPushNotifications
8
- } from "../../chunk-5DA74RWP.mjs";
9
- import "../../chunk-QUNLD7F2.mjs";
8
+ } from "../../chunk-TT56I53C.mjs";
9
+ import "../../chunk-52NKJDI2.mjs";
10
10
  import "../../chunk-IKWNHNJQ.mjs";
11
- import "../../chunk-5I4DIH6O.mjs";
11
+ import "../../chunk-HCOBC2R5.mjs";
12
12
  import "../../chunk-QTK2RMF7.mjs";
13
13
  import "../../chunk-B4ECJJ5C.mjs";
14
14
  import "../../chunk-4QXAPVW3.mjs";
@@ -21,7 +21,7 @@ import "../../chunk-U74Q3BRP.mjs";
21
21
  import "../../chunk-G52DNXFH.mjs";
22
22
  import "../../chunk-7RM3YNTD.mjs";
23
23
  import "../../chunk-PNCS6GEX.mjs";
24
- import "../../chunk-R6AIAXQV.mjs";
24
+ import "../../chunk-RYAHBEX2.mjs";
25
25
  import "../../chunk-RQWUD2FB.mjs";
26
26
  import "../../chunk-BONB66A2.mjs";
27
27
  import "../../chunk-EQWVJX6K.mjs";
@@ -4,7 +4,7 @@
4
4
 
5
5
  var _chunkPGMXFZ6Yjs = require('../../chunk-PGMXFZ6Y.js');
6
6
  require('../../chunk-EJ52BDLB.js');
7
- require('../../chunk-K75FPFTD.js');
7
+ require('../../chunk-4KZO4UUC.js');
8
8
  require('../../chunk-UPVIT75F.js');
9
9
  require('../../chunk-232HZSEV.js');
10
10
  require('../../chunk-IPI7BAW3.js');
@@ -17,7 +17,7 @@ require('../../chunk-XZEVRYUE.js');
17
17
  require('../../chunk-3ZS2HAEG.js');
18
18
  require('../../chunk-ZV3DFBO4.js');
19
19
  require('../../chunk-DMH4NSLF.js');
20
- require('../../chunk-YD3VVORT.js');
20
+ require('../../chunk-YRWUXGL3.js');
21
21
  require('../../chunk-GFAESVZA.js');
22
22
  require('../../chunk-LYEXYTOI.js');
23
23
  require('../../chunk-ZMNXLHAC.js');
@@ -4,7 +4,7 @@ import {
4
4
  isOnChainNotification
5
5
  } from "../../chunk-SSWX2N73.mjs";
6
6
  import "../../chunk-ODI2BTKS.mjs";
7
- import "../../chunk-5I4DIH6O.mjs";
7
+ import "../../chunk-HCOBC2R5.mjs";
8
8
  import "../../chunk-QTK2RMF7.mjs";
9
9
  import "../../chunk-B4ECJJ5C.mjs";
10
10
  import "../../chunk-4QXAPVW3.mjs";
@@ -17,7 +17,7 @@ import "../../chunk-U74Q3BRP.mjs";
17
17
  import "../../chunk-G52DNXFH.mjs";
18
18
  import "../../chunk-7RM3YNTD.mjs";
19
19
  import "../../chunk-PNCS6GEX.mjs";
20
- import "../../chunk-R6AIAXQV.mjs";
20
+ import "../../chunk-RYAHBEX2.mjs";
21
21
  import "../../chunk-RQWUD2FB.mjs";
22
22
  import "../../chunk-BONB66A2.mjs";
23
23
  import "../../chunk-EQWVJX6K.mjs";
@@ -10,7 +10,7 @@ var _chunkPGMXFZ6Yjs = require('../../chunk-PGMXFZ6Y.js');
10
10
 
11
11
 
12
12
  var _chunkEJ52BDLBjs = require('../../chunk-EJ52BDLB.js');
13
- require('../../chunk-K75FPFTD.js');
13
+ require('../../chunk-4KZO4UUC.js');
14
14
  require('../../chunk-UPVIT75F.js');
15
15
  require('../../chunk-232HZSEV.js');
16
16
  require('../../chunk-IPI7BAW3.js');
@@ -23,7 +23,7 @@ require('../../chunk-XZEVRYUE.js');
23
23
  require('../../chunk-3ZS2HAEG.js');
24
24
  require('../../chunk-ZV3DFBO4.js');
25
25
  require('../../chunk-DMH4NSLF.js');
26
- require('../../chunk-YD3VVORT.js');
26
+ require('../../chunk-YRWUXGL3.js');
27
27
  require('../../chunk-GFAESVZA.js');
28
28
  require('../../chunk-LYEXYTOI.js');
29
29
  require('../../chunk-ZMNXLHAC.js');
@@ -10,7 +10,7 @@ import {
10
10
  getAmount,
11
11
  getLeadingZeroCount
12
12
  } from "../../chunk-ODI2BTKS.mjs";
13
- import "../../chunk-5I4DIH6O.mjs";
13
+ import "../../chunk-HCOBC2R5.mjs";
14
14
  import "../../chunk-QTK2RMF7.mjs";
15
15
  import "../../chunk-B4ECJJ5C.mjs";
16
16
  import "../../chunk-4QXAPVW3.mjs";
@@ -23,7 +23,7 @@ import "../../chunk-U74Q3BRP.mjs";
23
23
  import "../../chunk-G52DNXFH.mjs";
24
24
  import "../../chunk-7RM3YNTD.mjs";
25
25
  import "../../chunk-PNCS6GEX.mjs";
26
- import "../../chunk-R6AIAXQV.mjs";
26
+ import "../../chunk-RYAHBEX2.mjs";
27
27
  import "../../chunk-RQWUD2FB.mjs";
28
28
  import "../../chunk-BONB66A2.mjs";
29
29
  import "../../chunk-EQWVJX6K.mjs";
@@ -7,7 +7,7 @@ var _chunk232HZSEVjs = require('./chunk-232HZSEV.js');
7
7
 
8
8
 
9
9
 
10
- var _chunkYD3VVORTjs = require('./chunk-YD3VVORT.js');
10
+ var _chunkYRWUXGL3js = require('./chunk-YRWUXGL3.js');
11
11
 
12
12
 
13
13
  var _chunkZMNXLHACjs = require('./chunk-ZMNXLHAC.js');
@@ -3369,11 +3369,11 @@ var require_nock = _chunkV46WVGWNjs.__commonJS.call(void 0, {
3369
3369
  var NotificationServicesController_exports = {};
3370
3370
  _chunkV46WVGWNjs.__export.call(void 0, NotificationServicesController_exports, {
3371
3371
  Constants: () => _chunkCQ6CGSKZjs.constants_exports,
3372
- Controller: () => _chunkYD3VVORTjs.NotificationServicesController,
3372
+ Controller: () => _chunkYRWUXGL3js.NotificationServicesController,
3373
3373
  Mocks: () => fixtures_exports,
3374
3374
  Processors: () => _chunkUPVIT75Fjs.processors_exports,
3375
3375
  Types: () => _chunk232HZSEVjs.types_exports,
3376
- defaultState: () => _chunkYD3VVORTjs.defaultState
3376
+ defaultState: () => _chunkYRWUXGL3js.defaultState
3377
3377
  });
3378
3378
 
3379
3379
  // src/NotificationServicesController/__fixtures__/index.ts
@@ -4297,4 +4297,4 @@ var mockMarkNotificationsAsRead = (mockReply) => {
4297
4297
 
4298
4298
 
4299
4299
  exports.require_nock = require_nock; exports.fixtures_exports = fixtures_exports; exports.NotificationServicesController_exports = NotificationServicesController_exports;
4300
- //# sourceMappingURL=chunk-K75FPFTD.js.map
4300
+ //# sourceMappingURL=chunk-4KZO4UUC.js.map
@@ -7,6 +7,7 @@ import { getApp, initializeApp } from "firebase/app";
7
7
  import { getToken, deleteToken } from "firebase/messaging";
8
8
  import { getMessaging, onBackgroundMessage } from "firebase/messaging/sw";
9
9
  import log from "loglevel";
10
+ var sw = self;
10
11
  var createFirebaseApp = async (env) => {
11
12
  try {
12
13
  return getApp();
@@ -31,7 +32,7 @@ async function createRegToken(env) {
31
32
  try {
32
33
  const messaging = await getFirebaseMessaging(env);
33
34
  const token = await getToken(messaging, {
34
- serviceWorkerRegistration: self.registration,
35
+ serviceWorkerRegistration: sw.registration,
35
36
  vapidKey: env.vapidKey
36
37
  });
37
38
  return token;
@@ -78,8 +79,8 @@ function listenToPushNotificationsClicked(handler) {
78
79
  const data = event?.notification?.data;
79
80
  handler(event, data);
80
81
  };
81
- self.addEventListener("notificationclick", clickHandler);
82
- const unsubscribe = () => self.removeEventListener("notificationclick", clickHandler);
82
+ sw.addEventListener("notificationclick", clickHandler);
83
+ const unsubscribe = () => sw.removeEventListener("notificationclick", clickHandler);
83
84
  return unsubscribe;
84
85
  }
85
86
 
@@ -89,4 +90,4 @@ export {
89
90
  listenToPushNotificationsReceived,
90
91
  listenToPushNotificationsClicked
91
92
  };
92
- //# sourceMappingURL=chunk-QUNLD7F2.mjs.map
93
+ //# sourceMappingURL=chunk-52NKJDI2.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 type { PushNotificationEnv } from '../../types/firebase';\n\nconst sw = self as unknown as 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: sw.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 notificationData: Types.NotificationUnion = payload?.data?.data\n ? JSON.parse(payload?.data?.data)\n : undefined;\n\n if (!notificationData) {\n return;\n }\n\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 sw.addEventListener('notificationclick', clickHandler);\n const unsubscribe = () =>\n sw.removeEventListener('notificationclick', clickHandler);\n return unsubscribe;\n}\n"],"mappings":";;;;;AAIA,SAAS,QAAQ,qBAAqB;AACtC,SAAS,UAAU,mBAAmB;AACtC,SAAS,cAAc,2BAA2B;AAElD,OAAO,SAAS;AAMhB,IAAM,KAAK;AAEX,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,GAAG;AAAA,MAC9B,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,mBAA4C,SAAS,MAAM,OAC7D,KAAK,MAAM,SAAS,MAAM,IAAI,IAC9B;AAEJ,YAAI,CAAC,kBAAkB;AACrB;AAAA,QACF;AAEA,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,KAAG,iBAAiB,qBAAqB,YAAY;AACrD,QAAM,cAAc,MAClB,GAAG,oBAAoB,qBAAqB,YAAY;AAC1D,SAAO;AACT;","names":[]}
@@ -3,11 +3,11 @@
3
3
 
4
4
 
5
5
 
6
- var _chunkYETZSCGKjs = require('./chunk-YETZSCGK.js');
6
+ var _chunkNMLYB3XTjs = require('./chunk-NMLYB3XT.js');
7
7
 
8
8
 
9
9
 
10
- var _chunkABJDEX2Sjs = require('./chunk-ABJDEX2S.js');
10
+ var _chunkNJBJIZLRjs = require('./chunk-NJBJIZLR.js');
11
11
 
12
12
 
13
13
 
@@ -66,17 +66,17 @@ var NotificationServicesPushController = class extends _basecontroller.BaseContr
66
66
  }
67
67
  const bearerToken = await _chunkV46WVGWNjs.__privateMethod.call(void 0, this, _getAndAssertBearerToken, getAndAssertBearerToken_fn).call(this);
68
68
  try {
69
- const regToken = await _chunkYETZSCGKjs.activatePushNotifications.call(void 0, {
69
+ const regToken = await _chunkNMLYB3XTjs.activatePushNotifications.call(void 0, {
70
70
  bearerToken,
71
71
  triggers: UUIDs,
72
72
  env: _chunkV46WVGWNjs.__privateGet.call(void 0, this, _env),
73
- createRegToken: _chunkABJDEX2Sjs.createRegToken,
73
+ createRegToken: _chunkNJBJIZLRjs.createRegToken,
74
74
  platform: _chunkV46WVGWNjs.__privateGet.call(void 0, this, _config).platform
75
75
  });
76
76
  if (!regToken) {
77
77
  return;
78
78
  }
79
- _chunkV46WVGWNjs.__privateSet.call(void 0, this, _pushListenerUnsubscribe, await _chunkYETZSCGKjs.listenToPushNotifications.call(void 0, {
79
+ _chunkV46WVGWNjs.__privateSet.call(void 0, this, _pushListenerUnsubscribe, await _chunkNMLYB3XTjs.listenToPushNotifications.call(void 0, {
80
80
  env: _chunkV46WVGWNjs.__privateGet.call(void 0, this, _env),
81
81
  listenToPushReceived: async (n) => {
82
82
  this.messagingSystem.publish(
@@ -120,11 +120,11 @@ var NotificationServicesPushController = class extends _basecontroller.BaseContr
120
120
  const bearerToken = await _chunkV46WVGWNjs.__privateMethod.call(void 0, this, _getAndAssertBearerToken, getAndAssertBearerToken_fn).call(this);
121
121
  let isPushNotificationsDisabled;
122
122
  try {
123
- isPushNotificationsDisabled = await _chunkYETZSCGKjs.deactivatePushNotifications.call(void 0, {
123
+ isPushNotificationsDisabled = await _chunkNMLYB3XTjs.deactivatePushNotifications.call(void 0, {
124
124
  bearerToken,
125
125
  triggers: UUIDs,
126
126
  env: _chunkV46WVGWNjs.__privateGet.call(void 0, this, _env),
127
- deleteRegToken: _chunkABJDEX2Sjs.deleteRegToken,
127
+ deleteRegToken: _chunkNJBJIZLRjs.deleteRegToken,
128
128
  regToken: this.state.fcmToken
129
129
  });
130
130
  } catch (error) {
@@ -155,12 +155,12 @@ var NotificationServicesPushController = class extends _basecontroller.BaseContr
155
155
  }
156
156
  const bearerToken = await _chunkV46WVGWNjs.__privateMethod.call(void 0, this, _getAndAssertBearerToken, getAndAssertBearerToken_fn).call(this);
157
157
  try {
158
- const { fcmToken } = await _chunkYETZSCGKjs.updateTriggerPushNotifications.call(void 0, {
158
+ const { fcmToken } = await _chunkNMLYB3XTjs.updateTriggerPushNotifications.call(void 0, {
159
159
  bearerToken,
160
160
  triggers: UUIDs,
161
161
  env: _chunkV46WVGWNjs.__privateGet.call(void 0, this, _env),
162
- createRegToken: _chunkABJDEX2Sjs.createRegToken,
163
- deleteRegToken: _chunkABJDEX2Sjs.deleteRegToken,
162
+ createRegToken: _chunkNJBJIZLRjs.createRegToken,
163
+ deleteRegToken: _chunkNJBJIZLRjs.deleteRegToken,
164
164
  platform: _chunkV46WVGWNjs.__privateGet.call(void 0, this, _config).platform,
165
165
  regToken: this.state.fcmToken
166
166
  });
@@ -211,4 +211,4 @@ getAndAssertBearerToken_fn = async function() {
211
211
 
212
212
 
213
213
  exports.NotificationServicesPushController = NotificationServicesPushController;
214
- //# sourceMappingURL=chunk-O22GVG7K.js.map
214
+ //# sourceMappingURL=chunk-DKQBDI4C.js.map
@@ -7,7 +7,7 @@ import {
7
7
  import {
8
8
  NotificationServicesController,
9
9
  defaultState
10
- } from "./chunk-R6AIAXQV.mjs";
10
+ } from "./chunk-RYAHBEX2.mjs";
11
11
  import {
12
12
  FEATURE_ANNOUNCEMENT_API
13
13
  } from "./chunk-EQWVJX6K.mjs";
@@ -4297,4 +4297,4 @@ export {
4297
4297
  fixtures_exports,
4298
4298
  NotificationServicesController_exports
4299
4299
  };
4300
- //# sourceMappingURL=chunk-5I4DIH6O.mjs.map
4300
+ //# sourceMappingURL=chunk-HCOBC2R5.mjs.map
@@ -6,13 +6,13 @@ import {
6
6
  } from "./chunk-IOMDG67D.mjs";
7
7
  import {
8
8
  NotificationServicesPushController
9
- } from "./chunk-7ET5GUSY.mjs";
9
+ } from "./chunk-ODZ6V4PH.mjs";
10
10
  import {
11
11
  REGISTRATION_TOKENS_ENDPOINT
12
12
  } from "./chunk-IKWNHNJQ.mjs";
13
13
  import {
14
14
  require_nock
15
- } from "./chunk-5I4DIH6O.mjs";
15
+ } from "./chunk-HCOBC2R5.mjs";
16
16
  import {
17
17
  __export,
18
18
  __toESM
@@ -116,4 +116,4 @@ export {
116
116
  fixtures_exports,
117
117
  NotificationServicesPushController_exports
118
118
  };
119
- //# sourceMappingURL=chunk-ATR6FRAX.mjs.map
119
+ //# sourceMappingURL=chunk-LFD7J7KR.mjs.map
@@ -7,6 +7,7 @@ var _app = require('firebase/app');
7
7
  var _messaging = require('firebase/messaging');
8
8
  var _sw = require('firebase/messaging/sw');
9
9
  var _loglevel = require('loglevel'); var _loglevel2 = _interopRequireDefault(_loglevel);
10
+ var sw = self;
10
11
  var createFirebaseApp = async (env) => {
11
12
  try {
12
13
  return _app.getApp.call(void 0, );
@@ -31,7 +32,7 @@ async function createRegToken(env) {
31
32
  try {
32
33
  const messaging = await getFirebaseMessaging(env);
33
34
  const token = await _messaging.getToken.call(void 0, messaging, {
34
- serviceWorkerRegistration: self.registration,
35
+ serviceWorkerRegistration: sw.registration,
35
36
  vapidKey: env.vapidKey
36
37
  });
37
38
  return token;
@@ -78,8 +79,8 @@ function listenToPushNotificationsClicked(handler) {
78
79
  const data = event?.notification?.data;
79
80
  handler(event, data);
80
81
  };
81
- self.addEventListener("notificationclick", clickHandler);
82
- const unsubscribe = () => self.removeEventListener("notificationclick", clickHandler);
82
+ sw.addEventListener("notificationclick", clickHandler);
83
+ const unsubscribe = () => sw.removeEventListener("notificationclick", clickHandler);
83
84
  return unsubscribe;
84
85
  }
85
86
 
@@ -89,4 +90,4 @@ function listenToPushNotificationsClicked(handler) {
89
90
 
90
91
 
91
92
  exports.createRegToken = createRegToken; exports.deleteRegToken = deleteRegToken; exports.listenToPushNotificationsReceived = listenToPushNotificationsReceived; exports.listenToPushNotificationsClicked = listenToPushNotificationsClicked;
92
- //# sourceMappingURL=chunk-ABJDEX2S.js.map
93
+ //# sourceMappingURL=chunk-NJBJIZLR.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/NotificationServicesPushController/services/push/push-web.ts"],"names":[],"mappings":";;;;;AAIA,SAAS,QAAQ,qBAAqB;AACtC,SAAS,UAAU,mBAAmB;AACtC,SAAS,cAAc,2BAA2B;AAElD,OAAO,SAAS;AAMhB,IAAM,KAAK;AAEX,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,GAAG;AAAA,MAC9B,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,mBAA4C,SAAS,MAAM,OAC7D,KAAK,MAAM,SAAS,MAAM,IAAI,IAC9B;AAEJ,YAAI,CAAC,kBAAkB;AACrB;AAAA,QACF;AAEA,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,KAAG,iBAAiB,qBAAqB,YAAY;AACrD,QAAM,cAAc,MAClB,GAAG,oBAAoB,qBAAqB,YAAY;AAC1D,SAAO;AACT","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 type { PushNotificationEnv } from '../../types/firebase';\n\nconst sw = self as unknown as 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: sw.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 notificationData: Types.NotificationUnion = payload?.data?.data\n ? JSON.parse(payload?.data?.data)\n : undefined;\n\n if (!notificationData) {\n return;\n }\n\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 sw.addEventListener('notificationclick', clickHandler);\n const unsubscribe = () =>\n sw.removeEventListener('notificationclick', clickHandler);\n return unsubscribe;\n}\n"]}