@metamask-previews/notification-services-controller 25.0.0-preview-8fd5dfabc → 25.0.0-preview-ae00c4c29

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/CHANGELOG.md CHANGED
@@ -7,10 +7,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
- ### Fixed
11
-
12
- - Update `isOnChainRawNotification` to detect on-chain notifications using the v4 `notification_type` discriminator instead of legacy payload field checks, fixing web push notification handling after the v4 API migration ([#9407](https://github.com/MetaMask/core/pull/9407))
13
-
14
10
  ## [25.0.0]
15
11
 
16
12
  ### Added
@@ -1,15 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isOnChainRawNotification = void 0;
4
- const notification_api_type_guards_1 = require("./notification-api-type-guards.cjs");
5
4
  /**
6
- * Checks if the given value is an on-chain notification using the v4 `notification_type` discriminator.
5
+ * Checks if the given value is an OnChainRawNotification object.
7
6
  *
8
7
  * @param notification - The value to check.
9
- * @returns True if the value is an on-chain notification, false otherwise.
8
+ * @returns True if the value is an OnChainRawNotification object, false otherwise.
10
9
  */
11
10
  function isOnChainRawNotification(notification) {
12
- return (0, notification_api_type_guards_1.isOnChainNotification)(notification);
11
+ const assumed = notification;
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?.payload?.data,
17
+ ].every((field) => field !== undefined);
18
+ return isValidEnoughToBeOnChainNotification;
13
19
  }
14
20
  exports.isOnChainRawNotification = isOnChainRawNotification;
15
21
  //# sourceMappingURL=is-onchain-notification.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"is-onchain-notification.cjs","sourceRoot":"","sources":["../../src/shared/is-onchain-notification.ts"],"names":[],"mappings":";;;AAIA,qFAAuE;AAEvE;;;;;GAKG;AACH,SAAgB,wBAAwB,CACtC,YAAqB;IAErB,OAAO,IAAA,oDAAqB,EAAC,YAA0C,CAAC,CAAC;AAC3E,CAAC;AAJD,4DAIC","sourcesContent":["import type {\n UnprocessedRawNotification,\n OnChainNotification,\n} from '../NotificationServicesController/types/notification-api';\nimport { isOnChainNotification } from './notification-api-type-guards';\n\n/**\n * Checks if the given value is an on-chain notification using the v4 `notification_type` discriminator.\n *\n * @param notification - The value to check.\n * @returns True if the value is an on-chain notification, false otherwise.\n */\nexport function isOnChainRawNotification(\n notification: unknown,\n): notification is OnChainNotification {\n return isOnChainNotification(notification as UnprocessedRawNotification);\n}\n"]}
1
+ {"version":3,"file":"is-onchain-notification.cjs","sourceRoot":"","sources":["../../src/shared/is-onchain-notification.ts"],"names":[],"mappings":";;;AAEA;;;;;GAKG;AACH,SAAgB,wBAAwB,CACtC,YAAqB;IAErB,MAAM,OAAO,GAAG,YAAsC,CAAC;IAEvD,qGAAqG;IACrG,yGAAyG;IACzG,MAAM,oCAAoC,GAAG;QAC3C,OAAO,EAAE,EAAE;QACX,OAAO,EAAE,OAAO,EAAE,IAAI;KACvB,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC;IACxC,OAAO,oCAAoC,CAAC;AAC9C,CAAC;AAZD,4DAYC","sourcesContent":["import type { OnChainRawNotification } from '../NotificationServicesController';\n\n/**\n * Checks if the given value is an OnChainRawNotification object.\n *\n * @param notification - The value to check.\n * @returns True if the value is an OnChainRawNotification object, false otherwise.\n */\nexport function isOnChainRawNotification(\n notification: unknown,\n): notification is OnChainRawNotification {\n const assumed = notification 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?.payload?.data,\n ].every((field) => field !== undefined);\n return isValidEnoughToBeOnChainNotification;\n}\n"]}
@@ -1,9 +1,9 @@
1
- import type { OnChainNotification } from "../NotificationServicesController/types/notification-api/index.cjs";
1
+ import type { OnChainRawNotification } from "../NotificationServicesController/index.cjs";
2
2
  /**
3
- * Checks if the given value is an on-chain notification using the v4 `notification_type` discriminator.
3
+ * Checks if the given value is an OnChainRawNotification object.
4
4
  *
5
5
  * @param notification - The value to check.
6
- * @returns True if the value is an on-chain notification, false otherwise.
6
+ * @returns True if the value is an OnChainRawNotification object, false otherwise.
7
7
  */
8
- export declare function isOnChainRawNotification(notification: unknown): notification is OnChainNotification;
8
+ export declare function isOnChainRawNotification(notification: unknown): notification is OnChainRawNotification;
9
9
  //# sourceMappingURL=is-onchain-notification.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"is-onchain-notification.d.cts","sourceRoot":"","sources":["../../src/shared/is-onchain-notification.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,mBAAmB,EACpB,2EAAiE;AAGlE;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,YAAY,EAAE,OAAO,GACpB,YAAY,IAAI,mBAAmB,CAErC"}
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,YAAY,EAAE,OAAO,GACpB,YAAY,IAAI,sBAAsB,CAUxC"}
@@ -1,9 +1,9 @@
1
- import type { OnChainNotification } from "../NotificationServicesController/types/notification-api/index.mjs";
1
+ import type { OnChainRawNotification } from "../NotificationServicesController/index.mjs";
2
2
  /**
3
- * Checks if the given value is an on-chain notification using the v4 `notification_type` discriminator.
3
+ * Checks if the given value is an OnChainRawNotification object.
4
4
  *
5
5
  * @param notification - The value to check.
6
- * @returns True if the value is an on-chain notification, false otherwise.
6
+ * @returns True if the value is an OnChainRawNotification object, false otherwise.
7
7
  */
8
- export declare function isOnChainRawNotification(notification: unknown): notification is OnChainNotification;
8
+ export declare function isOnChainRawNotification(notification: unknown): notification is OnChainRawNotification;
9
9
  //# sourceMappingURL=is-onchain-notification.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"is-onchain-notification.d.mts","sourceRoot":"","sources":["../../src/shared/is-onchain-notification.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,mBAAmB,EACpB,2EAAiE;AAGlE;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,YAAY,EAAE,OAAO,GACpB,YAAY,IAAI,mBAAmB,CAErC"}
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,YAAY,EAAE,OAAO,GACpB,YAAY,IAAI,sBAAsB,CAUxC"}
@@ -1,11 +1,17 @@
1
- import { isOnChainNotification } from "./notification-api-type-guards.mjs";
2
1
  /**
3
- * Checks if the given value is an on-chain notification using the v4 `notification_type` discriminator.
2
+ * Checks if the given value is an OnChainRawNotification object.
4
3
  *
5
4
  * @param notification - The value to check.
6
- * @returns True if the value is an on-chain notification, false otherwise.
5
+ * @returns True if the value is an OnChainRawNotification object, false otherwise.
7
6
  */
8
7
  export function isOnChainRawNotification(notification) {
9
- return isOnChainNotification(notification);
8
+ const assumed = notification;
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?.payload?.data,
14
+ ].every((field) => field !== undefined);
15
+ return isValidEnoughToBeOnChainNotification;
10
16
  }
11
17
  //# sourceMappingURL=is-onchain-notification.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"is-onchain-notification.mjs","sourceRoot":"","sources":["../../src/shared/is-onchain-notification.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,qBAAqB,EAAE,2CAAuC;AAEvE;;;;;GAKG;AACH,MAAM,UAAU,wBAAwB,CACtC,YAAqB;IAErB,OAAO,qBAAqB,CAAC,YAA0C,CAAC,CAAC;AAC3E,CAAC","sourcesContent":["import type {\n UnprocessedRawNotification,\n OnChainNotification,\n} from '../NotificationServicesController/types/notification-api';\nimport { isOnChainNotification } from './notification-api-type-guards';\n\n/**\n * Checks if the given value is an on-chain notification using the v4 `notification_type` discriminator.\n *\n * @param notification - The value to check.\n * @returns True if the value is an on-chain notification, false otherwise.\n */\nexport function isOnChainRawNotification(\n notification: unknown,\n): notification is OnChainNotification {\n return isOnChainNotification(notification as UnprocessedRawNotification);\n}\n"]}
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,YAAqB;IAErB,MAAM,OAAO,GAAG,YAAsC,CAAC;IAEvD,qGAAqG;IACrG,yGAAyG;IACzG,MAAM,oCAAoC,GAAG;QAC3C,OAAO,EAAE,EAAE;QACX,OAAO,EAAE,OAAO,EAAE,IAAI;KACvB,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 notification - The value to check.\n * @returns True if the value is an OnChainRawNotification object, false otherwise.\n */\nexport function isOnChainRawNotification(\n notification: unknown,\n): notification is OnChainRawNotification {\n const assumed = notification 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?.payload?.data,\n ].every((field) => field !== undefined);\n return isValidEnoughToBeOnChainNotification;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask-previews/notification-services-controller",
3
- "version": "25.0.0-preview-8fd5dfabc",
3
+ "version": "25.0.0-preview-ae00c4c29",
4
4
  "description": "Manages New MetaMask decentralized Notification system",
5
5
  "keywords": [
6
6
  "Ethereum",