@metamask-previews/notification-services-controller 0.21.0-preview-5575cd05 → 0.21.0-preview-a1eb992b
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/NotificationServicesController/NotificationServicesController.cjs +74 -62
- package/dist/NotificationServicesController/NotificationServicesController.cjs.map +1 -1
- package/dist/NotificationServicesController/NotificationServicesController.d.cts +34 -10
- package/dist/NotificationServicesController/NotificationServicesController.d.cts.map +1 -1
- package/dist/NotificationServicesController/NotificationServicesController.d.mts +34 -10
- package/dist/NotificationServicesController/NotificationServicesController.d.mts.map +1 -1
- package/dist/NotificationServicesController/NotificationServicesController.mjs +74 -62
- package/dist/NotificationServicesController/NotificationServicesController.mjs.map +1 -1
- package/dist/NotificationServicesController/index.cjs +0 -1
- package/dist/NotificationServicesController/index.cjs.map +1 -1
- package/dist/NotificationServicesController/index.d.cts +0 -1
- package/dist/NotificationServicesController/index.d.cts.map +1 -1
- package/dist/NotificationServicesController/index.d.mts +0 -1
- package/dist/NotificationServicesController/index.d.mts.map +1 -1
- package/dist/NotificationServicesController/index.mjs +0 -1
- package/dist/NotificationServicesController/index.mjs.map +1 -1
- package/dist/NotificationServicesPushController/NotificationServicesPushController.cjs +56 -56
- package/dist/NotificationServicesPushController/NotificationServicesPushController.cjs.map +1 -1
- package/dist/NotificationServicesPushController/NotificationServicesPushController.d.cts +24 -18
- package/dist/NotificationServicesPushController/NotificationServicesPushController.d.cts.map +1 -1
- package/dist/NotificationServicesPushController/NotificationServicesPushController.d.mts +24 -18
- package/dist/NotificationServicesPushController/NotificationServicesPushController.d.mts.map +1 -1
- package/dist/NotificationServicesPushController/NotificationServicesPushController.mjs +57 -57
- package/dist/NotificationServicesPushController/NotificationServicesPushController.mjs.map +1 -1
- package/dist/NotificationServicesPushController/__fixtures__/mockServices.cjs +13 -1
- package/dist/NotificationServicesPushController/__fixtures__/mockServices.cjs.map +1 -1
- package/dist/NotificationServicesPushController/__fixtures__/mockServices.d.cts +1 -0
- package/dist/NotificationServicesPushController/__fixtures__/mockServices.d.cts.map +1 -1
- package/dist/NotificationServicesPushController/__fixtures__/mockServices.d.mts +1 -0
- package/dist/NotificationServicesPushController/__fixtures__/mockServices.d.mts.map +1 -1
- package/dist/NotificationServicesPushController/__fixtures__/mockServices.mjs +12 -1
- package/dist/NotificationServicesPushController/__fixtures__/mockServices.mjs.map +1 -1
- package/dist/NotificationServicesPushController/constants.cjs +14 -0
- package/dist/NotificationServicesPushController/constants.cjs.map +1 -0
- package/dist/NotificationServicesPushController/constants.d.cts +11 -0
- package/dist/NotificationServicesPushController/constants.d.cts.map +1 -0
- package/dist/NotificationServicesPushController/constants.d.mts +11 -0
- package/dist/NotificationServicesPushController/constants.d.mts.map +1 -0
- package/dist/NotificationServicesPushController/constants.mjs +11 -0
- package/dist/NotificationServicesPushController/constants.mjs.map +1 -0
- package/dist/NotificationServicesPushController/{types/push-service-interface.cjs → services/push/index.cjs} +1 -1
- package/dist/NotificationServicesPushController/services/push/index.cjs.map +1 -0
- package/dist/NotificationServicesPushController/services/push/index.d.cts +6 -0
- package/dist/NotificationServicesPushController/services/push/index.d.cts.map +1 -0
- package/dist/NotificationServicesPushController/services/push/index.d.mts +6 -0
- package/dist/NotificationServicesPushController/services/push/index.d.mts.map +1 -0
- package/dist/NotificationServicesPushController/services/push/index.mjs +2 -0
- package/dist/NotificationServicesPushController/services/push/index.mjs.map +1 -0
- package/dist/NotificationServicesPushController/services/services.cjs +93 -15
- package/dist/NotificationServicesPushController/services/services.cjs.map +1 -1
- package/dist/NotificationServicesPushController/services/services.d.cts +27 -4
- package/dist/NotificationServicesPushController/services/services.d.cts.map +1 -1
- package/dist/NotificationServicesPushController/services/services.d.mts +27 -4
- package/dist/NotificationServicesPushController/services/services.d.mts.map +1 -1
- package/dist/NotificationServicesPushController/services/services.mjs +94 -14
- package/dist/NotificationServicesPushController/services/services.mjs.map +1 -1
- package/dist/NotificationServicesPushController/types/index.cjs.map +1 -1
- package/dist/NotificationServicesPushController/types/index.d.cts +0 -1
- package/dist/NotificationServicesPushController/types/index.d.cts.map +1 -1
- package/dist/NotificationServicesPushController/types/index.d.mts +0 -1
- package/dist/NotificationServicesPushController/types/index.d.mts.map +1 -1
- package/dist/NotificationServicesPushController/types/index.mjs.map +1 -1
- package/dist/NotificationServicesPushController/utils/get-notification-message.cjs +19 -1
- package/dist/NotificationServicesPushController/utils/get-notification-message.cjs.map +1 -1
- package/dist/NotificationServicesPushController/utils/get-notification-message.d.cts +7 -0
- package/dist/NotificationServicesPushController/utils/get-notification-message.d.cts.map +1 -1
- package/dist/NotificationServicesPushController/utils/get-notification-message.d.mts +7 -0
- package/dist/NotificationServicesPushController/utils/get-notification-message.d.mts.map +1 -1
- package/dist/NotificationServicesPushController/utils/get-notification-message.mjs +17 -0
- package/dist/NotificationServicesPushController/utils/get-notification-message.mjs.map +1 -1
- package/package.json +1 -11
- package/dist/NotificationServicesPushController/__fixtures__/mockMessenger.cjs +0 -14
- package/dist/NotificationServicesPushController/__fixtures__/mockMessenger.cjs.map +0 -1
- package/dist/NotificationServicesPushController/__fixtures__/mockMessenger.d.cts +0 -3
- package/dist/NotificationServicesPushController/__fixtures__/mockMessenger.d.cts.map +0 -1
- package/dist/NotificationServicesPushController/__fixtures__/mockMessenger.d.mts +0 -3
- package/dist/NotificationServicesPushController/__fixtures__/mockMessenger.d.mts.map +0 -1
- package/dist/NotificationServicesPushController/__fixtures__/mockMessenger.mjs +0 -10
- package/dist/NotificationServicesPushController/__fixtures__/mockMessenger.mjs.map +0 -1
- package/dist/NotificationServicesPushController/types/push-service-interface.cjs.map +0 -1
- package/dist/NotificationServicesPushController/types/push-service-interface.d.cts +0 -30
- package/dist/NotificationServicesPushController/types/push-service-interface.d.cts.map +0 -1
- package/dist/NotificationServicesPushController/types/push-service-interface.d.mts +0 -30
- package/dist/NotificationServicesPushController/types/push-service-interface.d.mts.map +0 -1
- package/dist/NotificationServicesPushController/types/push-service-interface.mjs +0 -2
- package/dist/NotificationServicesPushController/types/push-service-interface.mjs.map +0 -1
- package/dist/NotificationServicesPushController/web/index.cjs +0 -8
- package/dist/NotificationServicesPushController/web/index.cjs.map +0 -1
- package/dist/NotificationServicesPushController/web/index.d.cts +0 -2
- package/dist/NotificationServicesPushController/web/index.d.cts.map +0 -1
- package/dist/NotificationServicesPushController/web/index.d.mts +0 -2
- package/dist/NotificationServicesPushController/web/index.d.mts.map +0 -1
- package/dist/NotificationServicesPushController/web/index.mjs +0 -2
- package/dist/NotificationServicesPushController/web/index.mjs.map +0 -1
- package/dist/NotificationServicesPushController/web/push-utils.cjs +0 -170
- package/dist/NotificationServicesPushController/web/push-utils.cjs.map +0 -1
- package/dist/NotificationServicesPushController/web/push-utils.d.cts +0 -37
- package/dist/NotificationServicesPushController/web/push-utils.d.cts.map +0 -1
- package/dist/NotificationServicesPushController/web/push-utils.d.mts +0 -37
- package/dist/NotificationServicesPushController/web/push-utils.d.mts.map +0 -1
- package/dist/NotificationServicesPushController/web/push-utils.mjs +0 -168
- package/dist/NotificationServicesPushController/web/push-utils.mjs.map +0 -1
- package/dist/shared/index.cjs +0 -19
- package/dist/shared/index.cjs.map +0 -1
- package/dist/shared/index.d.cts +0 -3
- package/dist/shared/index.d.cts.map +0 -1
- package/dist/shared/index.d.mts +0 -3
- package/dist/shared/index.d.mts.map +0 -1
- package/dist/shared/index.mjs +0 -3
- package/dist/shared/index.mjs.map +0 -1
- package/dist/shared/is-onchain-notification.cjs +0 -22
- package/dist/shared/is-onchain-notification.cjs.map +0 -1
- package/dist/shared/is-onchain-notification.d.cts +0 -9
- package/dist/shared/is-onchain-notification.d.cts.map +0 -1
- package/dist/shared/is-onchain-notification.d.mts +0 -9
- package/dist/shared/is-onchain-notification.d.mts.map +0 -1
- package/dist/shared/is-onchain-notification.mjs +0 -18
- package/dist/shared/is-onchain-notification.mjs.map +0 -1
- package/push-services/web/package.json +0 -150
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"push-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AC,YAAY,CAAC,CAAC;QAC9C,CAAC,CACF,CAAC;QACF,MAAM,UAAU,GAAG,gCAAgC,CACjD,CAAC,KAAK,EAAE,YAAY,EAAE,EAAE;YACtB,KAAK,CAAC,SAAS,CAAC,OAAO,CACrB,4DAA4D,EAC5D,YAAY,CACb,CAAC;YACF,KAAK,CAAC,cAAc,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;QAC5C,CAAC,CACF,CAAC;QAEF,MAAM,WAAW,GAAG,GAAG,EAAE;YACvB,sBAAsB,EAAE,EAAE,CAAC;YAC3B,UAAU,EAAE,CAAC;QACf,CAAC,CAAC;QAEF,OAAO,WAAW,CAAC;IACrB,CAAC,CAAC;AACJ,CAAC;AAtCD,gFAsCC","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 {\n getMessaging,\n onBackgroundMessage,\n isSupported,\n} from 'firebase/messaging/sw';\nimport type { Messaging, MessagePayload } from 'firebase/messaging/sw';\nimport log from 'loglevel';\n\nimport type { Types } from '../../NotificationServicesController';\nimport { Processors } from '../../NotificationServicesController';\nimport { toRawOnChainNotification } from '../../shared/to-raw-notification';\nimport type { NotificationServicesPushControllerMessenger } from '../NotificationServicesPushController';\nimport type { PushNotificationEnv } from '../types/firebase';\n\ndeclare const self: ServiceWorkerGlobalScope;\n\n// Exported to help testing\n// eslint-disable-next-line import-x/no-mutable-exports\nexport let supportedCache: boolean | null = null;\n\nconst getPushAvailability = async () => {\n supportedCache ??= await isSupported();\n return supportedCache;\n};\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 | null> => {\n const supported = await getPushAvailability();\n if (!supported) {\n return null;\n }\n\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 if (!messaging) {\n return null;\n }\n\n const token = await getToken(messaging, {\n serviceWorkerRegistration: self.registration,\n vapidKey: env.vapidKey,\n });\n return token;\n } catch {\n return null;\n }\n}\n\n/**\n * Deletes the Firebase Cloud Messaging registration token.\n *\n * @param env - env to configure push notifications\n * @returns A promise that resolves with true if the token was successfully deleted, false otherwise.\n */\nexport async function deleteRegToken(\n env: PushNotificationEnv,\n): Promise<boolean> {\n try {\n const messaging = await getFirebaseMessaging(env);\n if (!messaging) {\n return true;\n }\n\n await deleteToken(messaging);\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * Service Worker Listener for when push notifications are received.\n *\n * @param env - push notification environment\n * @param handler - handler to actually showing notification, MUST BE PROVIDED\n * @returns unsubscribe handler\n */\nasync function listenToPushNotificationsReceived(\n env: PushNotificationEnv,\n handler: (notification: Types.INotification) => void | Promise<void>,\n): Promise<(() => void) | null> {\n const messaging = await getFirebaseMessaging(env);\n if (!messaging) {\n return null;\n }\n\n const unsubscribePushNotifications = onBackgroundMessage(\n messaging,\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n async (payload: MessagePayload) => {\n try {\n const data: Types.UnprocessedOnChainRawNotification | undefined =\n payload?.data?.data ? JSON.parse(payload?.data?.data) : undefined;\n\n if (!data) {\n return;\n }\n\n const notificationData = toRawOnChainNotification(data);\n const notification = Processors.processNotification(notificationData);\n await handler(notification);\n } catch (error) {\n // Do Nothing, cannot parse a bad notification\n log.error('Unable to send push notification:', {\n notification: payload?.data?.data,\n error,\n });\n throw new Error('Unable to send push notification');\n }\n },\n );\n\n const unsubscribe = () => unsubscribePushNotifications();\n return unsubscribe;\n}\n\n/**\n * Service Worker Listener for when a notification is clicked\n *\n * @param handler - listen to NotificationEvent from the service worker\n * @returns unsubscribe handler\n */\nfunction listenToPushNotificationsClicked(\n handler: (e: NotificationEvent, notification: Types.INotification) => void,\n) {\n const clickHandler = (event: NotificationEvent) => {\n // Get Data\n const data: Types.INotification = event?.notification?.data;\n handler(event, data);\n };\n\n self.addEventListener('notificationclick', clickHandler);\n const unsubscribe = () =>\n self.removeEventListener('notificationclick', clickHandler);\n return unsubscribe;\n}\n\n/**\n * A creator function that assists creating web-specific push notification subscription:\n * 1. Creates subscriptions for receiving and clicking notifications\n * 2. Creates click events when a notification is clicked\n * 3. Publishes controller messenger events\n *\n * @param props - props for this creator function.\n * @param props.onReceivedHandler - allows the developer to handle showing a notification\n * @param props.onClickHandler - allows the developer to handle clicking the notification\n * @param props.messenger - the controller messenger to publish the `onNewNotifications` and `pushNotificationsClicked` events\n * @returns a function that can be used by the controller\n */\nexport function createSubscribeToPushNotifications(props: {\n onReceivedHandler: (\n notification: Types.INotification,\n ) => void | Promise<void>;\n onClickHandler: (\n e: NotificationEvent,\n notification: Types.INotification,\n ) => void;\n messenger: NotificationServicesPushControllerMessenger;\n}) {\n return async function (env: PushNotificationEnv) {\n const onBackgroundMessageSub = await listenToPushNotificationsReceived(\n env,\n async (notification) => {\n props.messenger.publish(\n 'NotificationServicesPushController:onNewNotifications',\n notification,\n );\n await props.onReceivedHandler(notification);\n },\n );\n const onClickSub = listenToPushNotificationsClicked(\n (event, notification) => {\n props.messenger.publish(\n 'NotificationServicesPushController:pushNotificationClicked',\n notification,\n );\n props.onClickHandler(event, notification);\n },\n );\n\n const unsubscribe = () => {\n onBackgroundMessageSub?.();\n onClickSub();\n };\n\n return unsubscribe;\n };\n}\n"]}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/// <reference lib="webworker" />
|
|
2
|
-
import type { Types } from "../../NotificationServicesController/index.cjs";
|
|
3
|
-
import type { NotificationServicesPushControllerMessenger } from "../NotificationServicesPushController.cjs";
|
|
4
|
-
import type { PushNotificationEnv } from "../types/firebase.cjs";
|
|
5
|
-
export declare let supportedCache: boolean | null;
|
|
6
|
-
/**
|
|
7
|
-
* Creates a registration token for Firebase Cloud Messaging.
|
|
8
|
-
*
|
|
9
|
-
* @param env - env to configure push notifications
|
|
10
|
-
* @returns A promise that resolves with the registration token or null if an error occurs.
|
|
11
|
-
*/
|
|
12
|
-
export declare function createRegToken(env: PushNotificationEnv): Promise<string | null>;
|
|
13
|
-
/**
|
|
14
|
-
* Deletes the Firebase Cloud Messaging registration token.
|
|
15
|
-
*
|
|
16
|
-
* @param env - env to configure push notifications
|
|
17
|
-
* @returns A promise that resolves with true if the token was successfully deleted, false otherwise.
|
|
18
|
-
*/
|
|
19
|
-
export declare function deleteRegToken(env: PushNotificationEnv): Promise<boolean>;
|
|
20
|
-
/**
|
|
21
|
-
* A creator function that assists creating web-specific push notification subscription:
|
|
22
|
-
* 1. Creates subscriptions for receiving and clicking notifications
|
|
23
|
-
* 2. Creates click events when a notification is clicked
|
|
24
|
-
* 3. Publishes controller messenger events
|
|
25
|
-
*
|
|
26
|
-
* @param props - props for this creator function.
|
|
27
|
-
* @param props.onReceivedHandler - allows the developer to handle showing a notification
|
|
28
|
-
* @param props.onClickHandler - allows the developer to handle clicking the notification
|
|
29
|
-
* @param props.messenger - the controller messenger to publish the `onNewNotifications` and `pushNotificationsClicked` events
|
|
30
|
-
* @returns a function that can be used by the controller
|
|
31
|
-
*/
|
|
32
|
-
export declare function createSubscribeToPushNotifications(props: {
|
|
33
|
-
onReceivedHandler: (notification: Types.INotification) => void | Promise<void>;
|
|
34
|
-
onClickHandler: (e: NotificationEvent, notification: Types.INotification) => void;
|
|
35
|
-
messenger: NotificationServicesPushControllerMessenger;
|
|
36
|
-
}): (env: PushNotificationEnv) => Promise<() => void>;
|
|
37
|
-
//# sourceMappingURL=push-utils.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"push-utils.d.cts","sourceRoot":"","sources":["../../../src/NotificationServicesPushController/web/push-utils.ts"],"names":[],"mappings":";AAcA,OAAO,KAAK,EAAE,KAAK,EAAE,uDAA6C;AAGlE,OAAO,KAAK,EAAE,2CAA2C,EAAE,kDAA8C;AACzG,OAAO,KAAK,EAAE,mBAAmB,EAAE,8BAA0B;AAM7D,eAAO,IAAI,cAAc,EAAE,OAAO,GAAG,IAAW,CAAC;AAsCjD;;;;;GAKG;AACH,wBAAsB,cAAc,CAClC,GAAG,EAAE,mBAAmB,GACvB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAexB;AAED;;;;;GAKG;AACH,wBAAsB,cAAc,CAClC,GAAG,EAAE,mBAAmB,GACvB,OAAO,CAAC,OAAO,CAAC,CAYlB;AAqED;;;;;;;;;;;GAWG;AACH,wBAAgB,kCAAkC,CAAC,KAAK,EAAE;IACxD,iBAAiB,EAAE,CACjB,YAAY,EAAE,KAAK,CAAC,aAAa,KAC9B,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1B,cAAc,EAAE,CACd,CAAC,EAAE,iBAAiB,EACpB,YAAY,EAAE,KAAK,CAAC,aAAa,KAC9B,IAAI,CAAC;IACV,SAAS,EAAE,2CAA2C,CAAC;CACxD,SAC6B,mBAAmB,yBA4BhD"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/// <reference lib="webworker" />
|
|
2
|
-
import type { Types } from "../../NotificationServicesController/index.mjs";
|
|
3
|
-
import type { NotificationServicesPushControllerMessenger } from "../NotificationServicesPushController.mjs";
|
|
4
|
-
import type { PushNotificationEnv } from "../types/firebase.mjs";
|
|
5
|
-
export declare let supportedCache: boolean | null;
|
|
6
|
-
/**
|
|
7
|
-
* Creates a registration token for Firebase Cloud Messaging.
|
|
8
|
-
*
|
|
9
|
-
* @param env - env to configure push notifications
|
|
10
|
-
* @returns A promise that resolves with the registration token or null if an error occurs.
|
|
11
|
-
*/
|
|
12
|
-
export declare function createRegToken(env: PushNotificationEnv): Promise<string | null>;
|
|
13
|
-
/**
|
|
14
|
-
* Deletes the Firebase Cloud Messaging registration token.
|
|
15
|
-
*
|
|
16
|
-
* @param env - env to configure push notifications
|
|
17
|
-
* @returns A promise that resolves with true if the token was successfully deleted, false otherwise.
|
|
18
|
-
*/
|
|
19
|
-
export declare function deleteRegToken(env: PushNotificationEnv): Promise<boolean>;
|
|
20
|
-
/**
|
|
21
|
-
* A creator function that assists creating web-specific push notification subscription:
|
|
22
|
-
* 1. Creates subscriptions for receiving and clicking notifications
|
|
23
|
-
* 2. Creates click events when a notification is clicked
|
|
24
|
-
* 3. Publishes controller messenger events
|
|
25
|
-
*
|
|
26
|
-
* @param props - props for this creator function.
|
|
27
|
-
* @param props.onReceivedHandler - allows the developer to handle showing a notification
|
|
28
|
-
* @param props.onClickHandler - allows the developer to handle clicking the notification
|
|
29
|
-
* @param props.messenger - the controller messenger to publish the `onNewNotifications` and `pushNotificationsClicked` events
|
|
30
|
-
* @returns a function that can be used by the controller
|
|
31
|
-
*/
|
|
32
|
-
export declare function createSubscribeToPushNotifications(props: {
|
|
33
|
-
onReceivedHandler: (notification: Types.INotification) => void | Promise<void>;
|
|
34
|
-
onClickHandler: (e: NotificationEvent, notification: Types.INotification) => void;
|
|
35
|
-
messenger: NotificationServicesPushControllerMessenger;
|
|
36
|
-
}): (env: PushNotificationEnv) => Promise<() => void>;
|
|
37
|
-
//# sourceMappingURL=push-utils.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"push-utils.d.mts","sourceRoot":"","sources":["../../../src/NotificationServicesPushController/web/push-utils.ts"],"names":[],"mappings":";AAcA,OAAO,KAAK,EAAE,KAAK,EAAE,uDAA6C;AAGlE,OAAO,KAAK,EAAE,2CAA2C,EAAE,kDAA8C;AACzG,OAAO,KAAK,EAAE,mBAAmB,EAAE,8BAA0B;AAM7D,eAAO,IAAI,cAAc,EAAE,OAAO,GAAG,IAAW,CAAC;AAsCjD;;;;;GAKG;AACH,wBAAsB,cAAc,CAClC,GAAG,EAAE,mBAAmB,GACvB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAexB;AAED;;;;;GAKG;AACH,wBAAsB,cAAc,CAClC,GAAG,EAAE,mBAAmB,GACvB,OAAO,CAAC,OAAO,CAAC,CAYlB;AAqED;;;;;;;;;;;GAWG;AACH,wBAAgB,kCAAkC,CAAC,KAAK,EAAE;IACxD,iBAAiB,EAAE,CACjB,YAAY,EAAE,KAAK,CAAC,aAAa,KAC9B,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1B,cAAc,EAAE,CACd,CAAC,EAAE,iBAAiB,EACpB,YAAY,EAAE,KAAK,CAAC,aAAa,KAC9B,IAAI,CAAC;IACV,SAAS,EAAE,2CAA2C,CAAC;CACxD,SAC6B,mBAAmB,yBA4BhD"}
|
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
function $importDefault(module) {
|
|
2
|
-
if (module?.__esModule) {
|
|
3
|
-
return module.default;
|
|
4
|
-
}
|
|
5
|
-
return module;
|
|
6
|
-
}
|
|
7
|
-
import { getApp, initializeApp } from "firebase/app";
|
|
8
|
-
import { getToken, deleteToken } from "firebase/messaging";
|
|
9
|
-
import { getMessaging, onBackgroundMessage, isSupported } from "firebase/messaging/sw";
|
|
10
|
-
import $log from "loglevel";
|
|
11
|
-
const log = $importDefault($log);
|
|
12
|
-
import { Processors } from "../../NotificationServicesController/index.mjs";
|
|
13
|
-
import { toRawOnChainNotification } from "../../shared/to-raw-notification.mjs";
|
|
14
|
-
// Exported to help testing
|
|
15
|
-
// eslint-disable-next-line import-x/no-mutable-exports
|
|
16
|
-
export let supportedCache = null;
|
|
17
|
-
const getPushAvailability = async () => {
|
|
18
|
-
supportedCache ?? (supportedCache = await isSupported());
|
|
19
|
-
return supportedCache;
|
|
20
|
-
};
|
|
21
|
-
const createFirebaseApp = async (env) => {
|
|
22
|
-
try {
|
|
23
|
-
return getApp();
|
|
24
|
-
}
|
|
25
|
-
catch {
|
|
26
|
-
const firebaseConfig = {
|
|
27
|
-
apiKey: env.apiKey,
|
|
28
|
-
authDomain: env.authDomain,
|
|
29
|
-
storageBucket: env.storageBucket,
|
|
30
|
-
projectId: env.projectId,
|
|
31
|
-
messagingSenderId: env.messagingSenderId,
|
|
32
|
-
appId: env.appId,
|
|
33
|
-
measurementId: env.measurementId,
|
|
34
|
-
};
|
|
35
|
-
return initializeApp(firebaseConfig);
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
const getFirebaseMessaging = async (env) => {
|
|
39
|
-
const supported = await getPushAvailability();
|
|
40
|
-
if (!supported) {
|
|
41
|
-
return null;
|
|
42
|
-
}
|
|
43
|
-
const app = await createFirebaseApp(env);
|
|
44
|
-
return getMessaging(app);
|
|
45
|
-
};
|
|
46
|
-
/**
|
|
47
|
-
* Creates a registration token for Firebase Cloud Messaging.
|
|
48
|
-
*
|
|
49
|
-
* @param env - env to configure push notifications
|
|
50
|
-
* @returns A promise that resolves with the registration token or null if an error occurs.
|
|
51
|
-
*/
|
|
52
|
-
export async function createRegToken(env) {
|
|
53
|
-
try {
|
|
54
|
-
const messaging = await getFirebaseMessaging(env);
|
|
55
|
-
if (!messaging) {
|
|
56
|
-
return null;
|
|
57
|
-
}
|
|
58
|
-
const token = await getToken(messaging, {
|
|
59
|
-
serviceWorkerRegistration: self.registration,
|
|
60
|
-
vapidKey: env.vapidKey,
|
|
61
|
-
});
|
|
62
|
-
return token;
|
|
63
|
-
}
|
|
64
|
-
catch {
|
|
65
|
-
return null;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Deletes the Firebase Cloud Messaging registration token.
|
|
70
|
-
*
|
|
71
|
-
* @param env - env to configure push notifications
|
|
72
|
-
* @returns A promise that resolves with true if the token was successfully deleted, false otherwise.
|
|
73
|
-
*/
|
|
74
|
-
export async function deleteRegToken(env) {
|
|
75
|
-
try {
|
|
76
|
-
const messaging = await getFirebaseMessaging(env);
|
|
77
|
-
if (!messaging) {
|
|
78
|
-
return true;
|
|
79
|
-
}
|
|
80
|
-
await deleteToken(messaging);
|
|
81
|
-
return true;
|
|
82
|
-
}
|
|
83
|
-
catch {
|
|
84
|
-
return false;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Service Worker Listener for when push notifications are received.
|
|
89
|
-
*
|
|
90
|
-
* @param env - push notification environment
|
|
91
|
-
* @param handler - handler to actually showing notification, MUST BE PROVIDED
|
|
92
|
-
* @returns unsubscribe handler
|
|
93
|
-
*/
|
|
94
|
-
async function listenToPushNotificationsReceived(env, handler) {
|
|
95
|
-
const messaging = await getFirebaseMessaging(env);
|
|
96
|
-
if (!messaging) {
|
|
97
|
-
return null;
|
|
98
|
-
}
|
|
99
|
-
const unsubscribePushNotifications = onBackgroundMessage(messaging,
|
|
100
|
-
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
101
|
-
async (payload) => {
|
|
102
|
-
try {
|
|
103
|
-
const data = payload?.data?.data ? JSON.parse(payload?.data?.data) : undefined;
|
|
104
|
-
if (!data) {
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
const notificationData = toRawOnChainNotification(data);
|
|
108
|
-
const notification = Processors.processNotification(notificationData);
|
|
109
|
-
await handler(notification);
|
|
110
|
-
}
|
|
111
|
-
catch (error) {
|
|
112
|
-
// Do Nothing, cannot parse a bad notification
|
|
113
|
-
log.error('Unable to send push notification:', {
|
|
114
|
-
notification: payload?.data?.data,
|
|
115
|
-
error,
|
|
116
|
-
});
|
|
117
|
-
throw new Error('Unable to send push notification');
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
const unsubscribe = () => unsubscribePushNotifications();
|
|
121
|
-
return unsubscribe;
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Service Worker Listener for when a notification is clicked
|
|
125
|
-
*
|
|
126
|
-
* @param handler - listen to NotificationEvent from the service worker
|
|
127
|
-
* @returns unsubscribe handler
|
|
128
|
-
*/
|
|
129
|
-
function listenToPushNotificationsClicked(handler) {
|
|
130
|
-
const clickHandler = (event) => {
|
|
131
|
-
// Get Data
|
|
132
|
-
const data = event?.notification?.data;
|
|
133
|
-
handler(event, data);
|
|
134
|
-
};
|
|
135
|
-
self.addEventListener('notificationclick', clickHandler);
|
|
136
|
-
const unsubscribe = () => self.removeEventListener('notificationclick', clickHandler);
|
|
137
|
-
return unsubscribe;
|
|
138
|
-
}
|
|
139
|
-
/**
|
|
140
|
-
* A creator function that assists creating web-specific push notification subscription:
|
|
141
|
-
* 1. Creates subscriptions for receiving and clicking notifications
|
|
142
|
-
* 2. Creates click events when a notification is clicked
|
|
143
|
-
* 3. Publishes controller messenger events
|
|
144
|
-
*
|
|
145
|
-
* @param props - props for this creator function.
|
|
146
|
-
* @param props.onReceivedHandler - allows the developer to handle showing a notification
|
|
147
|
-
* @param props.onClickHandler - allows the developer to handle clicking the notification
|
|
148
|
-
* @param props.messenger - the controller messenger to publish the `onNewNotifications` and `pushNotificationsClicked` events
|
|
149
|
-
* @returns a function that can be used by the controller
|
|
150
|
-
*/
|
|
151
|
-
export function createSubscribeToPushNotifications(props) {
|
|
152
|
-
return async function (env) {
|
|
153
|
-
const onBackgroundMessageSub = await listenToPushNotificationsReceived(env, async (notification) => {
|
|
154
|
-
props.messenger.publish('NotificationServicesPushController:onNewNotifications', notification);
|
|
155
|
-
await props.onReceivedHandler(notification);
|
|
156
|
-
});
|
|
157
|
-
const onClickSub = listenToPushNotificationsClicked((event, notification) => {
|
|
158
|
-
props.messenger.publish('NotificationServicesPushController:pushNotificationClicked', notification);
|
|
159
|
-
props.onClickHandler(event, notification);
|
|
160
|
-
});
|
|
161
|
-
const unsubscribe = () => {
|
|
162
|
-
onBackgroundMessageSub?.();
|
|
163
|
-
onClickSub();
|
|
164
|
-
};
|
|
165
|
-
return unsubscribe;
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
//# sourceMappingURL=push-utils.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"push-utils.mjs","sourceRoot":"","sources":["../../../src/NotificationServicesPushController/web/push-utils.ts"],"names":[],"mappings":";;;;;;AAIA,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,qBAAqB;AACrD,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,2BAA2B;AAC3D,OAAO,EACL,YAAY,EACZ,mBAAmB,EACnB,WAAW,EACZ,8BAA8B;AAE/B,OAAO,IAAG,iBAAiB;;AAG3B,OAAO,EAAE,UAAU,EAAE,uDAA6C;AAClE,OAAO,EAAE,wBAAwB,EAAE,6CAAyC;AAM5E,2BAA2B;AAC3B,uDAAuD;AACvD,MAAM,CAAC,IAAI,cAAc,GAAmB,IAAI,CAAC;AAEjD,MAAM,mBAAmB,GAAG,KAAK,IAAI,EAAE;IACrC,cAAc,KAAd,cAAc,GAAK,MAAM,WAAW,EAAE,EAAC;IACvC,OAAO,cAAc,CAAC;AACxB,CAAC,CAAC;AAEF,MAAM,iBAAiB,GAAG,KAAK,EAC7B,GAAwB,EACF,EAAE;IACxB,IAAI;QACF,OAAO,MAAM,EAAE,CAAC;KACjB;IAAC,MAAM;QACN,MAAM,cAAc,GAAG;YACrB,MAAM,EAAE,GAAG,CAAC,MAAM;YAClB,UAAU,EAAE,GAAG,CAAC,UAAU;YAC1B,aAAa,EAAE,GAAG,CAAC,aAAa;YAChC,SAAS,EAAE,GAAG,CAAC,SAAS;YACxB,iBAAiB,EAAE,GAAG,CAAC,iBAAiB;YACxC,KAAK,EAAE,GAAG,CAAC,KAAK;YAChB,aAAa,EAAE,GAAG,CAAC,aAAa;SACjC,CAAC;QACF,OAAO,aAAa,CAAC,cAAc,CAAC,CAAC;KACtC;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,CAAC,CAAC;IAC9D,OAAO,WAAW,CAAC;AACrB,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,kCAAkC,CAAC,KASlD;IACC,OAAO,KAAK,WAAW,GAAwB;QAC7C,MAAM,sBAAsB,GAAG,MAAM,iCAAiC,CACpE,GAAG,EACH,KAAK,EAAE,YAAY,EAAE,EAAE;YACrB,KAAK,CAAC,SAAS,CAAC,OAAO,CACrB,uDAAuD,EACvD,YAAY,CACb,CAAC;YACF,MAAM,KAAK,CAAC,iBAAiB,CAAC,YAAY,CAAC,CAAC;QAC9C,CAAC,CACF,CAAC;QACF,MAAM,UAAU,GAAG,gCAAgC,CACjD,CAAC,KAAK,EAAE,YAAY,EAAE,EAAE;YACtB,KAAK,CAAC,SAAS,CAAC,OAAO,CACrB,4DAA4D,EAC5D,YAAY,CACb,CAAC;YACF,KAAK,CAAC,cAAc,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;QAC5C,CAAC,CACF,CAAC;QAEF,MAAM,WAAW,GAAG,GAAG,EAAE;YACvB,sBAAsB,EAAE,EAAE,CAAC;YAC3B,UAAU,EAAE,CAAC;QACf,CAAC,CAAC;QAEF,OAAO,WAAW,CAAC;IACrB,CAAC,CAAC;AACJ,CAAC","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 {\n getMessaging,\n onBackgroundMessage,\n isSupported,\n} from 'firebase/messaging/sw';\nimport type { Messaging, MessagePayload } from 'firebase/messaging/sw';\nimport log from 'loglevel';\n\nimport type { Types } from '../../NotificationServicesController';\nimport { Processors } from '../../NotificationServicesController';\nimport { toRawOnChainNotification } from '../../shared/to-raw-notification';\nimport type { NotificationServicesPushControllerMessenger } from '../NotificationServicesPushController';\nimport type { PushNotificationEnv } from '../types/firebase';\n\ndeclare const self: ServiceWorkerGlobalScope;\n\n// Exported to help testing\n// eslint-disable-next-line import-x/no-mutable-exports\nexport let supportedCache: boolean | null = null;\n\nconst getPushAvailability = async () => {\n supportedCache ??= await isSupported();\n return supportedCache;\n};\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 | null> => {\n const supported = await getPushAvailability();\n if (!supported) {\n return null;\n }\n\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 if (!messaging) {\n return null;\n }\n\n const token = await getToken(messaging, {\n serviceWorkerRegistration: self.registration,\n vapidKey: env.vapidKey,\n });\n return token;\n } catch {\n return null;\n }\n}\n\n/**\n * Deletes the Firebase Cloud Messaging registration token.\n *\n * @param env - env to configure push notifications\n * @returns A promise that resolves with true if the token was successfully deleted, false otherwise.\n */\nexport async function deleteRegToken(\n env: PushNotificationEnv,\n): Promise<boolean> {\n try {\n const messaging = await getFirebaseMessaging(env);\n if (!messaging) {\n return true;\n }\n\n await deleteToken(messaging);\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * Service Worker Listener for when push notifications are received.\n *\n * @param env - push notification environment\n * @param handler - handler to actually showing notification, MUST BE PROVIDED\n * @returns unsubscribe handler\n */\nasync function listenToPushNotificationsReceived(\n env: PushNotificationEnv,\n handler: (notification: Types.INotification) => void | Promise<void>,\n): Promise<(() => void) | null> {\n const messaging = await getFirebaseMessaging(env);\n if (!messaging) {\n return null;\n }\n\n const unsubscribePushNotifications = onBackgroundMessage(\n messaging,\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n async (payload: MessagePayload) => {\n try {\n const data: Types.UnprocessedOnChainRawNotification | undefined =\n payload?.data?.data ? JSON.parse(payload?.data?.data) : undefined;\n\n if (!data) {\n return;\n }\n\n const notificationData = toRawOnChainNotification(data);\n const notification = Processors.processNotification(notificationData);\n await handler(notification);\n } catch (error) {\n // Do Nothing, cannot parse a bad notification\n log.error('Unable to send push notification:', {\n notification: payload?.data?.data,\n error,\n });\n throw new Error('Unable to send push notification');\n }\n },\n );\n\n const unsubscribe = () => unsubscribePushNotifications();\n return unsubscribe;\n}\n\n/**\n * Service Worker Listener for when a notification is clicked\n *\n * @param handler - listen to NotificationEvent from the service worker\n * @returns unsubscribe handler\n */\nfunction listenToPushNotificationsClicked(\n handler: (e: NotificationEvent, notification: Types.INotification) => void,\n) {\n const clickHandler = (event: NotificationEvent) => {\n // Get Data\n const data: Types.INotification = event?.notification?.data;\n handler(event, data);\n };\n\n self.addEventListener('notificationclick', clickHandler);\n const unsubscribe = () =>\n self.removeEventListener('notificationclick', clickHandler);\n return unsubscribe;\n}\n\n/**\n * A creator function that assists creating web-specific push notification subscription:\n * 1. Creates subscriptions for receiving and clicking notifications\n * 2. Creates click events when a notification is clicked\n * 3. Publishes controller messenger events\n *\n * @param props - props for this creator function.\n * @param props.onReceivedHandler - allows the developer to handle showing a notification\n * @param props.onClickHandler - allows the developer to handle clicking the notification\n * @param props.messenger - the controller messenger to publish the `onNewNotifications` and `pushNotificationsClicked` events\n * @returns a function that can be used by the controller\n */\nexport function createSubscribeToPushNotifications(props: {\n onReceivedHandler: (\n notification: Types.INotification,\n ) => void | Promise<void>;\n onClickHandler: (\n e: NotificationEvent,\n notification: Types.INotification,\n ) => void;\n messenger: NotificationServicesPushControllerMessenger;\n}) {\n return async function (env: PushNotificationEnv) {\n const onBackgroundMessageSub = await listenToPushNotificationsReceived(\n env,\n async (notification) => {\n props.messenger.publish(\n 'NotificationServicesPushController:onNewNotifications',\n notification,\n );\n await props.onReceivedHandler(notification);\n },\n );\n const onClickSub = listenToPushNotificationsClicked(\n (event, notification) => {\n props.messenger.publish(\n 'NotificationServicesPushController:pushNotificationClicked',\n notification,\n );\n props.onClickHandler(event, notification);\n },\n );\n\n const unsubscribe = () => {\n onBackgroundMessageSub?.();\n onClickSub();\n };\n\n return unsubscribe;\n };\n}\n"]}
|
package/dist/shared/index.cjs
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./is-onchain-notification.cjs"), exports);
|
|
18
|
-
__exportStar(require("./to-raw-notification.cjs"), exports);
|
|
19
|
-
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../src/shared/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gEAA0C;AAC1C,4DAAsC","sourcesContent":["export * from './is-onchain-notification';\nexport * from './to-raw-notification';\n"]}
|
package/dist/shared/index.d.cts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../src/shared/index.ts"],"names":[],"mappings":"AAAA,8CAA0C;AAC1C,0CAAsC"}
|
package/dist/shared/index.d.mts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../src/shared/index.ts"],"names":[],"mappings":"AAAA,8CAA0C;AAC1C,0CAAsC"}
|
package/dist/shared/index.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../src/shared/index.ts"],"names":[],"mappings":"AAAA,8CAA0C;AAC1C,0CAAsC","sourcesContent":["export * from './is-onchain-notification';\nexport * from './to-raw-notification';\n"]}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isOnChainRawNotification = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Checks if the given value is an OnChainRawNotification object.
|
|
6
|
-
*
|
|
7
|
-
* @param n - The value to check.
|
|
8
|
-
* @returns True if the value is an OnChainRawNotification object, false otherwise.
|
|
9
|
-
*/
|
|
10
|
-
function isOnChainRawNotification(n) {
|
|
11
|
-
const assumed = n;
|
|
12
|
-
// We don't have a validation/parsing library to check all possible types of an on chain notification
|
|
13
|
-
// It is safe enough just to check "some" fields, and catch any errors down the line if the shape is bad.
|
|
14
|
-
const isValidEnoughToBeOnChainNotification = [
|
|
15
|
-
assumed?.id,
|
|
16
|
-
assumed?.data,
|
|
17
|
-
assumed?.trigger_id,
|
|
18
|
-
].every((field) => field !== undefined);
|
|
19
|
-
return isValidEnoughToBeOnChainNotification;
|
|
20
|
-
}
|
|
21
|
-
exports.isOnChainRawNotification = isOnChainRawNotification;
|
|
22
|
-
//# sourceMappingURL=is-onchain-notification.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"is-onchain-notification.cjs","sourceRoot":"","sources":["../../src/shared/is-onchain-notification.ts"],"names":[],"mappings":";;;AAEA;;;;;GAKG;AACH,SAAgB,wBAAwB,CACtC,CAAU;IAEV,MAAM,OAAO,GAAG,CAA2B,CAAC;IAE5C,qGAAqG;IACrG,yGAAyG;IACzG,MAAM,oCAAoC,GAAG;QAC3C,OAAO,EAAE,EAAE;QACX,OAAO,EAAE,IAAI;QACb,OAAO,EAAE,UAAU;KACpB,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC;IACxC,OAAO,oCAAoC,CAAC;AAC9C,CAAC;AAbD,4DAaC","sourcesContent":["import type { OnChainRawNotification } from '../NotificationServicesController';\n\n/**\n * Checks if the given value is an OnChainRawNotification object.\n *\n * @param n - The value to check.\n * @returns True if the value is an OnChainRawNotification object, false otherwise.\n */\nexport function isOnChainRawNotification(\n n: unknown,\n): n is OnChainRawNotification {\n const assumed = n as OnChainRawNotification;\n\n // We don't have a validation/parsing library to check all possible types of an on chain notification\n // It is safe enough just to check \"some\" fields, and catch any errors down the line if the shape is bad.\n const isValidEnoughToBeOnChainNotification = [\n assumed?.id,\n assumed?.data,\n assumed?.trigger_id,\n ].every((field) => field !== undefined);\n return isValidEnoughToBeOnChainNotification;\n}\n"]}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { OnChainRawNotification } from "../NotificationServicesController/index.cjs";
|
|
2
|
-
/**
|
|
3
|
-
* Checks if the given value is an OnChainRawNotification object.
|
|
4
|
-
*
|
|
5
|
-
* @param n - The value to check.
|
|
6
|
-
* @returns True if the value is an OnChainRawNotification object, false otherwise.
|
|
7
|
-
*/
|
|
8
|
-
export declare function isOnChainRawNotification(n: unknown): n is OnChainRawNotification;
|
|
9
|
-
//# sourceMappingURL=is-onchain-notification.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"is-onchain-notification.d.cts","sourceRoot":"","sources":["../../src/shared/is-onchain-notification.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,oDAA0C;AAEhF;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,CAAC,EAAE,OAAO,GACT,CAAC,IAAI,sBAAsB,CAW7B"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { OnChainRawNotification } from "../NotificationServicesController/index.mjs";
|
|
2
|
-
/**
|
|
3
|
-
* Checks if the given value is an OnChainRawNotification object.
|
|
4
|
-
*
|
|
5
|
-
* @param n - The value to check.
|
|
6
|
-
* @returns True if the value is an OnChainRawNotification object, false otherwise.
|
|
7
|
-
*/
|
|
8
|
-
export declare function isOnChainRawNotification(n: unknown): n is OnChainRawNotification;
|
|
9
|
-
//# sourceMappingURL=is-onchain-notification.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"is-onchain-notification.d.mts","sourceRoot":"","sources":["../../src/shared/is-onchain-notification.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,oDAA0C;AAEhF;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,CAAC,EAAE,OAAO,GACT,CAAC,IAAI,sBAAsB,CAW7B"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Checks if the given value is an OnChainRawNotification object.
|
|
3
|
-
*
|
|
4
|
-
* @param n - The value to check.
|
|
5
|
-
* @returns True if the value is an OnChainRawNotification object, false otherwise.
|
|
6
|
-
*/
|
|
7
|
-
export function isOnChainRawNotification(n) {
|
|
8
|
-
const assumed = n;
|
|
9
|
-
// We don't have a validation/parsing library to check all possible types of an on chain notification
|
|
10
|
-
// It is safe enough just to check "some" fields, and catch any errors down the line if the shape is bad.
|
|
11
|
-
const isValidEnoughToBeOnChainNotification = [
|
|
12
|
-
assumed?.id,
|
|
13
|
-
assumed?.data,
|
|
14
|
-
assumed?.trigger_id,
|
|
15
|
-
].every((field) => field !== undefined);
|
|
16
|
-
return isValidEnoughToBeOnChainNotification;
|
|
17
|
-
}
|
|
18
|
-
//# sourceMappingURL=is-onchain-notification.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"is-onchain-notification.mjs","sourceRoot":"","sources":["../../src/shared/is-onchain-notification.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,UAAU,wBAAwB,CACtC,CAAU;IAEV,MAAM,OAAO,GAAG,CAA2B,CAAC;IAE5C,qGAAqG;IACrG,yGAAyG;IACzG,MAAM,oCAAoC,GAAG;QAC3C,OAAO,EAAE,EAAE;QACX,OAAO,EAAE,IAAI;QACb,OAAO,EAAE,UAAU;KACpB,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC;IACxC,OAAO,oCAAoC,CAAC;AAC9C,CAAC","sourcesContent":["import type { OnChainRawNotification } from '../NotificationServicesController';\n\n/**\n * Checks if the given value is an OnChainRawNotification object.\n *\n * @param n - The value to check.\n * @returns True if the value is an OnChainRawNotification object, false otherwise.\n */\nexport function isOnChainRawNotification(\n n: unknown,\n): n is OnChainRawNotification {\n const assumed = n as OnChainRawNotification;\n\n // We don't have a validation/parsing library to check all possible types of an on chain notification\n // It is safe enough just to check \"some\" fields, and catch any errors down the line if the shape is bad.\n const isValidEnoughToBeOnChainNotification = [\n assumed?.id,\n assumed?.data,\n assumed?.trigger_id,\n ].every((field) => field !== undefined);\n return isValidEnoughToBeOnChainNotification;\n}\n"]}
|
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@metamask/notification-services-controller",
|
|
3
|
-
"version": "0.18.0",
|
|
4
|
-
"description": "Manages New MetaMask decentralized Notification system",
|
|
5
|
-
"keywords": [
|
|
6
|
-
"MetaMask",
|
|
7
|
-
"Ethereum"
|
|
8
|
-
],
|
|
9
|
-
"homepage": "https://github.com/MetaMask/core/tree/main/packages/notification-services-controller#readme",
|
|
10
|
-
"bugs": {
|
|
11
|
-
"url": "https://github.com/MetaMask/core/issues"
|
|
12
|
-
},
|
|
13
|
-
"repository": {
|
|
14
|
-
"type": "git",
|
|
15
|
-
"url": "https://github.com/MetaMask/core.git"
|
|
16
|
-
},
|
|
17
|
-
"license": "MIT",
|
|
18
|
-
"sideEffects": false,
|
|
19
|
-
"exports": {
|
|
20
|
-
".": {
|
|
21
|
-
"import": {
|
|
22
|
-
"types": "./dist/index.d.mts",
|
|
23
|
-
"default": "./dist/index.mjs"
|
|
24
|
-
},
|
|
25
|
-
"require": {
|
|
26
|
-
"types": "./dist/index.d.cts",
|
|
27
|
-
"default": "./dist/index.cjs"
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
"./notification-services": {
|
|
31
|
-
"import": {
|
|
32
|
-
"types": "./dist/NotificationServicesController/index.d.mts",
|
|
33
|
-
"default": "./dist/NotificationServicesController/index.mjs"
|
|
34
|
-
},
|
|
35
|
-
"require": {
|
|
36
|
-
"types": "./dist/NotificationServicesController/index.d.cts",
|
|
37
|
-
"default": "./dist/NotificationServicesController/index.cjs"
|
|
38
|
-
}
|
|
39
|
-
},
|
|
40
|
-
"./notification-services/ui": {
|
|
41
|
-
"import": {
|
|
42
|
-
"types": "./dist/NotificationServicesController/ui/index.d.mts",
|
|
43
|
-
"default": "./dist/NotificationServicesController/ui/index.mjs"
|
|
44
|
-
},
|
|
45
|
-
"require": {
|
|
46
|
-
"types": "./dist/NotificationServicesController/ui/index.d.cts",
|
|
47
|
-
"default": "./dist/NotificationServicesController/ui/index.cjs"
|
|
48
|
-
}
|
|
49
|
-
},
|
|
50
|
-
"./notification-services/mocks": {
|
|
51
|
-
"import": {
|
|
52
|
-
"types": "./dist/NotificationServicesController/__fixtures__/index.d.mts",
|
|
53
|
-
"default": "./dist/NotificationServicesController/__fixtures__/index.mjs"
|
|
54
|
-
},
|
|
55
|
-
"require": {
|
|
56
|
-
"types": "./dist/NotificationServicesController/__fixtures__/index.d.cts",
|
|
57
|
-
"default": "./dist/NotificationServicesController/__fixtures__/index.cjs"
|
|
58
|
-
}
|
|
59
|
-
},
|
|
60
|
-
"./push-services": {
|
|
61
|
-
"import": {
|
|
62
|
-
"types": "./dist/NotificationServicesPushController/index.d.mts",
|
|
63
|
-
"default": "./dist/NotificationServicesPushController/index.mjs"
|
|
64
|
-
},
|
|
65
|
-
"require": {
|
|
66
|
-
"types": "./dist/NotificationServicesPushController/index.d.cts",
|
|
67
|
-
"default": "./dist/NotificationServicesPushController/index.cjs"
|
|
68
|
-
}
|
|
69
|
-
},
|
|
70
|
-
"./push-services/web": {
|
|
71
|
-
"import": {
|
|
72
|
-
"types": "./dist/NotificationServicesPushController/web/index.d.mts",
|
|
73
|
-
"default": "./dist/NotificationServicesPushController/web/index.mjs"
|
|
74
|
-
},
|
|
75
|
-
"require": {
|
|
76
|
-
"types": "./dist/NotificationServicesPushController/web/index.d.cts",
|
|
77
|
-
"default": "./dist/NotificationServicesPushController/web/index.cjs"
|
|
78
|
-
}
|
|
79
|
-
},
|
|
80
|
-
"./push-services/mocks": {
|
|
81
|
-
"import": {
|
|
82
|
-
"types": "./dist/NotificationServicesPushController/__fixtures__/index.d.mts",
|
|
83
|
-
"default": "./dist/NotificationServicesPushController/__fixtures__/index.mjs"
|
|
84
|
-
},
|
|
85
|
-
"require": {
|
|
86
|
-
"types": "./dist/NotificationServicesPushController/__fixtures__/index.d.cts",
|
|
87
|
-
"default": "./dist/NotificationServicesPushController/__fixtures__/index.cjs"
|
|
88
|
-
}
|
|
89
|
-
},
|
|
90
|
-
"./package.json": "./package.json"
|
|
91
|
-
},
|
|
92
|
-
"main": "./dist/index.cjs",
|
|
93
|
-
"types": "./dist/index.d.cts",
|
|
94
|
-
"files": [
|
|
95
|
-
"dist/",
|
|
96
|
-
"notification-services/",
|
|
97
|
-
"push-services/"
|
|
98
|
-
],
|
|
99
|
-
"scripts": {
|
|
100
|
-
"build": "ts-bridge --project tsconfig.build.json --verbose --clean --no-references",
|
|
101
|
-
"build:docs": "typedoc",
|
|
102
|
-
"changelog:update": "../../scripts/update-changelog.sh @metamask/notification-services-controller",
|
|
103
|
-
"changelog:validate": "../../scripts/validate-changelog.sh @metamask/notification-services-controller",
|
|
104
|
-
"publish:preview": "yarn npm publish --tag preview",
|
|
105
|
-
"since-latest-release": "../../scripts/since-latest-release.sh",
|
|
106
|
-
"test": "NODE_OPTIONS=--experimental-vm-modules jest --reporters=jest-silent-reporter",
|
|
107
|
-
"test:clean": "NODE_OPTIONS=--experimental-vm-modules jest --clearCache",
|
|
108
|
-
"test:verbose": "NODE_OPTIONS=--experimental-vm-modules jest --verbose",
|
|
109
|
-
"test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch"
|
|
110
|
-
},
|
|
111
|
-
"dependencies": {
|
|
112
|
-
"@contentful/rich-text-html-renderer": "^16.5.2",
|
|
113
|
-
"@metamask/base-controller": "^7.1.1",
|
|
114
|
-
"@metamask/controller-utils": "^11.4.5",
|
|
115
|
-
"@metamask/utils": "^11.0.1",
|
|
116
|
-
"bignumber.js": "^9.1.2",
|
|
117
|
-
"firebase": "^11.2.0",
|
|
118
|
-
"loglevel": "^1.8.1",
|
|
119
|
-
"uuid": "^8.3.2"
|
|
120
|
-
},
|
|
121
|
-
"devDependencies": {
|
|
122
|
-
"@lavamoat/allow-scripts": "^3.0.4",
|
|
123
|
-
"@lavamoat/preinstall-always-fail": "^2.1.0",
|
|
124
|
-
"@metamask/auto-changelog": "^3.4.4",
|
|
125
|
-
"@metamask/keyring-controller": "^19.0.5",
|
|
126
|
-
"@metamask/profile-sync-controller": "^5.0.0",
|
|
127
|
-
"@types/jest": "^27.4.1",
|
|
128
|
-
"@types/readable-stream": "^2.3.0",
|
|
129
|
-
"contentful": "^10.15.0",
|
|
130
|
-
"deepmerge": "^4.2.2",
|
|
131
|
-
"jest": "^27.5.1",
|
|
132
|
-
"jest-environment-jsdom": "^27.5.1",
|
|
133
|
-
"nock": "^13.3.1",
|
|
134
|
-
"ts-jest": "^27.1.4",
|
|
135
|
-
"typedoc": "^0.24.8",
|
|
136
|
-
"typedoc-plugin-missing-exports": "^2.0.0",
|
|
137
|
-
"typescript": "~5.2.2"
|
|
138
|
-
},
|
|
139
|
-
"peerDependencies": {
|
|
140
|
-
"@metamask/keyring-controller": "^19.0.0",
|
|
141
|
-
"@metamask/profile-sync-controller": "^5.0.0"
|
|
142
|
-
},
|
|
143
|
-
"engines": {
|
|
144
|
-
"node": "^18.18 || >=20"
|
|
145
|
-
},
|
|
146
|
-
"publishConfig": {
|
|
147
|
-
"access": "public",
|
|
148
|
-
"registry": "https://registry.npmjs.org/"
|
|
149
|
-
}
|
|
150
|
-
}
|