@metamask-previews/notification-services-controller 0.10.0-preview-b7ea5d52 → 0.10.0-preview-3c1aabe6
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 +8 -85
- package/dist/NotificationServicesController/NotificationServicesController.cjs.map +1 -1
- package/dist/NotificationServicesController/NotificationServicesController.d.cts +1 -36
- package/dist/NotificationServicesController/NotificationServicesController.d.cts.map +1 -1
- package/dist/NotificationServicesController/NotificationServicesController.d.mts +1 -36
- package/dist/NotificationServicesController/NotificationServicesController.d.mts.map +1 -1
- package/dist/NotificationServicesController/NotificationServicesController.mjs +8 -85
- package/dist/NotificationServicesController/NotificationServicesController.mjs.map +1 -1
- package/dist/NotificationServicesController/__fixtures__/index.cjs +0 -1
- package/dist/NotificationServicesController/__fixtures__/index.cjs.map +1 -1
- package/dist/NotificationServicesController/__fixtures__/index.d.cts +0 -1
- package/dist/NotificationServicesController/__fixtures__/index.d.cts.map +1 -1
- package/dist/NotificationServicesController/__fixtures__/index.d.mts +0 -1
- package/dist/NotificationServicesController/__fixtures__/index.d.mts.map +1 -1
- package/dist/NotificationServicesController/__fixtures__/index.mjs +0 -1
- package/dist/NotificationServicesController/__fixtures__/index.mjs.map +1 -1
- package/dist/NotificationServicesController/constants/notification-schema.cjs +0 -1
- package/dist/NotificationServicesController/constants/notification-schema.cjs.map +1 -1
- package/dist/NotificationServicesController/constants/notification-schema.d.cts +1 -2
- package/dist/NotificationServicesController/constants/notification-schema.d.cts.map +1 -1
- package/dist/NotificationServicesController/constants/notification-schema.d.mts +1 -2
- package/dist/NotificationServicesController/constants/notification-schema.d.mts.map +1 -1
- package/dist/NotificationServicesController/constants/notification-schema.mjs +0 -1
- package/dist/NotificationServicesController/constants/notification-schema.mjs.map +1 -1
- package/dist/NotificationServicesController/processors/process-notifications.cjs +0 -5
- package/dist/NotificationServicesController/processors/process-notifications.cjs.map +1 -1
- package/dist/NotificationServicesController/processors/process-notifications.d.cts +3 -3
- package/dist/NotificationServicesController/processors/process-notifications.d.cts.map +1 -1
- package/dist/NotificationServicesController/processors/process-notifications.d.mts +3 -3
- package/dist/NotificationServicesController/processors/process-notifications.d.mts.map +1 -1
- package/dist/NotificationServicesController/processors/process-notifications.mjs +0 -5
- package/dist/NotificationServicesController/processors/process-notifications.mjs.map +1 -1
- package/dist/NotificationServicesController/types/notification/notification.cjs.map +1 -1
- package/dist/NotificationServicesController/types/notification/notification.d.cts +6 -10
- package/dist/NotificationServicesController/types/notification/notification.d.cts.map +1 -1
- package/dist/NotificationServicesController/types/notification/notification.d.mts +6 -10
- package/dist/NotificationServicesController/types/notification/notification.d.mts.map +1 -1
- package/dist/NotificationServicesController/types/notification/notification.mjs.map +1 -1
- package/dist/NotificationServicesPushController/NotificationServicesPushController.cjs +1 -3
- package/dist/NotificationServicesPushController/NotificationServicesPushController.cjs.map +1 -1
- package/dist/NotificationServicesPushController/NotificationServicesPushController.d.cts +1 -2
- package/dist/NotificationServicesPushController/NotificationServicesPushController.d.cts.map +1 -1
- package/dist/NotificationServicesPushController/NotificationServicesPushController.d.mts +1 -2
- package/dist/NotificationServicesPushController/NotificationServicesPushController.d.mts.map +1 -1
- package/dist/NotificationServicesPushController/NotificationServicesPushController.mjs +1 -3
- package/dist/NotificationServicesPushController/NotificationServicesPushController.mjs.map +1 -1
- package/dist/NotificationServicesPushController/services/services.cjs +2 -2
- package/dist/NotificationServicesPushController/services/services.cjs.map +1 -1
- package/dist/NotificationServicesPushController/services/services.d.cts +0 -1
- package/dist/NotificationServicesPushController/services/services.d.cts.map +1 -1
- package/dist/NotificationServicesPushController/services/services.d.mts +0 -1
- package/dist/NotificationServicesPushController/services/services.d.mts.map +1 -1
- package/dist/NotificationServicesPushController/services/services.mjs +2 -2
- package/dist/NotificationServicesPushController/services/services.mjs.map +1 -1
- package/dist/NotificationServicesPushController/utils/get-notification-data.mjs +1 -2
- package/dist/NotificationServicesPushController/utils/get-notification-data.mjs.map +1 -1
- package/package.json +3 -4
- package/dist/NotificationServicesController/__fixtures__/mock-snap-notification.cjs +0 -29
- package/dist/NotificationServicesController/__fixtures__/mock-snap-notification.cjs.map +0 -1
- package/dist/NotificationServicesController/__fixtures__/mock-snap-notification.d.cts +0 -8
- package/dist/NotificationServicesController/__fixtures__/mock-snap-notification.d.cts.map +0 -1
- package/dist/NotificationServicesController/__fixtures__/mock-snap-notification.d.mts +0 -8
- package/dist/NotificationServicesController/__fixtures__/mock-snap-notification.d.mts.map +0 -1
- package/dist/NotificationServicesController/__fixtures__/mock-snap-notification.mjs +0 -25
- package/dist/NotificationServicesController/__fixtures__/mock-snap-notification.mjs.map +0 -1
- package/dist/NotificationServicesController/processors/process-snap-notifications.cjs +0 -23
- package/dist/NotificationServicesController/processors/process-snap-notifications.cjs.map +0 -1
- package/dist/NotificationServicesController/processors/process-snap-notifications.d.cts +0 -10
- package/dist/NotificationServicesController/processors/process-snap-notifications.d.cts.map +0 -1
- package/dist/NotificationServicesController/processors/process-snap-notifications.d.mts +0 -10
- package/dist/NotificationServicesController/processors/process-snap-notifications.d.mts.map +0 -1
- package/dist/NotificationServicesController/processors/process-snap-notifications.mjs +0 -19
- package/dist/NotificationServicesController/processors/process-snap-notifications.mjs.map +0 -1
- package/dist/NotificationServicesController/types/snaps/index.cjs +0 -18
- package/dist/NotificationServicesController/types/snaps/index.cjs.map +0 -1
- package/dist/NotificationServicesController/types/snaps/index.d.cts +0 -2
- package/dist/NotificationServicesController/types/snaps/index.d.cts.map +0 -1
- package/dist/NotificationServicesController/types/snaps/index.d.mts +0 -2
- package/dist/NotificationServicesController/types/snaps/index.d.mts.map +0 -1
- package/dist/NotificationServicesController/types/snaps/index.mjs +0 -2
- package/dist/NotificationServicesController/types/snaps/index.mjs.map +0 -1
- package/dist/NotificationServicesController/types/snaps/snaps.cjs +0 -3
- package/dist/NotificationServicesController/types/snaps/snaps.cjs.map +0 -1
- package/dist/NotificationServicesController/types/snaps/snaps.d.cts +0 -23
- package/dist/NotificationServicesController/types/snaps/snaps.d.cts.map +0 -1
- package/dist/NotificationServicesController/types/snaps/snaps.d.mts +0 -23
- package/dist/NotificationServicesController/types/snaps/snaps.d.mts.map +0 -1
- package/dist/NotificationServicesController/types/snaps/snaps.mjs +0 -2
- package/dist/NotificationServicesController/types/snaps/snaps.mjs.map +0 -1
|
@@ -3,5 +3,4 @@ export * from "./mock-notification-trigger.mjs";
|
|
|
3
3
|
export * from "./mock-notification-user-storage.mjs";
|
|
4
4
|
export * from "./mock-raw-notifications.mjs";
|
|
5
5
|
export * from "./mockResponses.mjs";
|
|
6
|
-
export * from "./mock-snap-notification.mjs";
|
|
7
6
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../src/NotificationServicesController/__fixtures__/index.ts"],"names":[],"mappings":"AAAA,iDAA6C;AAC7C,gDAA4C;AAC5C,qDAAiD;AACjD,6CAAyC;AACzC,oCAAgC
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../src/NotificationServicesController/__fixtures__/index.ts"],"names":[],"mappings":"AAAA,iDAA6C;AAC7C,gDAA4C;AAC5C,qDAAiD;AACjD,6CAAyC;AACzC,oCAAgC","sourcesContent":["export * from './mock-feature-announcements';\nexport * from './mock-notification-trigger';\nexport * from './mock-notification-user-storage';\nexport * from './mock-raw-notifications';\nexport * from './mockResponses';\n"]}
|
|
@@ -26,7 +26,6 @@ var TRIGGER_TYPES;
|
|
|
26
26
|
TRIGGER_TYPES["ROCKETPOOL_STAKING_REWARDS"] = "rocketpool_staking_rewards";
|
|
27
27
|
TRIGGER_TYPES["NOTIONAL_LOAN_EXPIRATION"] = "notional_loan_expiration";
|
|
28
28
|
TRIGGER_TYPES["SPARK_FI_HEALTH_FACTOR"] = "spark_fi_health_factor";
|
|
29
|
-
TRIGGER_TYPES["SNAP"] = "snap";
|
|
30
29
|
})(TRIGGER_TYPES || (exports.TRIGGER_TYPES = TRIGGER_TYPES = {}));
|
|
31
30
|
exports.TRIGGER_TYPES_WALLET_SET = new Set([
|
|
32
31
|
TRIGGER_TYPES.METAMASK_SWAP_COMPLETED,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notification-schema.cjs","sourceRoot":"","sources":["../../../src/NotificationServicesController/constants/notification-schema.ts"],"names":[],"mappings":";;;AAEA,yDAAyD;AACzD,IAAY,
|
|
1
|
+
{"version":3,"file":"notification-schema.cjs","sourceRoot":"","sources":["../../../src/NotificationServicesController/constants/notification-schema.ts"],"names":[],"mappings":";;;AAEA,yDAAyD;AACzD,IAAY,aAuBX;AAvBD,WAAY,aAAa;IACvB,gEAA+C,CAAA;IAC/C,oEAAmD,CAAA;IACnD,0CAAyB,CAAA;IACzB,kDAAiC,CAAA;IACjC,sCAAqB,CAAA;IACrB,8CAA6B,CAAA;IAC7B,0EAAyD,CAAA;IACzD,8EAA6D,CAAA;IAC7D,8DAA6C,CAAA;IAC7C,wEAAuD,CAAA;IACvD,wEAAuD,CAAA;IACvD,sFAAqE,CAAA;IACrE,4CAA2B,CAAA;IAC3B,oDAAmC,CAAA;IACnC,8CAA6B,CAAA;IAC7B,sDAAqC,CAAA;IACrC,gEAA+C,CAAA;IAC/C,kDAAiC,CAAA;IACjC,8DAA6C,CAAA;IAC7C,0EAAyD,CAAA;IACzD,sEAAqD,CAAA;IACrD,kEAAiD,CAAA;AACnD,CAAC,EAvBW,aAAa,6BAAb,aAAa,QAuBxB;AAEY,QAAA,wBAAwB,GAAgB,IAAI,GAAG,CAAC;IAC3D,aAAa,CAAC,uBAAuB;IACrC,aAAa,CAAC,UAAU;IACxB,aAAa,CAAC,cAAc;IAC5B,aAAa,CAAC,QAAQ;IACtB,aAAa,CAAC,YAAY;IAC1B,aAAa,CAAC,0BAA0B;IACxC,aAAa,CAAC,4BAA4B;IAC1C,aAAa,CAAC,oBAAoB;IAClC,aAAa,CAAC,yBAAyB;IACv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ChB,2BAAmB,CAAC,QAAQ;YAC5B,2BAAmB,CAAC,OAAO;SAC5B;KACF;IACD,CAAC,aAAa,CAAC,QAAQ,CAAC,EAAE;QACxB,gBAAgB,EAAE;YAChB,2BAAmB,CAAC,QAAQ;YAC5B,2BAAmB,CAAC,QAAQ;YAC5B,2BAAmB,CAAC,GAAG;YACvB,2BAAmB,CAAC,OAAO;YAC3B,2BAAmB,CAAC,QAAQ;YAC5B,2BAAmB,CAAC,SAAS;YAC7B,2BAAmB,CAAC,KAAK;SAC1B;KACF;IACD,CAAC,aAAa,CAAC,YAAY,CAAC,EAAE;QAC5B,gBAAgB,EAAE;YAChB,2BAAmB,CAAC,QAAQ;YAC5B,2BAAmB,CAAC,QAAQ;YAC5B,2BAAmB,CAAC,GAAG;YACvB,2BAAmB,CAAC,OAAO;YAC3B,2BAAmB,CAAC,QAAQ;YAC5B,2BAAmB,CAAC,SAAS;YAC7B,2BAAmB,CAAC,KAAK;SAC1B;KACF;IACD,CAAC,aAAa,CAAC,0BAA0B,CAAC,EAAE;QAC1C,gBAAgB,EAAE,CAAC,2BAAmB,CAAC,QAAQ,CAAC;KACjD;IACD,CAAC,aAAa,CAAC,4BAA4B,CAAC,EAAE;QAC5C,gBAAgB,EAAE,CAAC,2BAAmB,CAAC,QAAQ,CAAC;KACjD;IACD,CAAC,aAAa,CAAC,oBAAoB,CAAC,EAAE;QACpC,gBAAgB,EAAE,CAAC,2BAAmB,CAAC,QAAQ,CAAC;KACjD;IACD,CAAC,aAAa,CAAC,yBAAyB,CAAC,EAAE;QACzC,gBAAgB,EAAE,CAAC,2BAAmB,CAAC,QAAQ,CAAC;KACjD;IACD,CAAC,aAAa,CAAC,yBAAyB,CAAC,EAAE;QACzC,gBAAgB,EAAE,CAAC,2BAAmB,CAAC,QAAQ,CAAC;KACjD;CACF,CAAC","sourcesContent":["import type { Compute } from '../types/type-utils';\n\n/* eslint-disable @typescript-eslint/naming-convention */\nexport enum TRIGGER_TYPES {\n FEATURES_ANNOUNCEMENT = 'features_announcement',\n METAMASK_SWAP_COMPLETED = 'metamask_swap_completed',\n ERC20_SENT = 'erc20_sent',\n ERC20_RECEIVED = 'erc20_received',\n ETH_SENT = 'eth_sent',\n ETH_RECEIVED = 'eth_received',\n ROCKETPOOL_STAKE_COMPLETED = 'rocketpool_stake_completed',\n ROCKETPOOL_UNSTAKE_COMPLETED = 'rocketpool_unstake_completed',\n LIDO_STAKE_COMPLETED = 'lido_stake_completed',\n LIDO_WITHDRAWAL_REQUESTED = 'lido_withdrawal_requested',\n LIDO_WITHDRAWAL_COMPLETED = 'lido_withdrawal_completed',\n LIDO_STAKE_READY_TO_BE_WITHDRAWN = 'lido_stake_ready_to_be_withdrawn',\n ERC721_SENT = 'erc721_sent',\n ERC721_RECEIVED = 'erc721_received',\n ERC1155_SENT = 'erc1155_sent',\n ERC1155_RECEIVED = 'erc1155_received',\n AAVE_V3_HEALTH_FACTOR = 'aave_v3_health_factor',\n ENS_EXPIRATION = 'ens_expiration',\n LIDO_STAKING_REWARDS = 'lido_staking_rewards',\n ROCKETPOOL_STAKING_REWARDS = 'rocketpool_staking_rewards',\n NOTIONAL_LOAN_EXPIRATION = 'notional_loan_expiration',\n SPARK_FI_HEALTH_FACTOR = 'spark_fi_health_factor',\n}\n\nexport const TRIGGER_TYPES_WALLET_SET: Set<string> = new Set([\n TRIGGER_TYPES.METAMASK_SWAP_COMPLETED,\n TRIGGER_TYPES.ERC20_SENT,\n TRIGGER_TYPES.ERC20_RECEIVED,\n TRIGGER_TYPES.ETH_SENT,\n TRIGGER_TYPES.ETH_RECEIVED,\n TRIGGER_TYPES.ROCKETPOOL_STAKE_COMPLETED,\n TRIGGER_TYPES.ROCKETPOOL_UNSTAKE_COMPLETED,\n TRIGGER_TYPES.LIDO_STAKE_COMPLETED,\n TRIGGER_TYPES.LIDO_WITHDRAWAL_REQUESTED,\n TRIGGER_TYPES.LIDO_WITHDRAWAL_COMPLETED,\n TRIGGER_TYPES.LIDO_STAKE_READY_TO_BE_WITHDRAWN,\n TRIGGER_TYPES.ERC721_SENT,\n TRIGGER_TYPES.ERC721_RECEIVED,\n TRIGGER_TYPES.ERC1155_SENT,\n TRIGGER_TYPES.ERC1155_RECEIVED,\n]) satisfies Set<Exclude<TRIGGER_TYPES, TRIGGER_TYPES.FEATURES_ANNOUNCEMENT>>;\n\nexport enum TRIGGER_TYPES_GROUPS {\n RECEIVED = 'received',\n SENT = 'sent',\n DEFI = 'defi',\n}\n\nexport const NOTIFICATION_CHAINS_ID = {\n ETHEREUM: '1',\n OPTIMISM: '10',\n BSC: '56',\n POLYGON: '137',\n ARBITRUM: '42161',\n AVALANCHE: '43114',\n LINEA: '59144',\n} as const;\n\ntype ToPrimitiveKeys<TObj> = Compute<{\n [K in keyof TObj]: TObj[K] extends string ? string : TObj[K];\n}>;\nexport const NOTIFICATION_CHAINS: ToPrimitiveKeys<\n typeof NOTIFICATION_CHAINS_ID\n> = NOTIFICATION_CHAINS_ID;\n\nexport const CHAIN_SYMBOLS = {\n [NOTIFICATION_CHAINS.ETHEREUM]: 'ETH',\n [NOTIFICATION_CHAINS.OPTIMISM]: 'ETH',\n [NOTIFICATION_CHAINS.BSC]: 'BNB',\n [NOTIFICATION_CHAINS.POLYGON]: 'POL',\n [NOTIFICATION_CHAINS.ARBITRUM]: 'ETH',\n [NOTIFICATION_CHAINS.AVALANCHE]: 'AVAX',\n [NOTIFICATION_CHAINS.LINEA]: 'ETH',\n};\n\nexport const SUPPORTED_CHAINS = [\n NOTIFICATION_CHAINS.ETHEREUM,\n NOTIFICATION_CHAINS.OPTIMISM,\n NOTIFICATION_CHAINS.BSC,\n NOTIFICATION_CHAINS.POLYGON,\n NOTIFICATION_CHAINS.ARBITRUM,\n NOTIFICATION_CHAINS.AVALANCHE,\n NOTIFICATION_CHAINS.LINEA,\n];\n\nexport type Trigger = {\n supported_chains: (typeof SUPPORTED_CHAINS)[number][];\n};\n\nexport const TRIGGERS: Partial<Record<TRIGGER_TYPES, Trigger>> = {\n [TRIGGER_TYPES.METAMASK_SWAP_COMPLETED]: {\n supported_chains: [\n NOTIFICATION_CHAINS.ETHEREUM,\n NOTIFICATION_CHAINS.OPTIMISM,\n NOTIFICATION_CHAINS.BSC,\n NOTIFICATION_CHAINS.POLYGON,\n NOTIFICATION_CHAINS.ARBITRUM,\n NOTIFICATION_CHAINS.AVALANCHE,\n ],\n },\n [TRIGGER_TYPES.ERC20_SENT]: {\n supported_chains: [\n NOTIFICATION_CHAINS.ETHEREUM,\n NOTIFICATION_CHAINS.OPTIMISM,\n NOTIFICATION_CHAINS.BSC,\n NOTIFICATION_CHAINS.POLYGON,\n NOTIFICATION_CHAINS.ARBITRUM,\n NOTIFICATION_CHAINS.AVALANCHE,\n NOTIFICATION_CHAINS.LINEA,\n ],\n },\n [TRIGGER_TYPES.ERC20_RECEIVED]: {\n supported_chains: [\n NOTIFICATION_CHAINS.ETHEREUM,\n NOTIFICATION_CHAINS.OPTIMISM,\n NOTIFICATION_CHAINS.BSC,\n NOTIFICATION_CHAINS.POLYGON,\n NOTIFICATION_CHAINS.ARBITRUM,\n NOTIFICATION_CHAINS.AVALANCHE,\n NOTIFICATION_CHAINS.LINEA,\n ],\n },\n [TRIGGER_TYPES.ERC721_SENT]: {\n supported_chains: [\n NOTIFICATION_CHAINS.ETHEREUM,\n NOTIFICATION_CHAINS.POLYGON,\n ],\n },\n [TRIGGER_TYPES.ERC721_RECEIVED]: {\n supported_chains: [\n NOTIFICATION_CHAINS.ETHEREUM,\n NOTIFICATION_CHAINS.POLYGON,\n ],\n },\n [TRIGGER_TYPES.ERC1155_SENT]: {\n supported_chains: [\n NOTIFICATION_CHAINS.ETHEREUM,\n NOTIFICATION_CHAINS.POLYGON,\n ],\n },\n [TRIGGER_TYPES.ERC1155_RECEIVED]: {\n supported_chains: [\n NOTIFICATION_CHAINS.ETHEREUM,\n NOTIFICATION_CHAINS.POLYGON,\n ],\n },\n [TRIGGER_TYPES.ETH_SENT]: {\n supported_chains: [\n NOTIFICATION_CHAINS.ETHEREUM,\n NOTIFICATION_CHAINS.OPTIMISM,\n NOTIFICATION_CHAINS.BSC,\n NOTIFICATION_CHAINS.POLYGON,\n NOTIFICATION_CHAINS.ARBITRUM,\n NOTIFICATION_CHAINS.AVALANCHE,\n NOTIFICATION_CHAINS.LINEA,\n ],\n },\n [TRIGGER_TYPES.ETH_RECEIVED]: {\n supported_chains: [\n NOTIFICATION_CHAINS.ETHEREUM,\n NOTIFICATION_CHAINS.OPTIMISM,\n NOTIFICATION_CHAINS.BSC,\n NOTIFICATION_CHAINS.POLYGON,\n NOTIFICATION_CHAINS.ARBITRUM,\n NOTIFICATION_CHAINS.AVALANCHE,\n NOTIFICATION_CHAINS.LINEA,\n ],\n },\n [TRIGGER_TYPES.ROCKETPOOL_STAKE_COMPLETED]: {\n supported_chains: [NOTIFICATION_CHAINS.ETHEREUM],\n },\n [TRIGGER_TYPES.ROCKETPOOL_UNSTAKE_COMPLETED]: {\n supported_chains: [NOTIFICATION_CHAINS.ETHEREUM],\n },\n [TRIGGER_TYPES.LIDO_STAKE_COMPLETED]: {\n supported_chains: [NOTIFICATION_CHAINS.ETHEREUM],\n },\n [TRIGGER_TYPES.LIDO_WITHDRAWAL_REQUESTED]: {\n supported_chains: [NOTIFICATION_CHAINS.ETHEREUM],\n },\n [TRIGGER_TYPES.LIDO_WITHDRAWAL_COMPLETED]: {\n supported_chains: [NOTIFICATION_CHAINS.ETHEREUM],\n },\n};\n"]}
|
|
@@ -21,8 +21,7 @@ export declare enum TRIGGER_TYPES {
|
|
|
21
21
|
LIDO_STAKING_REWARDS = "lido_staking_rewards",
|
|
22
22
|
ROCKETPOOL_STAKING_REWARDS = "rocketpool_staking_rewards",
|
|
23
23
|
NOTIONAL_LOAN_EXPIRATION = "notional_loan_expiration",
|
|
24
|
-
SPARK_FI_HEALTH_FACTOR = "spark_fi_health_factor"
|
|
25
|
-
SNAP = "snap"
|
|
24
|
+
SPARK_FI_HEALTH_FACTOR = "spark_fi_health_factor"
|
|
26
25
|
}
|
|
27
26
|
export declare const TRIGGER_TYPES_WALLET_SET: Set<string>;
|
|
28
27
|
export declare enum TRIGGER_TYPES_GROUPS {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notification-schema.d.cts","sourceRoot":"","sources":["../../../src/NotificationServicesController/constants/notification-schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,gCAA4B;AAGnD,oBAAY,aAAa;IACvB,qBAAqB,0BAA0B;IAC/C,uBAAuB,4BAA4B;IACnD,UAAU,eAAe;IACzB,cAAc,mBAAmB;IACjC,QAAQ,aAAa;IACrB,YAAY,iBAAiB;IAC7B,0BAA0B,+BAA+B;IACzD,4BAA4B,iCAAiC;IAC7D,oBAAoB,yBAAyB;IAC7C,yBAAyB,8BAA8B;IACvD,yBAAyB,8BAA8B;IACvD,gCAAgC,qCAAqC;IACrE,WAAW,gBAAgB;IAC3B,eAAe,oBAAoB;IACnC,YAAY,iBAAiB;IAC7B,gBAAgB,qBAAqB;IACrC,qBAAqB,0BAA0B;IAC/C,cAAc,mBAAmB;IACjC,oBAAoB,yBAAyB;IAC7C,0BAA0B,+BAA+B;IACzD,wBAAwB,6BAA6B;IACrD,sBAAsB,2BAA2B;
|
|
1
|
+
{"version":3,"file":"notification-schema.d.cts","sourceRoot":"","sources":["../../../src/NotificationServicesController/constants/notification-schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,gCAA4B;AAGnD,oBAAY,aAAa;IACvB,qBAAqB,0BAA0B;IAC/C,uBAAuB,4BAA4B;IACnD,UAAU,eAAe;IACzB,cAAc,mBAAmB;IACjC,QAAQ,aAAa;IACrB,YAAY,iBAAiB;IAC7B,0BAA0B,+BAA+B;IACzD,4BAA4B,iCAAiC;IAC7D,oBAAoB,yBAAyB;IAC7C,yBAAyB,8BAA8B;IACvD,yBAAyB,8BAA8B;IACvD,gCAAgC,qCAAqC;IACrE,WAAW,gBAAgB;IAC3B,eAAe,oBAAoB;IACnC,YAAY,iBAAiB;IAC7B,gBAAgB,qBAAqB;IACrC,qBAAqB,0BAA0B;IAC/C,cAAc,mBAAmB;IACjC,oBAAoB,yBAAyB;IAC7C,0BAA0B,+BAA+B;IACzD,wBAAwB,6BAA6B;IACrD,sBAAsB,2BAA2B;CAClD;AAED,eAAO,MAAM,wBAAwB,EAAE,GAAG,CAAC,MAAM,CAgB4B,CAAC;AAE9E,oBAAY,oBAAoB;IAC9B,QAAQ,aAAa;IACrB,IAAI,SAAS;IACb,IAAI,SAAS;CACd;AAED,eAAO,MAAM,sBAAsB;;;;;;;;CAQzB,CAAC;AAEX,KAAK,eAAe,CAAC,IAAI,IAAI,OAAO,CAAC;KAClC,CAAC,IAAI,MAAM,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC;CAC7D,CAAC,CAAC;AACH,eAAO,MAAM,mBAAmB,EAAE,eAAe,CAC/C,OAAO,sBAAsB,CACL,CAAC;AAE3B,eAAO,MAAM,aAAa;;CAQzB,CAAC;AAEF,eAAO,MAAM,gBAAgB,UAQ5B,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG;IACpB,gBAAgB,EAAE,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;CACvD,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,aAAa,EAAE,OAAO,CAAC,CA8F5D,CAAC"}
|
|
@@ -21,8 +21,7 @@ export declare enum TRIGGER_TYPES {
|
|
|
21
21
|
LIDO_STAKING_REWARDS = "lido_staking_rewards",
|
|
22
22
|
ROCKETPOOL_STAKING_REWARDS = "rocketpool_staking_rewards",
|
|
23
23
|
NOTIONAL_LOAN_EXPIRATION = "notional_loan_expiration",
|
|
24
|
-
SPARK_FI_HEALTH_FACTOR = "spark_fi_health_factor"
|
|
25
|
-
SNAP = "snap"
|
|
24
|
+
SPARK_FI_HEALTH_FACTOR = "spark_fi_health_factor"
|
|
26
25
|
}
|
|
27
26
|
export declare const TRIGGER_TYPES_WALLET_SET: Set<string>;
|
|
28
27
|
export declare enum TRIGGER_TYPES_GROUPS {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notification-schema.d.mts","sourceRoot":"","sources":["../../../src/NotificationServicesController/constants/notification-schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,gCAA4B;AAGnD,oBAAY,aAAa;IACvB,qBAAqB,0BAA0B;IAC/C,uBAAuB,4BAA4B;IACnD,UAAU,eAAe;IACzB,cAAc,mBAAmB;IACjC,QAAQ,aAAa;IACrB,YAAY,iBAAiB;IAC7B,0BAA0B,+BAA+B;IACzD,4BAA4B,iCAAiC;IAC7D,oBAAoB,yBAAyB;IAC7C,yBAAyB,8BAA8B;IACvD,yBAAyB,8BAA8B;IACvD,gCAAgC,qCAAqC;IACrE,WAAW,gBAAgB;IAC3B,eAAe,oBAAoB;IACnC,YAAY,iBAAiB;IAC7B,gBAAgB,qBAAqB;IACrC,qBAAqB,0BAA0B;IAC/C,cAAc,mBAAmB;IACjC,oBAAoB,yBAAyB;IAC7C,0BAA0B,+BAA+B;IACzD,wBAAwB,6BAA6B;IACrD,sBAAsB,2BAA2B;
|
|
1
|
+
{"version":3,"file":"notification-schema.d.mts","sourceRoot":"","sources":["../../../src/NotificationServicesController/constants/notification-schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,gCAA4B;AAGnD,oBAAY,aAAa;IACvB,qBAAqB,0BAA0B;IAC/C,uBAAuB,4BAA4B;IACnD,UAAU,eAAe;IACzB,cAAc,mBAAmB;IACjC,QAAQ,aAAa;IACrB,YAAY,iBAAiB;IAC7B,0BAA0B,+BAA+B;IACzD,4BAA4B,iCAAiC;IAC7D,oBAAoB,yBAAyB;IAC7C,yBAAyB,8BAA8B;IACvD,yBAAyB,8BAA8B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= "spark_fi_health_factor";
|
|
26
|
-
TRIGGER_TYPES["SNAP"] = "snap";
|
|
27
26
|
})(TRIGGER_TYPES || (TRIGGER_TYPES = {}));
|
|
28
27
|
export const TRIGGER_TYPES_WALLET_SET = new Set([
|
|
29
28
|
TRIGGER_TYPES.METAMASK_SWAP_COMPLETED,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notification-schema.mjs","sourceRoot":"","sources":["../../../src/NotificationServicesController/constants/notification-schema.ts"],"names":[],"mappings":"AAEA,yDAAyD;AACzD,MAAM,CAAN,IAAY,
|
|
1
|
+
{"version":3,"file":"notification-schema.mjs","sourceRoot":"","sources":["../../../src/NotificationServicesController/constants/notification-schema.ts"],"names":[],"mappings":"AAEA,yDAAyD;AACzD,MAAM,CAAN,IAAY,aAuBX;AAvBD,WAAY,aAAa;IACvB,gEAA+C,CAAA;IAC/C,oEAAmD,CAAA;IACnD,0CAAyB,CAAA;IACzB,kDAAiC,CAAA;IACjC,sCAAqB,CAAA;IACrB,8CAA6B,CAAA;IAC7B,0EAAyD,CAAA;IACzD,8EAA6D,CAAA;IAC7D,8DAA6C,CAAA;IAC7C,wEAAuD,CAAA;IACvD,wEAAuD,CAAA;IACvD,sFAAqE,CAAA;IACrE,4CAA2B,CAAA;IAC3B,oDAAmC,CAAA;IACnC,8CAA6B,CAAA;IAC7B,sDAAqC,CAAA;IACrC,gEAA+C,CAAA;IAC/C,kDAAiC,CAAA;IACjC,8DAA6C,CAAA;IAC7C,0EAAyD,CAAA;IACzD,sEAAqD,CAAA;IACrD,kEAAiD,CAAA;AACnD,CAAC,EAvBW,aAAa,KAAb,aAAa,QAuBxB;AAED,MAAM,CAAC,MAAM,wBAAwB,GAAgB,IAAI,GAAG,CAAC;IAC3D,aAAa,CAAC,uBAAuB;IACrC,aAAa,CAAC,UAAU;IACxB,aAAa,CAAC,cAAc;IAC5B,aAAa,CAAC,QAAQ;IACtB,aAAa,CAAC,YAAY;IAC1B,aAAa,CAAC,0B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BAAgB,EAAE,CAAC,mBAAmB,CAAC,QAAQ,CAAC;KACjD;CACF,CAAC","sourcesContent":["import type { Compute } from '../types/type-utils';\n\n/* eslint-disable @typescript-eslint/naming-convention */\nexport enum TRIGGER_TYPES {\n FEATURES_ANNOUNCEMENT = 'features_announcement',\n METAMASK_SWAP_COMPLETED = 'metamask_swap_completed',\n ERC20_SENT = 'erc20_sent',\n ERC20_RECEIVED = 'erc20_received',\n ETH_SENT = 'eth_sent',\n ETH_RECEIVED = 'eth_received',\n ROCKETPOOL_STAKE_COMPLETED = 'rocketpool_stake_completed',\n ROCKETPOOL_UNSTAKE_COMPLETED = 'rocketpool_unstake_completed',\n LIDO_STAKE_COMPLETED = 'lido_stake_completed',\n LIDO_WITHDRAWAL_REQUESTED = 'lido_withdrawal_requested',\n LIDO_WITHDRAWAL_COMPLETED = 'lido_withdrawal_completed',\n LIDO_STAKE_READY_TO_BE_WITHDRAWN = 'lido_stake_ready_to_be_withdrawn',\n ERC721_SENT = 'erc721_sent',\n ERC721_RECEIVED = 'erc721_received',\n ERC1155_SENT = 'erc1155_sent',\n ERC1155_RECEIVED = 'erc1155_received',\n AAVE_V3_HEALTH_FACTOR = 'aave_v3_health_factor',\n ENS_EXPIRATION = 'ens_expiration',\n LIDO_STAKING_REWARDS = 'lido_staking_rewards',\n ROCKETPOOL_STAKING_REWARDS = 'rocketpool_staking_rewards',\n NOTIONAL_LOAN_EXPIRATION = 'notional_loan_expiration',\n SPARK_FI_HEALTH_FACTOR = 'spark_fi_health_factor',\n}\n\nexport const TRIGGER_TYPES_WALLET_SET: Set<string> = new Set([\n TRIGGER_TYPES.METAMASK_SWAP_COMPLETED,\n TRIGGER_TYPES.ERC20_SENT,\n TRIGGER_TYPES.ERC20_RECEIVED,\n TRIGGER_TYPES.ETH_SENT,\n TRIGGER_TYPES.ETH_RECEIVED,\n TRIGGER_TYPES.ROCKETPOOL_STAKE_COMPLETED,\n TRIGGER_TYPES.ROCKETPOOL_UNSTAKE_COMPLETED,\n TRIGGER_TYPES.LIDO_STAKE_COMPLETED,\n TRIGGER_TYPES.LIDO_WITHDRAWAL_REQUESTED,\n TRIGGER_TYPES.LIDO_WITHDRAWAL_COMPLETED,\n TRIGGER_TYPES.LIDO_STAKE_READY_TO_BE_WITHDRAWN,\n TRIGGER_TYPES.ERC721_SENT,\n TRIGGER_TYPES.ERC721_RECEIVED,\n TRIGGER_TYPES.ERC1155_SENT,\n TRIGGER_TYPES.ERC1155_RECEIVED,\n]) satisfies Set<Exclude<TRIGGER_TYPES, TRIGGER_TYPES.FEATURES_ANNOUNCEMENT>>;\n\nexport enum TRIGGER_TYPES_GROUPS {\n RECEIVED = 'received',\n SENT = 'sent',\n DEFI = 'defi',\n}\n\nexport const NOTIFICATION_CHAINS_ID = {\n ETHEREUM: '1',\n OPTIMISM: '10',\n BSC: '56',\n POLYGON: '137',\n ARBITRUM: '42161',\n AVALANCHE: '43114',\n LINEA: '59144',\n} as const;\n\ntype ToPrimitiveKeys<TObj> = Compute<{\n [K in keyof TObj]: TObj[K] extends string ? string : TObj[K];\n}>;\nexport const NOTIFICATION_CHAINS: ToPrimitiveKeys<\n typeof NOTIFICATION_CHAINS_ID\n> = NOTIFICATION_CHAINS_ID;\n\nexport const CHAIN_SYMBOLS = {\n [NOTIFICATION_CHAINS.ETHEREUM]: 'ETH',\n [NOTIFICATION_CHAINS.OPTIMISM]: 'ETH',\n [NOTIFICATION_CHAINS.BSC]: 'BNB',\n [NOTIFICATION_CHAINS.POLYGON]: 'POL',\n [NOTIFICATION_CHAINS.ARBITRUM]: 'ETH',\n [NOTIFICATION_CHAINS.AVALANCHE]: 'AVAX',\n [NOTIFICATION_CHAINS.LINEA]: 'ETH',\n};\n\nexport const SUPPORTED_CHAINS = [\n NOTIFICATION_CHAINS.ETHEREUM,\n NOTIFICATION_CHAINS.OPTIMISM,\n NOTIFICATION_CHAINS.BSC,\n NOTIFICATION_CHAINS.POLYGON,\n NOTIFICATION_CHAINS.ARBITRUM,\n NOTIFICATION_CHAINS.AVALANCHE,\n NOTIFICATION_CHAINS.LINEA,\n];\n\nexport type Trigger = {\n supported_chains: (typeof SUPPORTED_CHAINS)[number][];\n};\n\nexport const TRIGGERS: Partial<Record<TRIGGER_TYPES, Trigger>> = {\n [TRIGGER_TYPES.METAMASK_SWAP_COMPLETED]: {\n supported_chains: [\n NOTIFICATION_CHAINS.ETHEREUM,\n NOTIFICATION_CHAINS.OPTIMISM,\n NOTIFICATION_CHAINS.BSC,\n NOTIFICATION_CHAINS.POLYGON,\n NOTIFICATION_CHAINS.ARBITRUM,\n NOTIFICATION_CHAINS.AVALANCHE,\n ],\n },\n [TRIGGER_TYPES.ERC20_SENT]: {\n supported_chains: [\n NOTIFICATION_CHAINS.ETHEREUM,\n NOTIFICATION_CHAINS.OPTIMISM,\n NOTIFICATION_CHAINS.BSC,\n NOTIFICATION_CHAINS.POLYGON,\n NOTIFICATION_CHAINS.ARBITRUM,\n NOTIFICATION_CHAINS.AVALANCHE,\n NOTIFICATION_CHAINS.LINEA,\n ],\n },\n [TRIGGER_TYPES.ERC20_RECEIVED]: {\n supported_chains: [\n NOTIFICATION_CHAINS.ETHEREUM,\n NOTIFICATION_CHAINS.OPTIMISM,\n NOTIFICATION_CHAINS.BSC,\n NOTIFICATION_CHAINS.POLYGON,\n NOTIFICATION_CHAINS.ARBITRUM,\n NOTIFICATION_CHAINS.AVALANCHE,\n NOTIFICATION_CHAINS.LINEA,\n ],\n },\n [TRIGGER_TYPES.ERC721_SENT]: {\n supported_chains: [\n NOTIFICATION_CHAINS.ETHEREUM,\n NOTIFICATION_CHAINS.POLYGON,\n ],\n },\n [TRIGGER_TYPES.ERC721_RECEIVED]: {\n supported_chains: [\n NOTIFICATION_CHAINS.ETHEREUM,\n NOTIFICATION_CHAINS.POLYGON,\n ],\n },\n [TRIGGER_TYPES.ERC1155_SENT]: {\n supported_chains: [\n NOTIFICATION_CHAINS.ETHEREUM,\n NOTIFICATION_CHAINS.POLYGON,\n ],\n },\n [TRIGGER_TYPES.ERC1155_RECEIVED]: {\n supported_chains: [\n NOTIFICATION_CHAINS.ETHEREUM,\n NOTIFICATION_CHAINS.POLYGON,\n ],\n },\n [TRIGGER_TYPES.ETH_SENT]: {\n supported_chains: [\n NOTIFICATION_CHAINS.ETHEREUM,\n NOTIFICATION_CHAINS.OPTIMISM,\n NOTIFICATION_CHAINS.BSC,\n NOTIFICATION_CHAINS.POLYGON,\n NOTIFICATION_CHAINS.ARBITRUM,\n NOTIFICATION_CHAINS.AVALANCHE,\n NOTIFICATION_CHAINS.LINEA,\n ],\n },\n [TRIGGER_TYPES.ETH_RECEIVED]: {\n supported_chains: [\n NOTIFICATION_CHAINS.ETHEREUM,\n NOTIFICATION_CHAINS.OPTIMISM,\n NOTIFICATION_CHAINS.BSC,\n NOTIFICATION_CHAINS.POLYGON,\n NOTIFICATION_CHAINS.ARBITRUM,\n NOTIFICATION_CHAINS.AVALANCHE,\n NOTIFICATION_CHAINS.LINEA,\n ],\n },\n [TRIGGER_TYPES.ROCKETPOOL_STAKE_COMPLETED]: {\n supported_chains: [NOTIFICATION_CHAINS.ETHEREUM],\n },\n [TRIGGER_TYPES.ROCKETPOOL_UNSTAKE_COMPLETED]: {\n supported_chains: [NOTIFICATION_CHAINS.ETHEREUM],\n },\n [TRIGGER_TYPES.LIDO_STAKE_COMPLETED]: {\n supported_chains: [NOTIFICATION_CHAINS.ETHEREUM],\n },\n [TRIGGER_TYPES.LIDO_WITHDRAWAL_REQUESTED]: {\n supported_chains: [NOTIFICATION_CHAINS.ETHEREUM],\n },\n [TRIGGER_TYPES.LIDO_WITHDRAWAL_COMPLETED]: {\n supported_chains: [NOTIFICATION_CHAINS.ETHEREUM],\n },\n};\n"]}
|
|
@@ -4,10 +4,8 @@ exports.safeProcessNotification = exports.processNotification = void 0;
|
|
|
4
4
|
const notification_schema_1 = require("../constants/notification-schema.cjs");
|
|
5
5
|
const process_feature_announcement_1 = require("./process-feature-announcement.cjs");
|
|
6
6
|
const process_onchain_notifications_1 = require("./process-onchain-notifications.cjs");
|
|
7
|
-
const process_snap_notifications_1 = require("./process-snap-notifications.cjs");
|
|
8
7
|
const isOnChainNotification = (n) => Object.values(notification_schema_1.TRIGGER_TYPES).includes(n.type);
|
|
9
8
|
const isFeatureAnnouncement = (n) => n.type === notification_schema_1.TRIGGER_TYPES.FEATURES_ANNOUNCEMENT;
|
|
10
|
-
const isSnapNotification = (n) => n.type === notification_schema_1.TRIGGER_TYPES.SNAP;
|
|
11
9
|
/**
|
|
12
10
|
* Process feature announcement and wallet notifications into a shared/normalised notification shape.
|
|
13
11
|
* We can still differentiate notifications by the `type` property
|
|
@@ -26,9 +24,6 @@ function processNotification(notification, readNotifications = []) {
|
|
|
26
24
|
n.isRead = (0, process_feature_announcement_1.isFeatureAnnouncementRead)(n, readNotifications);
|
|
27
25
|
return n;
|
|
28
26
|
}
|
|
29
|
-
if (isSnapNotification(notification)) {
|
|
30
|
-
return (0, process_snap_notifications_1.processSnapNotification)(notification);
|
|
31
|
-
}
|
|
32
27
|
if (isOnChainNotification(notification)) {
|
|
33
28
|
return (0, process_onchain_notifications_1.processOnChainNotification)(notification);
|
|
34
29
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"process-notifications.cjs","sourceRoot":"","sources":["../../../src/NotificationServicesController/processors/process-notifications.ts"],"names":[],"mappings":";;;AAAA,8EAAiE;
|
|
1
|
+
{"version":3,"file":"process-notifications.cjs","sourceRoot":"","sources":["../../../src/NotificationServicesController/processors/process-notifications.ts"],"names":[],"mappings":";;;AAAA,8EAAiE;AAOjE,qFAGwC;AACxC,uFAA6E;AAE7E,MAAM,qBAAqB,GAAG,CAC5B,CAAoB,EACS,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,mCAAa,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;AAEhF,MAAM,qBAAqB,GAAG,CAC5B,CAAoB,EACqB,EAAE,CAC3C,CAAC,CAAC,IAAI,KAAK,mCAAa,CAAC,qBAAqB,CAAC;AAEjD;;;;;;;GAOG;AACH,SAAgB,mBAAmB,CACjC,YAA+B,EAC/B,oBAA8B,EAAE;IAEhC,MAAM,iBAAiB,GAAG,CAAC,CAAQ,EAAE,EAAE;QACrC,MAAM,IAAI,GAAW,YAAY,EAAE,IAAI,CAAC;QACxC,MAAM,IAAI,KAAK,CAAC,4CAA4C,IAAI,EAAE,CAAC,CAAC;IACtE,CAAC,CAAC;IAEF,IAAI,qBAAqB,CAAC,YAAY,CAAC,EAAE;QACvC,MAAM,CAAC,GAAG,IAAA,yDAA0B,EAClC,YAAkD,CACnD,CAAC;QACF,CAAC,CAAC,MAAM,GAAG,IAAA,wDAAyB,EAAC,CAAC,EAAE,iBAAiB,CAAC,CAAC;QAC3D,OAAO,CAAC,CAAC;KACV;IAED,IAAI,qBAAqB,CAAC,YAAY,CAAC,EAAE;QACvC,OAAO,IAAA,0DAA0B,EAAC,YAAsC,CAAC,CAAC;KAC3E;IAED,OAAO,iBAAiB,CAAC,YAAqB,CAAC,CAAC;AAClD,CAAC;AAtBD,kDAsBC;AAED;;;;;;GAMG;AACH,SAAgB,uBAAuB,CACrC,YAA+B,EAC/B,oBAA8B,EAAE;IAEhC,IAAI;QACF,MAAM,qBAAqB,GAAG,mBAAmB,CAC/C,YAAY,EACZ,iBAAiB,CAClB,CAAC;QACF,OAAO,qBAAqB,CAAC;KAC9B;IAAC,MAAM;QACN,OAAO,SAAS,CAAC;KAClB;AACH,CAAC;AAbD,0DAaC","sourcesContent":["import { TRIGGER_TYPES } from '../constants/notification-schema';\nimport type { FeatureAnnouncementRawNotification } from '../types/feature-announcement/feature-announcement';\nimport type {\n INotification,\n NotificationUnion,\n} from '../types/notification/notification';\nimport type { OnChainRawNotification } from '../types/on-chain-notification/on-chain-notification';\nimport {\n isFeatureAnnouncementRead,\n processFeatureAnnouncement,\n} from './process-feature-announcement';\nimport { processOnChainNotification } from './process-onchain-notifications';\n\nconst isOnChainNotification = (\n n: NotificationUnion,\n): n is OnChainRawNotification => Object.values(TRIGGER_TYPES).includes(n.type);\n\nconst isFeatureAnnouncement = (\n n: NotificationUnion,\n): n is FeatureAnnouncementRawNotification =>\n n.type === TRIGGER_TYPES.FEATURES_ANNOUNCEMENT;\n\n/**\n * Process feature announcement and wallet notifications into a shared/normalised notification shape.\n * We can still differentiate notifications by the `type` property\n *\n * @param notification - a feature announcement or on chain notification\n * @param readNotifications - all read notifications currently\n * @returns a processed notification\n */\nexport function processNotification(\n notification: NotificationUnion,\n readNotifications: string[] = [],\n): INotification {\n const exhaustedAllCases = (_: never) => {\n const type: string = notification?.type;\n throw new Error(`No processor found for notification kind ${type}`);\n };\n\n if (isFeatureAnnouncement(notification)) {\n const n = processFeatureAnnouncement(\n notification as FeatureAnnouncementRawNotification,\n );\n n.isRead = isFeatureAnnouncementRead(n, readNotifications);\n return n;\n }\n\n if (isOnChainNotification(notification)) {\n return processOnChainNotification(notification as OnChainRawNotification);\n }\n\n return exhaustedAllCases(notification as never);\n}\n\n/**\n * Safe version of processing a notification. Rather than throwing an error if failed to process, it will return the Notification or undefined\n *\n * @param notification - notification to processes\n * @param readNotifications - all read notifications currently\n * @returns a process notification or undefined if failed to process\n */\nexport function safeProcessNotification(\n notification: NotificationUnion,\n readNotifications: string[] = [],\n): INotification | undefined {\n try {\n const processedNotification = processNotification(\n notification,\n readNotifications,\n );\n return processedNotification;\n } catch {\n return undefined;\n }\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { INotification,
|
|
1
|
+
import type { INotification, NotificationUnion } from "../types/notification/notification.cjs";
|
|
2
2
|
/**
|
|
3
3
|
* Process feature announcement and wallet notifications into a shared/normalised notification shape.
|
|
4
4
|
* We can still differentiate notifications by the `type` property
|
|
@@ -7,7 +7,7 @@ import type { INotification, RawNotificationUnion } from "../types/notification/
|
|
|
7
7
|
* @param readNotifications - all read notifications currently
|
|
8
8
|
* @returns a processed notification
|
|
9
9
|
*/
|
|
10
|
-
export declare function processNotification(notification:
|
|
10
|
+
export declare function processNotification(notification: NotificationUnion, readNotifications?: string[]): INotification;
|
|
11
11
|
/**
|
|
12
12
|
* Safe version of processing a notification. Rather than throwing an error if failed to process, it will return the Notification or undefined
|
|
13
13
|
*
|
|
@@ -15,5 +15,5 @@ export declare function processNotification(notification: RawNotificationUnion,
|
|
|
15
15
|
* @param readNotifications - all read notifications currently
|
|
16
16
|
* @returns a process notification or undefined if failed to process
|
|
17
17
|
*/
|
|
18
|
-
export declare function safeProcessNotification(notification:
|
|
18
|
+
export declare function safeProcessNotification(notification: NotificationUnion, readNotifications?: string[]): INotification | undefined;
|
|
19
19
|
//# sourceMappingURL=process-notifications.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"process-notifications.d.cts","sourceRoot":"","sources":["../../../src/NotificationServicesController/processors/process-notifications.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,aAAa,EACb,
|
|
1
|
+
{"version":3,"file":"process-notifications.d.cts","sourceRoot":"","sources":["../../../src/NotificationServicesController/processors/process-notifications.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,aAAa,EACb,iBAAiB,EAClB,+CAA2C;AAiB5C;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CACjC,YAAY,EAAE,iBAAiB,EAC/B,iBAAiB,GAAE,MAAM,EAAO,GAC/B,aAAa,CAmBf;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,YAAY,EAAE,iBAAiB,EAC/B,iBAAiB,GAAE,MAAM,EAAO,GAC/B,aAAa,GAAG,SAAS,CAU3B"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { INotification,
|
|
1
|
+
import type { INotification, NotificationUnion } from "../types/notification/notification.mjs";
|
|
2
2
|
/**
|
|
3
3
|
* Process feature announcement and wallet notifications into a shared/normalised notification shape.
|
|
4
4
|
* We can still differentiate notifications by the `type` property
|
|
@@ -7,7 +7,7 @@ import type { INotification, RawNotificationUnion } from "../types/notification/
|
|
|
7
7
|
* @param readNotifications - all read notifications currently
|
|
8
8
|
* @returns a processed notification
|
|
9
9
|
*/
|
|
10
|
-
export declare function processNotification(notification:
|
|
10
|
+
export declare function processNotification(notification: NotificationUnion, readNotifications?: string[]): INotification;
|
|
11
11
|
/**
|
|
12
12
|
* Safe version of processing a notification. Rather than throwing an error if failed to process, it will return the Notification or undefined
|
|
13
13
|
*
|
|
@@ -15,5 +15,5 @@ export declare function processNotification(notification: RawNotificationUnion,
|
|
|
15
15
|
* @param readNotifications - all read notifications currently
|
|
16
16
|
* @returns a process notification or undefined if failed to process
|
|
17
17
|
*/
|
|
18
|
-
export declare function safeProcessNotification(notification:
|
|
18
|
+
export declare function safeProcessNotification(notification: NotificationUnion, readNotifications?: string[]): INotification | undefined;
|
|
19
19
|
//# sourceMappingURL=process-notifications.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"process-notifications.d.mts","sourceRoot":"","sources":["../../../src/NotificationServicesController/processors/process-notifications.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,aAAa,EACb,
|
|
1
|
+
{"version":3,"file":"process-notifications.d.mts","sourceRoot":"","sources":["../../../src/NotificationServicesController/processors/process-notifications.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,aAAa,EACb,iBAAiB,EAClB,+CAA2C;AAiB5C;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CACjC,YAAY,EAAE,iBAAiB,EAC/B,iBAAiB,GAAE,MAAM,EAAO,GAC/B,aAAa,CAmBf;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,YAAY,EAAE,iBAAiB,EAC/B,iBAAiB,GAAE,MAAM,EAAO,GAC/B,aAAa,GAAG,SAAS,CAU3B"}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { TRIGGER_TYPES } from "../constants/notification-schema.mjs";
|
|
2
2
|
import { isFeatureAnnouncementRead, processFeatureAnnouncement } from "./process-feature-announcement.mjs";
|
|
3
3
|
import { processOnChainNotification } from "./process-onchain-notifications.mjs";
|
|
4
|
-
import { processSnapNotification } from "./process-snap-notifications.mjs";
|
|
5
4
|
const isOnChainNotification = (n) => Object.values(TRIGGER_TYPES).includes(n.type);
|
|
6
5
|
const isFeatureAnnouncement = (n) => n.type === TRIGGER_TYPES.FEATURES_ANNOUNCEMENT;
|
|
7
|
-
const isSnapNotification = (n) => n.type === TRIGGER_TYPES.SNAP;
|
|
8
6
|
/**
|
|
9
7
|
* Process feature announcement and wallet notifications into a shared/normalised notification shape.
|
|
10
8
|
* We can still differentiate notifications by the `type` property
|
|
@@ -23,9 +21,6 @@ export function processNotification(notification, readNotifications = []) {
|
|
|
23
21
|
n.isRead = isFeatureAnnouncementRead(n, readNotifications);
|
|
24
22
|
return n;
|
|
25
23
|
}
|
|
26
|
-
if (isSnapNotification(notification)) {
|
|
27
|
-
return processSnapNotification(notification);
|
|
28
|
-
}
|
|
29
24
|
if (isOnChainNotification(notification)) {
|
|
30
25
|
return processOnChainNotification(notification);
|
|
31
26
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"process-notifications.mjs","sourceRoot":"","sources":["../../../src/NotificationServicesController/processors/process-notifications.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,6CAAyC;
|
|
1
|
+
{"version":3,"file":"process-notifications.mjs","sourceRoot":"","sources":["../../../src/NotificationServicesController/processors/process-notifications.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,6CAAyC;AAOjE,OAAO,EACL,yBAAyB,EACzB,0BAA0B,EAC3B,2CAAuC;AACxC,OAAO,EAAE,0BAA0B,EAAE,4CAAwC;AAE7E,MAAM,qBAAqB,GAAG,CAC5B,CAAoB,EACS,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;AAEhF,MAAM,qBAAqB,GAAG,CAC5B,CAAoB,EACqB,EAAE,CAC3C,CAAC,CAAC,IAAI,KAAK,aAAa,CAAC,qBAAqB,CAAC;AAEjD;;;;;;;GAOG;AACH,MAAM,UAAU,mBAAmB,CACjC,YAA+B,EAC/B,oBAA8B,EAAE;IAEhC,MAAM,iBAAiB,GAAG,CAAC,CAAQ,EAAE,EAAE;QACrC,MAAM,IAAI,GAAW,YAAY,EAAE,IAAI,CAAC;QACxC,MAAM,IAAI,KAAK,CAAC,4CAA4C,IAAI,EAAE,CAAC,CAAC;IACtE,CAAC,CAAC;IAEF,IAAI,qBAAqB,CAAC,YAAY,CAAC,EAAE;QACvC,MAAM,CAAC,GAAG,0BAA0B,CAClC,YAAkD,CACnD,CAAC;QACF,CAAC,CAAC,MAAM,GAAG,yBAAyB,CAAC,CAAC,EAAE,iBAAiB,CAAC,CAAC;QAC3D,OAAO,CAAC,CAAC;KACV;IAED,IAAI,qBAAqB,CAAC,YAAY,CAAC,EAAE;QACvC,OAAO,0BAA0B,CAAC,YAAsC,CAAC,CAAC;KAC3E;IAED,OAAO,iBAAiB,CAAC,YAAqB,CAAC,CAAC;AAClD,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,uBAAuB,CACrC,YAA+B,EAC/B,oBAA8B,EAAE;IAEhC,IAAI;QACF,MAAM,qBAAqB,GAAG,mBAAmB,CAC/C,YAAY,EACZ,iBAAiB,CAClB,CAAC;QACF,OAAO,qBAAqB,CAAC;KAC9B;IAAC,MAAM;QACN,OAAO,SAAS,CAAC;KAClB;AACH,CAAC","sourcesContent":["import { TRIGGER_TYPES } from '../constants/notification-schema';\nimport type { FeatureAnnouncementRawNotification } from '../types/feature-announcement/feature-announcement';\nimport type {\n INotification,\n NotificationUnion,\n} from '../types/notification/notification';\nimport type { OnChainRawNotification } from '../types/on-chain-notification/on-chain-notification';\nimport {\n isFeatureAnnouncementRead,\n processFeatureAnnouncement,\n} from './process-feature-announcement';\nimport { processOnChainNotification } from './process-onchain-notifications';\n\nconst isOnChainNotification = (\n n: NotificationUnion,\n): n is OnChainRawNotification => Object.values(TRIGGER_TYPES).includes(n.type);\n\nconst isFeatureAnnouncement = (\n n: NotificationUnion,\n): n is FeatureAnnouncementRawNotification =>\n n.type === TRIGGER_TYPES.FEATURES_ANNOUNCEMENT;\n\n/**\n * Process feature announcement and wallet notifications into a shared/normalised notification shape.\n * We can still differentiate notifications by the `type` property\n *\n * @param notification - a feature announcement or on chain notification\n * @param readNotifications - all read notifications currently\n * @returns a processed notification\n */\nexport function processNotification(\n notification: NotificationUnion,\n readNotifications: string[] = [],\n): INotification {\n const exhaustedAllCases = (_: never) => {\n const type: string = notification?.type;\n throw new Error(`No processor found for notification kind ${type}`);\n };\n\n if (isFeatureAnnouncement(notification)) {\n const n = processFeatureAnnouncement(\n notification as FeatureAnnouncementRawNotification,\n );\n n.isRead = isFeatureAnnouncementRead(n, readNotifications);\n return n;\n }\n\n if (isOnChainNotification(notification)) {\n return processOnChainNotification(notification as OnChainRawNotification);\n }\n\n return exhaustedAllCases(notification as never);\n}\n\n/**\n * Safe version of processing a notification. Rather than throwing an error if failed to process, it will return the Notification or undefined\n *\n * @param notification - notification to processes\n * @param readNotifications - all read notifications currently\n * @returns a process notification or undefined if failed to process\n */\nexport function safeProcessNotification(\n notification: NotificationUnion,\n readNotifications: string[] = [],\n): INotification | undefined {\n try {\n const processedNotification = processNotification(\n notification,\n readNotifications,\n );\n return processedNotification;\n } catch {\n return undefined;\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notification.cjs","sourceRoot":"","sources":["../../../../src/NotificationServicesController/types/notification/notification.ts"],"names":[],"mappings":"","sourcesContent":["import type { FeatureAnnouncementRawNotification } from '../feature-announcement/feature-announcement';\nimport type { OnChainRawNotification } from '../on-chain-notification/on-chain-notification';\nimport type {
|
|
1
|
+
{"version":3,"file":"notification.cjs","sourceRoot":"","sources":["../../../../src/NotificationServicesController/types/notification/notification.ts"],"names":[],"mappings":"","sourcesContent":["import type { FeatureAnnouncementRawNotification } from '../feature-announcement/feature-announcement';\nimport type { OnChainRawNotification } from '../on-chain-notification/on-chain-notification';\nimport type { Compute } from '../type-utils';\n\nexport type NotificationUnion =\n | FeatureAnnouncementRawNotification\n | OnChainRawNotification;\n\n/**\n * The shape of a \"generic\" notification.\n * Other than the fields listed below, tt will also contain:\n * - `type` field (declared in the Raw shapes)\n * - `data` field (declared in the Raw shapes)\n */\nexport type INotification = Compute<\n NotificationUnion & {\n id: string;\n createdAt: string;\n isRead: boolean;\n }\n>;\n\n// NFT\nexport type NFT = {\n // eslint-disable-next-line @typescript-eslint/naming-convention\n token_id: string;\n image: string;\n collection?: {\n name: string;\n image: string;\n };\n};\n\nexport type MarkAsReadNotificationsParam = Pick<\n INotification,\n 'id' | 'type' | 'isRead'\n>[];\n"]}
|
|
@@ -1,22 +1,18 @@
|
|
|
1
1
|
import type { FeatureAnnouncementRawNotification } from "../feature-announcement/feature-announcement.cjs";
|
|
2
2
|
import type { OnChainRawNotification } from "../on-chain-notification/on-chain-notification.cjs";
|
|
3
|
-
import type { RawSnapNotification } from "../snaps/index.cjs";
|
|
4
3
|
import type { Compute } from "../type-utils.cjs";
|
|
5
|
-
export type
|
|
6
|
-
id: string;
|
|
7
|
-
createdAt: string;
|
|
8
|
-
isRead: boolean;
|
|
9
|
-
};
|
|
10
|
-
export type RawNotificationUnion = OnChainRawNotification | FeatureAnnouncementRawNotification | RawSnapNotification;
|
|
4
|
+
export type NotificationUnion = FeatureAnnouncementRawNotification | OnChainRawNotification;
|
|
11
5
|
/**
|
|
12
6
|
* The shape of a "generic" notification.
|
|
13
7
|
* Other than the fields listed below, tt will also contain:
|
|
14
8
|
* - `type` field (declared in the Raw shapes)
|
|
15
9
|
* - `data` field (declared in the Raw shapes)
|
|
16
10
|
*/
|
|
17
|
-
export type INotification = Compute<
|
|
18
|
-
|
|
19
|
-
|
|
11
|
+
export type INotification = Compute<NotificationUnion & {
|
|
12
|
+
id: string;
|
|
13
|
+
createdAt: string;
|
|
14
|
+
isRead: boolean;
|
|
15
|
+
}>;
|
|
20
16
|
export type NFT = {
|
|
21
17
|
token_id: string;
|
|
22
18
|
image: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notification.d.cts","sourceRoot":"","sources":["../../../../src/NotificationServicesController/types/notification/notification.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kCAAkC,EAAE,yDAAqD;AACvG,OAAO,KAAK,EAAE,sBAAsB,EAAE,2DAAuD;AAC7F,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"notification.d.cts","sourceRoot":"","sources":["../../../../src/NotificationServicesController/types/notification/notification.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kCAAkC,EAAE,yDAAqD;AACvG,OAAO,KAAK,EAAE,sBAAsB,EAAE,2DAAuD;AAC7F,OAAO,KAAK,EAAE,OAAO,EAAE,0BAAsB;AAE7C,MAAM,MAAM,iBAAiB,GACzB,kCAAkC,GAClC,sBAAsB,CAAC;AAE3B;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GAAG,OAAO,CACjC,iBAAiB,GAAG;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,OAAO,CAAC;CACjB,CACF,CAAC;AAGF,MAAM,MAAM,GAAG,GAAG;IAEhB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE;QACX,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,4BAA4B,GAAG,IAAI,CAC7C,aAAa,EACb,IAAI,GAAG,MAAM,GAAG,QAAQ,CACzB,EAAE,CAAC"}
|
|
@@ -1,22 +1,18 @@
|
|
|
1
1
|
import type { FeatureAnnouncementRawNotification } from "../feature-announcement/feature-announcement.mjs";
|
|
2
2
|
import type { OnChainRawNotification } from "../on-chain-notification/on-chain-notification.mjs";
|
|
3
|
-
import type { RawSnapNotification } from "../snaps/index.mjs";
|
|
4
3
|
import type { Compute } from "../type-utils.mjs";
|
|
5
|
-
export type
|
|
6
|
-
id: string;
|
|
7
|
-
createdAt: string;
|
|
8
|
-
isRead: boolean;
|
|
9
|
-
};
|
|
10
|
-
export type RawNotificationUnion = OnChainRawNotification | FeatureAnnouncementRawNotification | RawSnapNotification;
|
|
4
|
+
export type NotificationUnion = FeatureAnnouncementRawNotification | OnChainRawNotification;
|
|
11
5
|
/**
|
|
12
6
|
* The shape of a "generic" notification.
|
|
13
7
|
* Other than the fields listed below, tt will also contain:
|
|
14
8
|
* - `type` field (declared in the Raw shapes)
|
|
15
9
|
* - `data` field (declared in the Raw shapes)
|
|
16
10
|
*/
|
|
17
|
-
export type INotification = Compute<
|
|
18
|
-
|
|
19
|
-
|
|
11
|
+
export type INotification = Compute<NotificationUnion & {
|
|
12
|
+
id: string;
|
|
13
|
+
createdAt: string;
|
|
14
|
+
isRead: boolean;
|
|
15
|
+
}>;
|
|
20
16
|
export type NFT = {
|
|
21
17
|
token_id: string;
|
|
22
18
|
image: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notification.d.mts","sourceRoot":"","sources":["../../../../src/NotificationServicesController/types/notification/notification.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kCAAkC,EAAE,yDAAqD;AACvG,OAAO,KAAK,EAAE,sBAAsB,EAAE,2DAAuD;AAC7F,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"notification.d.mts","sourceRoot":"","sources":["../../../../src/NotificationServicesController/types/notification/notification.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kCAAkC,EAAE,yDAAqD;AACvG,OAAO,KAAK,EAAE,sBAAsB,EAAE,2DAAuD;AAC7F,OAAO,KAAK,EAAE,OAAO,EAAE,0BAAsB;AAE7C,MAAM,MAAM,iBAAiB,GACzB,kCAAkC,GAClC,sBAAsB,CAAC;AAE3B;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GAAG,OAAO,CACjC,iBAAiB,GAAG;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,OAAO,CAAC;CACjB,CACF,CAAC;AAGF,MAAM,MAAM,GAAG,GAAG;IAEhB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE;QACX,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,4BAA4B,GAAG,IAAI,CAC7C,aAAa,EACb,IAAI,GAAG,MAAM,GAAG,QAAQ,CACzB,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notification.mjs","sourceRoot":"","sources":["../../../../src/NotificationServicesController/types/notification/notification.ts"],"names":[],"mappings":"","sourcesContent":["import type { FeatureAnnouncementRawNotification } from '../feature-announcement/feature-announcement';\nimport type { OnChainRawNotification } from '../on-chain-notification/on-chain-notification';\nimport type {
|
|
1
|
+
{"version":3,"file":"notification.mjs","sourceRoot":"","sources":["../../../../src/NotificationServicesController/types/notification/notification.ts"],"names":[],"mappings":"","sourcesContent":["import type { FeatureAnnouncementRawNotification } from '../feature-announcement/feature-announcement';\nimport type { OnChainRawNotification } from '../on-chain-notification/on-chain-notification';\nimport type { Compute } from '../type-utils';\n\nexport type NotificationUnion =\n | FeatureAnnouncementRawNotification\n | OnChainRawNotification;\n\n/**\n * The shape of a \"generic\" notification.\n * Other than the fields listed below, tt will also contain:\n * - `type` field (declared in the Raw shapes)\n * - `data` field (declared in the Raw shapes)\n */\nexport type INotification = Compute<\n NotificationUnion & {\n id: string;\n createdAt: string;\n isRead: boolean;\n }\n>;\n\n// NFT\nexport type NFT = {\n // eslint-disable-next-line @typescript-eslint/naming-convention\n token_id: string;\n image: string;\n collection?: {\n name: string;\n image: string;\n };\n};\n\nexport type MarkAsReadNotificationsParam = Pick<\n INotification,\n 'id' | 'type' | 'isRead'\n>[];\n"]}
|
|
@@ -88,9 +88,8 @@ class NotificationServicesPushController extends base_controller_1.BaseControlle
|
|
|
88
88
|
* 3. Sending the FCM token to the server responsible for sending notifications, to register the device.
|
|
89
89
|
*
|
|
90
90
|
* @param UUIDs - An array of UUIDs to enable push notifications for.
|
|
91
|
-
* @param fcmToken - The optional FCM token to use for push notifications.
|
|
92
91
|
*/
|
|
93
|
-
async enablePushNotifications(UUIDs
|
|
92
|
+
async enablePushNotifications(UUIDs) {
|
|
94
93
|
if (!__classPrivateFieldGet(this, _NotificationServicesPushController_config, "f").isPushEnabled) {
|
|
95
94
|
return;
|
|
96
95
|
}
|
|
@@ -104,7 +103,6 @@ class NotificationServicesPushController extends base_controller_1.BaseControlle
|
|
|
104
103
|
bearerToken,
|
|
105
104
|
triggers: UUIDs,
|
|
106
105
|
env: __classPrivateFieldGet(this, _NotificationServicesPushController_env, "f"),
|
|
107
|
-
fcmToken,
|
|
108
106
|
createRegToken: push_web_1.createRegToken,
|
|
109
107
|
platform: __classPrivateFieldGet(this, _NotificationServicesPushController_config, "f").platform,
|
|
110
108
|
}).catch(() => null);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NotificationServicesPushController.cjs","sourceRoot":"","sources":["../../src/NotificationServicesPushController/NotificationServicesPushController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAMA,+DAA2D;AAE3D,wDAA2B;AAG3B,2DAA0E;AAC1E,sDAK6B;AAG7B,MAAM,cAAc,GAAG,oCAAoC,CAAC;AAwE/C,QAAA,YAAY,GAA4C;IACnE,QAAQ,EAAE,EAAE;CACb,CAAC;AACF,MAAM,QAAQ,GAA2D;IACvE,QAAQ,EAAE;QACR,OAAO,EAAE,IAAI;QACb,SAAS,EAAE,IAAI;KAChB;CACF,CAAC;AAgCF;;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enger,\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n StateMetadata,\n} from '@metamask/base-controller';\nimport { BaseController } from '@metamask/base-controller';\nimport type { AuthenticationController } from '@metamask/profile-sync-controller';\nimport log from 'loglevel';\n\nimport type { Types } from '../NotificationServicesController';\nimport { createRegToken, deleteRegToken } from './services/push/push-web';\nimport {\n activatePushNotifications,\n deactivatePushNotifications,\n listenToPushNotifications,\n updateTriggerPushNotifications,\n} from './services/services';\nimport type { PushNotificationEnv } from './types';\n\nconst controllerName = 'NotificationServicesPushController';\n\nexport type NotificationServicesPushControllerState = {\n fcmToken: string;\n};\n\nexport type NotificationServicesPushControllerGetStateAction =\n ControllerGetStateAction<\n typeof controllerName,\n NotificationServicesPushControllerState\n >;\n\nexport type NotificationServicesPushControllerEnablePushNotificationsAction = {\n type: `${typeof controllerName}:enablePushNotifications`;\n handler: NotificationServicesPushController['enablePushNotifications'];\n};\nexport type NotificationServicesPushControllerDisablePushNotificationsAction = {\n type: `${typeof controllerName}:disablePushNotifications`;\n handler: NotificationServicesPushController['disablePushNotifications'];\n};\nexport type NotificationServicesPushControllerUpdateTriggerPushNotificationsAction =\n {\n type: `${typeof controllerName}:updateTriggerPushNotifications`;\n handler: NotificationServicesPushController['updateTriggerPushNotifications'];\n };\nexport type NotificationServicesPushControllerSubscribeToNotificationsAction = {\n type: `${typeof controllerName}:subscribeToPushNotifications`;\n handler: NotificationServicesPushController['subscribeToPushNotifications'];\n};\n\nexport type Actions =\n | NotificationServicesPushControllerGetStateAction\n | NotificationServicesPushControllerEnablePushNotificationsAction\n | NotificationServicesPushControllerDisablePushNotificationsAction\n | NotificationServicesPushControllerUpdateTriggerPushNotificationsAction\n | NotificationServicesPushControllerSubscribeToNotificationsAction;\n\nexport type AllowedActions =\n AuthenticationController.AuthenticationControllerGetBearerToken;\n\nexport type NotificationServicesPushControllerStateChangeEvent =\n ControllerStateChangeEvent<\n typeof controllerName,\n NotificationServicesPushControllerState\n >;\n\nexport type NotificationServicesPushControllerOnNewNotificationEvent = {\n type: `${typeof controllerName}:onNewNotifications`;\n payload: [Types.INotification];\n};\n\nexport type NotificationServicesPushControllerPushNotificationClickedEvent = {\n type: `${typeof controllerName}:pushNotificationClicked`;\n payload: [Types.INotification];\n};\n\nexport type Events =\n | NotificationServicesPushControllerStateChangeEvent\n | NotificationServicesPushControllerOnNewNotificationEvent\n | NotificationServicesPushControllerPushNotificationClickedEvent;\n\nexport type AllowedEvents = never;\n\nexport type NotificationServicesPushControllerMessenger =\n RestrictedControllerMessenger<\n typeof controllerName,\n Actions | AllowedActions,\n Events | AllowedEvents,\n AllowedActions['type'],\n AllowedEvents['type']\n >;\n\nexport const defaultState: NotificationServicesPushControllerState = {\n fcmToken: '',\n};\nconst metadata: StateMetadata<NotificationServicesPushControllerState> = {\n fcmToken: {\n persist: true,\n anonymous: true,\n },\n};\n\ntype ControllerConfig = {\n /**\n * Config to turn on/off push notifications.\n * This is currently linked to MV3 builds on extension.\n */\n isPushEnabled: boolean;\n\n /**\n * Must handle when a push notification is received.\n * You must call `registration.showNotification` or equivalent to show the notification on web/mobile\n */\n onPushNotificationReceived: (\n notification: Types.INotification,\n ) => void | Promise<void>;\n\n /**\n * Must handle when a push notification is clicked.\n * You must call `event.notification.close();` or equivalent for closing and opening notification in a new window.\n */\n onPushNotificationClicked: (\n event: NotificationEvent,\n notification?: Types.INotification,\n ) => void;\n\n /**\n * determine the config used for push notification services\n */\n platform: 'extension' | 'mobile';\n};\n\n/**\n * Manages push notifications for the application, including enabling, disabling, and updating triggers for push notifications.\n * This controller integrates with Firebase Cloud Messaging (FCM) to handle the registration and management of push notifications.\n * It is responsible for registering and unregistering the service worker that listens for push notifications,\n * managing the FCM token, and communicating with the server to register or unregister the device for push notifications.\n * Additionally, it provides functionality to update the server with new UUIDs that should trigger push notifications.\n *\n * @augments {BaseController<typeof controllerName, NotificationServicesPushControllerState, NotificationServicesPushControllerMessenger>}\n */\nexport default class NotificationServicesPushController extends BaseController<\n typeof controllerName,\n NotificationServicesPushControllerState,\n NotificationServicesPushControllerMessenger\n> {\n #pushListenerUnsubscribe: (() => void) | undefined = undefined;\n\n #env: PushNotificationEnv;\n\n #config: ControllerConfig;\n\n constructor({\n messenger,\n state,\n env,\n config,\n }: {\n messenger: NotificationServicesPushControllerMessenger;\n state: NotificationServicesPushControllerState;\n env: PushNotificationEnv;\n config: ControllerConfig;\n }) {\n super({\n messenger,\n metadata,\n name: controllerName,\n state: { ...defaultState, ...state },\n });\n\n this.#env = env;\n this.#config = config;\n\n this.#registerMessageHandlers();\n }\n\n #registerMessageHandlers(): void {\n this.messagingSystem.registerActionHandler(\n 'NotificationServicesPushController:enablePushNotifications',\n this.enablePushNotifications.bind(this),\n );\n this.messagingSystem.registerActionHandler(\n 'NotificationServicesPushController:disablePushNotifications',\n this.disablePushNotifications.bind(this),\n );\n this.messagingSystem.registerActionHandler(\n 'NotificationServicesPushController:updateTriggerPushNotifications',\n this.updateTriggerPushNotifications.bind(this),\n );\n this.messagingSystem.registerActionHandler(\n 'NotificationServicesPushController:subscribeToPushNotifications',\n this.subscribeToPushNotifications.bind(this),\n );\n }\n\n async #getAndAssertBearerToken() {\n const bearerToken = await this.messagingSystem.call(\n 'AuthenticationController:getBearerToken',\n );\n if (!bearerToken) {\n log.error(\n 'Failed to enable push notifications: BearerToken token is missing.',\n );\n throw new Error('BearerToken token is missing');\n }\n\n return bearerToken;\n }\n\n async subscribeToPushNotifications() {\n if (this.#pushListenerUnsubscribe) {\n this.#pushListenerUnsubscribe();\n this.#pushListenerUnsubscribe = undefined;\n }\n\n try {\n this.#pushListenerUnsubscribe = await listenToPushNotifications({\n env: this.#env,\n listenToPushReceived: async (n) => {\n this.messagingSystem.publish(\n 'NotificationServicesPushController:onNewNotifications',\n n,\n );\n await this.#config.onPushNotificationReceived(n);\n },\n listenToPushClicked: (e, n) => {\n if (n) {\n this.messagingSystem.publish(\n 'NotificationServicesPushController:pushNotificationClicked',\n n,\n );\n }\n\n this.#config.onPushNotificationClicked(e, n);\n },\n });\n } catch (e) {\n // Do nothing, we are silently failing if push notification registration fails\n }\n }\n\n /**\n * Enables push notifications for the application.\n *\n * This method sets up the necessary infrastructure for handling push notifications by:\n * 1. Registering the service worker to listen for messages.\n * 2. Fetching the Firebase Cloud Messaging (FCM) token from Firebase.\n * 3. Sending the FCM token to the server responsible for sending notifications, to register the device.\n *\n * @param UUIDs - An array of UUIDs to enable push notifications for.\n * @param fcmToken - The optional FCM token to use for push notifications.\n */\n async enablePushNotifications(UUIDs: string[], fcmToken?: string) {\n if (!this.#config.isPushEnabled) {\n return;\n }\n\n // Handle creating new reg token (if available)\n try {\n const bearerToken = await this.#getAndAssertBearerToken().catch(\n () => null,\n );\n\n // If there is a bearer token, lets try to refresh/create new reg token\n if (bearerToken) {\n // Activate Push Notifications\n const regToken = await activatePushNotifications({\n bearerToken,\n triggers: UUIDs,\n env: this.#env,\n fcmToken,\n createRegToken,\n platform: this.#config.platform,\n }).catch(() => null);\n\n if (regToken) {\n this.update((state) => {\n state.fcmToken = regToken;\n });\n }\n }\n } catch {\n // Do nothing, we are silently failing\n }\n\n // New token created, (re)subscribe to push notifications\n await this.subscribeToPushNotifications();\n }\n\n /**\n * Disables push notifications for the application.\n * This method handles the process of disabling push notifications by:\n * 1. Unregistering the service worker to stop listening for messages.\n * 2. Sending a request to the server to unregister the device using the FCM token.\n * 3. Removing the FCM token from the state to complete the process.\n *\n * @param UUIDs - An array of UUIDs for which push notifications should be disabled.\n */\n async disablePushNotifications(UUIDs: string[]) {\n if (!this.#config.isPushEnabled) {\n return;\n }\n\n const bearerToken = await this.#getAndAssertBearerToken();\n let isPushNotificationsDisabled: boolean;\n\n try {\n // Send a request to the server to unregister the token/device\n isPushNotificationsDisabled = await deactivatePushNotifications({\n bearerToken,\n triggers: UUIDs,\n env: this.#env,\n deleteRegToken,\n regToken: this.state.fcmToken,\n });\n } catch (error) {\n const errorMessage = `Failed to disable push notifications: ${\n error as string\n }`;\n log.error(errorMessage);\n throw new Error(errorMessage);\n }\n\n // Remove the FCM token from the state\n if (!isPushNotificationsDisabled) {\n return;\n }\n\n // Unsubscribe from push notifications\n this.#pushListenerUnsubscribe?.();\n\n // Update State\n if (isPushNotificationsDisabled) {\n this.update((state) => {\n state.fcmToken = '';\n });\n }\n }\n\n /**\n * Updates the triggers for push notifications.\n * This method is responsible for updating the server with the new set of UUIDs that should trigger push notifications.\n * It uses the current FCM token and a BearerToken for authentication.\n *\n * @param UUIDs - An array of UUIDs that should trigger push notifications.\n */\n async updateTriggerPushNotifications(UUIDs: string[]) {\n if (!this.#config.isPushEnabled) {\n return;\n }\n\n const bearerToken = await this.#getAndAssertBearerToken();\n\n try {\n const { fcmToken } = await updateTriggerPushNotifications({\n bearerToken,\n triggers: UUIDs,\n env: this.#env,\n createRegToken,\n deleteRegToken,\n platform: this.#config.platform,\n regToken: this.state.fcmToken,\n });\n\n // update the state with the new FCM token\n if (fcmToken) {\n this.update((state) => {\n state.fcmToken = fcmToken;\n });\n }\n } catch (error) {\n const errorMessage = `Failed to update triggers for push notifications: ${\n error as string\n }`;\n log.error(errorMessage);\n throw new Error(errorMessage);\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"NotificationServicesPushController.cjs","sourceRoot":"","sources":["../../src/NotificationServicesPushController/NotificationServicesPushController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAMA,+DAA2D;AAE3D,wDAA2B;AAG3B,2DAA0E;AAC1E,sDAK6B;AAG7B,MAAM,cAAc,GAAG,oCAAoC,CAAC;AAwE/C,QAAA,YAAY,GAA4C;IACnE,QAAQ,EAAE,EAAE;CACb,CAAC;AACF,MAAM,QAAQ,GAA2D;IACvE,QAAQ,EAAE;QACR,OAAO,EAAE,IAAI;QACb,SAAS,EAAE,IAAI;KAChB;CACF,CAAC;AAgCF;;;;;;;;GAQG;AACH,MAAqB,kCAAmC,SAAQ,gCAI/D;IAOC,YAAY,EACV,SAAS,EACT,KAAK,EACL,GAAG,EACH,MAAM,GAMP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AAE;oBACpB,KAAK,CAAC,QAAQ,GAAG,QAAQ,CAAC;gBAC5B,CAAC,CAAC,CAAC;aACJ;SACF;QAAC,OAAO,KAAK,EAAE;YACd,MAAM,YAAY,GAAG,qDACnB,KACF,EAAE,CAAC;YACH,kBAAG,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;YACxB,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;SAC/B;IACH,CAAC;CACF;;IAvMG,IAAI,CAAC,eAAe,CAAC,qBAAqB,CACxC,4DAA4D,EAC5D,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC,IAAI,CAAC,CACxC,CAAC;IACF,IAAI,CAAC,eAAe,CAAC,qBAAqB,CACxC,6DAA6D,EAC7D,IAAI,CAAC,wBAAwB,CAAC,IAAI,CAAC,IAAI,CAAC,CACzC,CAAC;IACF,IAAI,CAAC,eAAe,CAAC,qBAAqB,CACxC,mEAAmE,EACnE,IAAI,CAAC,8BAA8B,CAAC,IAAI,CAAC,IAAI,CAAC,CAC/C,CAAC;IACF,IAAI,CAAC,eAAe,CAAC,qBAAqB,CACxC,iEAAiE,EACjE,IAAI,CAAC,4BAA4B,CAAC,IAAI,CAAC,IAAI,CAAC,CAC7C,CAAC;AACJ,CAAC,gEAED,KAAK;IACH,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,IAAI,CACjD,yCAAyC,CAC1C,CAAC;IACF,IAAI,CAAC,WAAW,EAAE;QAChB,kBAAG,CAAC,KAAK,CACP,oEAAoE,CACrE,CAAC;QACF,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;KACjD;IAED,OAAO,WAAW,CAAC;AACrB,CAAC;kBAlEkB,kCAAkC","sourcesContent":["import type {\n RestrictedControllerMessenger,\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n StateMetadata,\n} from '@metamask/base-controller';\nimport { BaseController } from '@metamask/base-controller';\nimport type { AuthenticationController } from '@metamask/profile-sync-controller';\nimport log from 'loglevel';\n\nimport type { Types } from '../NotificationServicesController';\nimport { createRegToken, deleteRegToken } from './services/push/push-web';\nimport {\n activatePushNotifications,\n deactivatePushNotifications,\n listenToPushNotifications,\n updateTriggerPushNotifications,\n} from './services/services';\nimport type { PushNotificationEnv } from './types';\n\nconst controllerName = 'NotificationServicesPushController';\n\nexport type NotificationServicesPushControllerState = {\n fcmToken: string;\n};\n\nexport type NotificationServicesPushControllerGetStateAction =\n ControllerGetStateAction<\n typeof controllerName,\n NotificationServicesPushControllerState\n >;\n\nexport type NotificationServicesPushControllerEnablePushNotificationsAction = {\n type: `${typeof controllerName}:enablePushNotifications`;\n handler: NotificationServicesPushController['enablePushNotifications'];\n};\nexport type NotificationServicesPushControllerDisablePushNotificationsAction = {\n type: `${typeof controllerName}:disablePushNotifications`;\n handler: NotificationServicesPushController['disablePushNotifications'];\n};\nexport type NotificationServicesPushControllerUpdateTriggerPushNotificationsAction =\n {\n type: `${typeof controllerName}:updateTriggerPushNotifications`;\n handler: NotificationServicesPushController['updateTriggerPushNotifications'];\n };\nexport type NotificationServicesPushControllerSubscribeToNotificationsAction = {\n type: `${typeof controllerName}:subscribeToPushNotifications`;\n handler: NotificationServicesPushController['subscribeToPushNotifications'];\n};\n\nexport type Actions =\n | NotificationServicesPushControllerGetStateAction\n | NotificationServicesPushControllerEnablePushNotificationsAction\n | NotificationServicesPushControllerDisablePushNotificationsAction\n | NotificationServicesPushControllerUpdateTriggerPushNotificationsAction\n | NotificationServicesPushControllerSubscribeToNotificationsAction;\n\nexport type AllowedActions =\n AuthenticationController.AuthenticationControllerGetBearerToken;\n\nexport type NotificationServicesPushControllerStateChangeEvent =\n ControllerStateChangeEvent<\n typeof controllerName,\n NotificationServicesPushControllerState\n >;\n\nexport type NotificationServicesPushControllerOnNewNotificationEvent = {\n type: `${typeof controllerName}:onNewNotifications`;\n payload: [Types.INotification];\n};\n\nexport type NotificationServicesPushControllerPushNotificationClickedEvent = {\n type: `${typeof controllerName}:pushNotificationClicked`;\n payload: [Types.INotification];\n};\n\nexport type Events =\n | NotificationServicesPushControllerStateChangeEvent\n | NotificationServicesPushControllerOnNewNotificationEvent\n | NotificationServicesPushControllerPushNotificationClickedEvent;\n\nexport type AllowedEvents = never;\n\nexport type NotificationServicesPushControllerMessenger =\n RestrictedControllerMessenger<\n typeof controllerName,\n Actions | AllowedActions,\n Events | AllowedEvents,\n AllowedActions['type'],\n AllowedEvents['type']\n >;\n\nexport const defaultState: NotificationServicesPushControllerState = {\n fcmToken: '',\n};\nconst metadata: StateMetadata<NotificationServicesPushControllerState> = {\n fcmToken: {\n persist: true,\n anonymous: true,\n },\n};\n\ntype ControllerConfig = {\n /**\n * Config to turn on/off push notifications.\n * This is currently linked to MV3 builds on extension.\n */\n isPushEnabled: boolean;\n\n /**\n * Must handle when a push notification is received.\n * You must call `registration.showNotification` or equivalent to show the notification on web/mobile\n */\n onPushNotificationReceived: (\n notification: Types.INotification,\n ) => void | Promise<void>;\n\n /**\n * Must handle when a push notification is clicked.\n * You must call `event.notification.close();` or equivalent for closing and opening notification in a new window.\n */\n onPushNotificationClicked: (\n event: NotificationEvent,\n notification?: Types.INotification,\n ) => void;\n\n /**\n * determine the config used for push notification services\n */\n platform: 'extension' | 'mobile';\n};\n\n/**\n * Manages push notifications for the application, including enabling, disabling, and updating triggers for push notifications.\n * This controller integrates with Firebase Cloud Messaging (FCM) to handle the registration and management of push notifications.\n * It is responsible for registering and unregistering the service worker that listens for push notifications,\n * managing the FCM token, and communicating with the server to register or unregister the device for push notifications.\n * Additionally, it provides functionality to update the server with new UUIDs that should trigger push notifications.\n *\n * @augments {BaseController<typeof controllerName, NotificationServicesPushControllerState, NotificationServicesPushControllerMessenger>}\n */\nexport default class NotificationServicesPushController extends BaseController<\n typeof controllerName,\n NotificationServicesPushControllerState,\n NotificationServicesPushControllerMessenger\n> {\n #pushListenerUnsubscribe: (() => void) | undefined = undefined;\n\n #env: PushNotificationEnv;\n\n #config: ControllerConfig;\n\n constructor({\n messenger,\n state,\n env,\n config,\n }: {\n messenger: NotificationServicesPushControllerMessenger;\n state: NotificationServicesPushControllerState;\n env: PushNotificationEnv;\n config: ControllerConfig;\n }) {\n super({\n messenger,\n metadata,\n name: controllerName,\n state: { ...defaultState, ...state },\n });\n\n this.#env = env;\n this.#config = config;\n\n this.#registerMessageHandlers();\n }\n\n #registerMessageHandlers(): void {\n this.messagingSystem.registerActionHandler(\n 'NotificationServicesPushController:enablePushNotifications',\n this.enablePushNotifications.bind(this),\n );\n this.messagingSystem.registerActionHandler(\n 'NotificationServicesPushController:disablePushNotifications',\n this.disablePushNotifications.bind(this),\n );\n this.messagingSystem.registerActionHandler(\n 'NotificationServicesPushController:updateTriggerPushNotifications',\n this.updateTriggerPushNotifications.bind(this),\n );\n this.messagingSystem.registerActionHandler(\n 'NotificationServicesPushController:subscribeToPushNotifications',\n this.subscribeToPushNotifications.bind(this),\n );\n }\n\n async #getAndAssertBearerToken() {\n const bearerToken = await this.messagingSystem.call(\n 'AuthenticationController:getBearerToken',\n );\n if (!bearerToken) {\n log.error(\n 'Failed to enable push notifications: BearerToken token is missing.',\n );\n throw new Error('BearerToken token is missing');\n }\n\n return bearerToken;\n }\n\n async subscribeToPushNotifications() {\n if (this.#pushListenerUnsubscribe) {\n this.#pushListenerUnsubscribe();\n this.#pushListenerUnsubscribe = undefined;\n }\n\n try {\n this.#pushListenerUnsubscribe = await listenToPushNotifications({\n env: this.#env,\n listenToPushReceived: async (n) => {\n this.messagingSystem.publish(\n 'NotificationServicesPushController:onNewNotifications',\n n,\n );\n await this.#config.onPushNotificationReceived(n);\n },\n listenToPushClicked: (e, n) => {\n if (n) {\n this.messagingSystem.publish(\n 'NotificationServicesPushController:pushNotificationClicked',\n n,\n );\n }\n\n this.#config.onPushNotificationClicked(e, n);\n },\n });\n } catch (e) {\n // Do nothing, we are silently failing if push notification registration fails\n }\n }\n\n /**\n * Enables push notifications for the application.\n *\n * This method sets up the necessary infrastructure for handling push notifications by:\n * 1. Registering the service worker to listen for messages.\n * 2. Fetching the Firebase Cloud Messaging (FCM) token from Firebase.\n * 3. Sending the FCM token to the server responsible for sending notifications, to register the device.\n *\n * @param UUIDs - An array of UUIDs to enable push notifications for.\n */\n async enablePushNotifications(UUIDs: string[]) {\n if (!this.#config.isPushEnabled) {\n return;\n }\n\n // Handle creating new reg token (if available)\n try {\n const bearerToken = await this.#getAndAssertBearerToken().catch(\n () => null,\n );\n\n // If there is a bearer token, lets try to refresh/create new reg token\n if (bearerToken) {\n // Activate Push Notifications\n const regToken = await activatePushNotifications({\n bearerToken,\n triggers: UUIDs,\n env: this.#env,\n createRegToken,\n platform: this.#config.platform,\n }).catch(() => null);\n\n if (regToken) {\n this.update((state) => {\n state.fcmToken = regToken;\n });\n }\n }\n } catch {\n // Do nothing, we are silently failing\n }\n\n // New token created, (re)subscribe to push notifications\n await this.subscribeToPushNotifications();\n }\n\n /**\n * Disables push notifications for the application.\n * This method handles the process of disabling push notifications by:\n * 1. Unregistering the service worker to stop listening for messages.\n * 2. Sending a request to the server to unregister the device using the FCM token.\n * 3. Removing the FCM token from the state to complete the process.\n *\n * @param UUIDs - An array of UUIDs for which push notifications should be disabled.\n */\n async disablePushNotifications(UUIDs: string[]) {\n if (!this.#config.isPushEnabled) {\n return;\n }\n\n const bearerToken = await this.#getAndAssertBearerToken();\n let isPushNotificationsDisabled: boolean;\n\n try {\n // Send a request to the server to unregister the token/device\n isPushNotificationsDisabled = await deactivatePushNotifications({\n bearerToken,\n triggers: UUIDs,\n env: this.#env,\n deleteRegToken,\n regToken: this.state.fcmToken,\n });\n } catch (error) {\n const errorMessage = `Failed to disable push notifications: ${\n error as string\n }`;\n log.error(errorMessage);\n throw new Error(errorMessage);\n }\n\n // Remove the FCM token from the state\n if (!isPushNotificationsDisabled) {\n return;\n }\n\n // Unsubscribe from push notifications\n this.#pushListenerUnsubscribe?.();\n\n // Update State\n if (isPushNotificationsDisabled) {\n this.update((state) => {\n state.fcmToken = '';\n });\n }\n }\n\n /**\n * Updates the triggers for push notifications.\n * This method is responsible for updating the server with the new set of UUIDs that should trigger push notifications.\n * It uses the current FCM token and a BearerToken for authentication.\n *\n * @param UUIDs - An array of UUIDs that should trigger push notifications.\n */\n async updateTriggerPushNotifications(UUIDs: string[]) {\n if (!this.#config.isPushEnabled) {\n return;\n }\n\n const bearerToken = await this.#getAndAssertBearerToken();\n\n try {\n const { fcmToken } = await updateTriggerPushNotifications({\n bearerToken,\n triggers: UUIDs,\n env: this.#env,\n createRegToken,\n deleteRegToken,\n platform: this.#config.platform,\n regToken: this.state.fcmToken,\n });\n\n // update the state with the new FCM token\n if (fcmToken) {\n this.update((state) => {\n state.fcmToken = fcmToken;\n });\n }\n } catch (error) {\n const errorMessage = `Failed to update triggers for push notifications: ${\n error as string\n }`;\n log.error(errorMessage);\n throw new Error(errorMessage);\n }\n }\n}\n"]}
|
|
@@ -87,9 +87,8 @@ export default class NotificationServicesPushController extends BaseController<t
|
|
|
87
87
|
* 3. Sending the FCM token to the server responsible for sending notifications, to register the device.
|
|
88
88
|
*
|
|
89
89
|
* @param UUIDs - An array of UUIDs to enable push notifications for.
|
|
90
|
-
* @param fcmToken - The optional FCM token to use for push notifications.
|
|
91
90
|
*/
|
|
92
|
-
enablePushNotifications(UUIDs: string[]
|
|
91
|
+
enablePushNotifications(UUIDs: string[]): Promise<void>;
|
|
93
92
|
/**
|
|
94
93
|
* Disables push notifications for the application.
|
|
95
94
|
* This method handles the process of disabling push notifications by:
|
package/dist/NotificationServicesPushController/NotificationServicesPushController.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NotificationServicesPushController.d.cts","sourceRoot":"","sources":["../../src/NotificationServicesPushController/NotificationServicesPushController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,6BAA6B,EAC7B,wBAAwB,EACxB,0BAA0B,EAE3B,kCAAkC;AACnC,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAC3D,OAAO,KAAK,EAAE,wBAAwB,EAA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C;QACzB,MAAM,EAAE,gBAAgB,CAAC;KAC1B;IA+CK,4BAA4B;IAgClC
|
|
1
|
+
{"version":3,"file":"NotificationServicesPushController.d.cts","sourceRoot":"","sources":["../../src/NotificationServicesPushController/NotificationServicesPushController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,6BAA6B,EAC7B,wBAAwB,EACxB,0BAA0B,EAE3B,kCAAkC;AACnC,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAC3D,OAAO,KAAK,EAAE,wBAAwB,EAAE,0CAA0C;AAGlF,OAAO,KAAK,EAAE,KAAK,EAAE,oDAA0C;AAQ/D,OAAO,KAAK,EAAE,mBAAmB,EAAE,0BAAgB;AAEnD,QAAA,MAAM,cAAc,uCAAuC,CAAC;AAE5D,MAAM,MAAM,uCAAuC,GAAG;IACpD,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,gDAAgD,GAC1D,wBAAwB,CACtB,OAAO,cAAc,EACrB,uCAAuC,CACxC,CAAC;AAEJ,MAAM,MAAM,+DAA+D,GAAG;IAC5E,IAAI,EAAE,GAAG,OAAO,cAAc,0BAA0B,CAAC;IACzD,OAAO,EAAE,kCAAkC,CAAC,yBAAyB,CAAC,CAAC;CACxE,CAAC;AACF,MAAM,MAAM,gEAAgE,GAAG;IAC7E,IAAI,EAAE,GAAG,OAAO,cAAc,2BAA2B,CAAC;IAC1D,OAAO,EAAE,kCAAkC,CAAC,0BAA0B,CAAC,CAAC;CACzE,CAAC;AACF,MAAM,MAAM,sEAAsE,GAChF;IACE,IAAI,EAAE,GAAG,OAAO,cAAc,iCAAiC,CAAC;IAChE,OAAO,EAAE,kCAAkC,CAAC,gCAAgC,CAAC,CAAC;CAC/E,CAAC;AACJ,MAAM,MAAM,gEAAgE,GAAG;IAC7E,IAAI,EAAE,GAAG,OAAO,cAAc,+BAA+B,CAAC;IAC9D,OAAO,EAAE,kCAAkC,CAAC,8BAA8B,CAAC,CAAC;CAC7E,CAAC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AAE,WAAW,GAAG,QAAQ,CAAC;CAClC,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,CAAC,OAAO,OAAO,kCAAmC,SAAQ,cAAc,CAC5E,OAAO,cAAc,EACrB,uCAAuC,EACvC,2CAA2C,CAC5C;;gBAOa,EACV,SAAS,EACT,KAAK,EACL,GAAG,EACH,MAAM,GACP,EAAE;QACD,SAAS,EAAE,2CAA2C,CAAC;QACvD,KAAK,EAAE,uCAAuC,CAAC;QAC/C,GAAG,EAAE,mBAAmB,CAAC;QACzB,MAAM,EAAE,gBAAgB,CAAC;KAC1B;IA+CK,4BAA4B;IAgClC;;;;;;;;;OASG;IACG,uBAAuB,CAAC,KAAK,EAAE,MAAM,EAAE;IAoC7C;;;;;;;;OAQG;IACG,wBAAwB,CAAC,KAAK,EAAE,MAAM,EAAE;IAyC9C;;;;;;OAMG;IACG,8BAA8B,CAAC,KAAK,EAAE,MAAM,EAAE;CAgCrD"}
|
|
@@ -87,9 +87,8 @@ export default class NotificationServicesPushController extends BaseController<t
|
|
|
87
87
|
* 3. Sending the FCM token to the server responsible for sending notifications, to register the device.
|
|
88
88
|
*
|
|
89
89
|
* @param UUIDs - An array of UUIDs to enable push notifications for.
|
|
90
|
-
* @param fcmToken - The optional FCM token to use for push notifications.
|
|
91
90
|
*/
|
|
92
|
-
enablePushNotifications(UUIDs: string[]
|
|
91
|
+
enablePushNotifications(UUIDs: string[]): Promise<void>;
|
|
93
92
|
/**
|
|
94
93
|
* Disables push notifications for the application.
|
|
95
94
|
* This method handles the process of disabling push notifications by:
|