@metamask-previews/notification-services-controller 10.0.0-preview-7dcef379 → 10.0.0-preview-5dcecbb7
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 +0 -16
- package/dist/NotificationServicesController/NotificationServicesController.cjs +188 -76
- package/dist/NotificationServicesController/NotificationServicesController.cjs.map +1 -1
- package/dist/NotificationServicesController/NotificationServicesController.d.cts +16 -10
- package/dist/NotificationServicesController/NotificationServicesController.d.cts.map +1 -1
- package/dist/NotificationServicesController/NotificationServicesController.d.mts +16 -10
- package/dist/NotificationServicesController/NotificationServicesController.d.mts.map +1 -1
- package/dist/NotificationServicesController/NotificationServicesController.mjs +189 -77
- package/dist/NotificationServicesController/NotificationServicesController.mjs.map +1 -1
- package/dist/NotificationServicesController/constants/constants.cjs +7 -0
- package/dist/NotificationServicesController/constants/constants.cjs.map +1 -0
- package/dist/NotificationServicesController/constants/constants.d.cts +3 -0
- package/dist/NotificationServicesController/constants/constants.d.cts.map +1 -0
- package/dist/NotificationServicesController/constants/constants.d.mts +3 -0
- package/dist/NotificationServicesController/constants/constants.d.mts.map +1 -0
- package/dist/NotificationServicesController/constants/constants.mjs +4 -0
- package/dist/NotificationServicesController/constants/constants.mjs.map +1 -0
- package/dist/NotificationServicesController/constants/index.cjs +1 -0
- package/dist/NotificationServicesController/constants/index.cjs.map +1 -1
- package/dist/NotificationServicesController/constants/index.d.cts +1 -0
- package/dist/NotificationServicesController/constants/index.d.cts.map +1 -1
- package/dist/NotificationServicesController/constants/index.d.mts +1 -0
- package/dist/NotificationServicesController/constants/index.d.mts.map +1 -1
- package/dist/NotificationServicesController/constants/index.mjs +1 -0
- package/dist/NotificationServicesController/constants/index.mjs.map +1 -1
- package/dist/NotificationServicesController/mocks/index.cjs +2 -0
- package/dist/NotificationServicesController/mocks/index.cjs.map +1 -1
- package/dist/NotificationServicesController/mocks/index.d.cts +2 -0
- package/dist/NotificationServicesController/mocks/index.d.cts.map +1 -1
- package/dist/NotificationServicesController/mocks/index.d.mts +2 -0
- package/dist/NotificationServicesController/mocks/index.d.mts.map +1 -1
- package/dist/NotificationServicesController/mocks/index.mjs +2 -0
- package/dist/NotificationServicesController/mocks/index.mjs.map +1 -1
- package/dist/NotificationServicesController/mocks/mock-notification-trigger.cjs +22 -0
- package/dist/NotificationServicesController/mocks/mock-notification-trigger.cjs.map +1 -0
- package/dist/NotificationServicesController/mocks/mock-notification-trigger.d.cts +9 -0
- package/dist/NotificationServicesController/mocks/mock-notification-trigger.d.cts.map +1 -0
- package/dist/NotificationServicesController/mocks/mock-notification-trigger.d.mts +9 -0
- package/dist/NotificationServicesController/mocks/mock-notification-trigger.d.mts.map +1 -0
- package/dist/NotificationServicesController/mocks/mock-notification-trigger.mjs +18 -0
- package/dist/NotificationServicesController/mocks/mock-notification-trigger.mjs.map +1 -0
- package/dist/NotificationServicesController/mocks/mock-notification-user-storage.cjs +82 -0
- package/dist/NotificationServicesController/mocks/mock-notification-user-storage.cjs.map +1 -0
- package/dist/NotificationServicesController/mocks/mock-notification-user-storage.d.cts +35 -0
- package/dist/NotificationServicesController/mocks/mock-notification-user-storage.d.cts.map +1 -0
- package/dist/NotificationServicesController/mocks/mock-notification-user-storage.d.mts +35 -0
- package/dist/NotificationServicesController/mocks/mock-notification-user-storage.d.mts.map +1 -0
- package/dist/NotificationServicesController/mocks/mock-notification-user-storage.mjs +76 -0
- package/dist/NotificationServicesController/mocks/mock-notification-user-storage.mjs.map +1 -0
- package/dist/NotificationServicesController/mocks/mockResponses.cjs +9 -9
- package/dist/NotificationServicesController/mocks/mockResponses.cjs.map +1 -1
- package/dist/NotificationServicesController/mocks/mockResponses.d.cts +4 -7
- package/dist/NotificationServicesController/mocks/mockResponses.d.cts.map +1 -1
- package/dist/NotificationServicesController/mocks/mockResponses.d.mts +4 -7
- package/dist/NotificationServicesController/mocks/mockResponses.d.mts.map +1 -1
- package/dist/NotificationServicesController/mocks/mockResponses.mjs +7 -7
- package/dist/NotificationServicesController/mocks/mockResponses.mjs.map +1 -1
- package/dist/NotificationServicesController/processors/process-notifications.cjs +1 -4
- package/dist/NotificationServicesController/processors/process-notifications.cjs.map +1 -1
- package/dist/NotificationServicesController/processors/process-notifications.d.cts +0 -623
- package/dist/NotificationServicesController/processors/process-notifications.d.cts.map +1 -1
- package/dist/NotificationServicesController/processors/process-notifications.d.mts +0 -623
- package/dist/NotificationServicesController/processors/process-notifications.d.mts.map +1 -1
- package/dist/NotificationServicesController/processors/process-notifications.mjs +0 -2
- package/dist/NotificationServicesController/processors/process-notifications.mjs.map +1 -1
- package/dist/NotificationServicesController/services/onchain-notifications.cjs +140 -67
- package/dist/NotificationServicesController/services/onchain-notifications.cjs.map +1 -1
- package/dist/NotificationServicesController/services/onchain-notifications.d.cts +31 -25
- package/dist/NotificationServicesController/services/onchain-notifications.d.cts.map +1 -1
- package/dist/NotificationServicesController/services/onchain-notifications.d.mts +31 -25
- package/dist/NotificationServicesController/services/onchain-notifications.d.mts.map +1 -1
- package/dist/NotificationServicesController/services/onchain-notifications.mjs +137 -65
- package/dist/NotificationServicesController/services/onchain-notifications.mjs.map +1 -1
- package/dist/NotificationServicesController/types/index.cjs.map +1 -1
- package/dist/NotificationServicesController/types/index.d.cts +1 -0
- package/dist/NotificationServicesController/types/index.d.cts.map +1 -1
- package/dist/NotificationServicesController/types/index.d.mts +1 -0
- package/dist/NotificationServicesController/types/index.d.mts.map +1 -1
- package/dist/NotificationServicesController/types/index.mjs.map +1 -1
- package/dist/NotificationServicesController/types/user-storage/index.cjs +3 -0
- package/dist/NotificationServicesController/types/user-storage/index.cjs.map +1 -0
- package/dist/NotificationServicesController/types/user-storage/index.d.cts +2 -0
- package/dist/NotificationServicesController/types/user-storage/index.d.cts.map +1 -0
- package/dist/NotificationServicesController/types/user-storage/index.d.mts +2 -0
- package/dist/NotificationServicesController/types/user-storage/index.d.mts.map +1 -0
- package/dist/NotificationServicesController/types/user-storage/index.mjs +2 -0
- package/dist/NotificationServicesController/types/user-storage/index.mjs.map +1 -0
- package/dist/NotificationServicesController/types/user-storage/user-storage.cjs +3 -0
- package/dist/NotificationServicesController/types/user-storage/user-storage.cjs.map +1 -0
- package/dist/NotificationServicesController/types/user-storage/user-storage.d.cts +26 -0
- package/dist/NotificationServicesController/types/user-storage/user-storage.d.cts.map +1 -0
- package/dist/NotificationServicesController/types/user-storage/user-storage.d.mts +26 -0
- package/dist/NotificationServicesController/types/user-storage/user-storage.d.mts.map +1 -0
- package/dist/NotificationServicesController/types/user-storage/user-storage.mjs +2 -0
- package/dist/NotificationServicesController/types/user-storage/user-storage.mjs.map +1 -0
- package/dist/NotificationServicesController/utils/utils.cjs +350 -1
- package/dist/NotificationServicesController/utils/utils.cjs.map +1 -1
- package/dist/NotificationServicesController/utils/utils.d.cts +141 -0
- package/dist/NotificationServicesController/utils/utils.d.cts.map +1 -1
- package/dist/NotificationServicesController/utils/utils.d.mts +141 -0
- package/dist/NotificationServicesController/utils/utils.d.mts.map +1 -1
- package/dist/NotificationServicesController/utils/utils.mjs +337 -0
- package/dist/NotificationServicesController/utils/utils.mjs.map +1 -1
- package/dist/NotificationServicesPushController/NotificationServicesPushController.cjs +15 -22
- package/dist/NotificationServicesPushController/NotificationServicesPushController.cjs.map +1 -1
- package/dist/NotificationServicesPushController/NotificationServicesPushController.d.cts +5 -6
- package/dist/NotificationServicesPushController/NotificationServicesPushController.d.cts.map +1 -1
- package/dist/NotificationServicesPushController/NotificationServicesPushController.d.mts +5 -6
- package/dist/NotificationServicesPushController/NotificationServicesPushController.d.mts.map +1 -1
- package/dist/NotificationServicesPushController/NotificationServicesPushController.mjs +16 -23
- package/dist/NotificationServicesPushController/NotificationServicesPushController.mjs.map +1 -1
- package/dist/NotificationServicesPushController/mocks/mockResponse.cjs +16 -1
- package/dist/NotificationServicesPushController/mocks/mockResponse.cjs.map +1 -1
- package/dist/NotificationServicesPushController/mocks/mockResponse.d.cts +7 -0
- package/dist/NotificationServicesPushController/mocks/mockResponse.d.cts.map +1 -1
- package/dist/NotificationServicesPushController/mocks/mockResponse.d.mts +7 -0
- package/dist/NotificationServicesPushController/mocks/mockResponse.d.mts.map +1 -1
- package/dist/NotificationServicesPushController/mocks/mockResponse.mjs +14 -0
- package/dist/NotificationServicesPushController/mocks/mockResponse.mjs.map +1 -1
- package/dist/NotificationServicesPushController/services/endpoints.cjs +1 -1
- package/dist/NotificationServicesPushController/services/endpoints.cjs.map +1 -1
- package/dist/NotificationServicesPushController/services/endpoints.d.cts +1 -1
- package/dist/NotificationServicesPushController/services/endpoints.d.cts.map +1 -1
- package/dist/NotificationServicesPushController/services/endpoints.d.mts +1 -1
- package/dist/NotificationServicesPushController/services/endpoints.d.mts.map +1 -1
- package/dist/NotificationServicesPushController/services/endpoints.mjs +1 -1
- package/dist/NotificationServicesPushController/services/endpoints.mjs.map +1 -1
- package/dist/NotificationServicesPushController/services/services.cjs +41 -18
- package/dist/NotificationServicesPushController/services/services.cjs.map +1 -1
- package/dist/NotificationServicesPushController/services/services.d.cts +33 -19
- package/dist/NotificationServicesPushController/services/services.d.cts.map +1 -1
- package/dist/NotificationServicesPushController/services/services.d.mts +33 -19
- package/dist/NotificationServicesPushController/services/services.d.mts.map +1 -1
- package/dist/NotificationServicesPushController/services/services.mjs +39 -17
- package/dist/NotificationServicesPushController/services/services.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/NotificationServicesController/services/notification-config-cache.cjs +0 -72
- package/dist/NotificationServicesController/services/notification-config-cache.cjs.map +0 -1
- package/dist/NotificationServicesController/services/notification-config-cache.d.cts +0 -19
- package/dist/NotificationServicesController/services/notification-config-cache.d.cts.map +0 -1
- package/dist/NotificationServicesController/services/notification-config-cache.d.mts +0 -19
- package/dist/NotificationServicesController/services/notification-config-cache.d.mts.map +0 -1
- package/dist/NotificationServicesController/services/notification-config-cache.mjs +0 -68
- package/dist/NotificationServicesController/services/notification-config-cache.mjs.map +0 -1
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
2
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
3
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
4
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5
|
-
};
|
|
6
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
7
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
8
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
9
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
10
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
11
|
-
};
|
|
12
|
-
var _OnChainNotificationsCache_instances, _OnChainNotificationsCache_cache, _OnChainNotificationsCache_TTL, _OnChainNotificationsCache_isExpired, _OnChainNotificationsCache_hasAllAddresses;
|
|
13
|
-
export const NotificationConfigCacheTTL = 1000 * 60; // 60 seconds
|
|
14
|
-
export class OnChainNotificationsCache {
|
|
15
|
-
constructor() {
|
|
16
|
-
_OnChainNotificationsCache_instances.add(this);
|
|
17
|
-
_OnChainNotificationsCache_cache.set(this, null);
|
|
18
|
-
_OnChainNotificationsCache_TTL.set(this, NotificationConfigCacheTTL);
|
|
19
|
-
}
|
|
20
|
-
get(addresses) {
|
|
21
|
-
if (__classPrivateFieldGet(this, _OnChainNotificationsCache_instances, "m", _OnChainNotificationsCache_isExpired).call(this) || !__classPrivateFieldGet(this, _OnChainNotificationsCache_instances, "m", _OnChainNotificationsCache_hasAllAddresses).call(this, addresses)) {
|
|
22
|
-
return null;
|
|
23
|
-
}
|
|
24
|
-
return addresses.map((address) => ({
|
|
25
|
-
address,
|
|
26
|
-
enabled: __classPrivateFieldGet(this, _OnChainNotificationsCache_cache, "f")?.data.get(address) ?? false,
|
|
27
|
-
}));
|
|
28
|
-
}
|
|
29
|
-
set(data) {
|
|
30
|
-
let map = new Map();
|
|
31
|
-
// If we have existing cache, preserve it and update with new data
|
|
32
|
-
if (__classPrivateFieldGet(this, _OnChainNotificationsCache_cache, "f") && !__classPrivateFieldGet(this, _OnChainNotificationsCache_instances, "m", _OnChainNotificationsCache_isExpired).call(this)) {
|
|
33
|
-
map = new Map(__classPrivateFieldGet(this, _OnChainNotificationsCache_cache, "f").data);
|
|
34
|
-
}
|
|
35
|
-
// Update with new data
|
|
36
|
-
data.forEach(({ address, enabled }) => {
|
|
37
|
-
map.set(address, enabled);
|
|
38
|
-
});
|
|
39
|
-
__classPrivateFieldSet(this, _OnChainNotificationsCache_cache, {
|
|
40
|
-
data: map,
|
|
41
|
-
timestamp: Date.now(),
|
|
42
|
-
}, "f");
|
|
43
|
-
}
|
|
44
|
-
// Full replace when updateOnChainNotifications is called
|
|
45
|
-
replace(data) {
|
|
46
|
-
const map = new Map();
|
|
47
|
-
data.forEach(({ address, enabled }) => {
|
|
48
|
-
map.set(address, enabled);
|
|
49
|
-
});
|
|
50
|
-
__classPrivateFieldSet(this, _OnChainNotificationsCache_cache, {
|
|
51
|
-
data: map,
|
|
52
|
-
timestamp: Date.now(),
|
|
53
|
-
}, "f");
|
|
54
|
-
}
|
|
55
|
-
clear() {
|
|
56
|
-
__classPrivateFieldSet(this, _OnChainNotificationsCache_cache, null, "f");
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
_OnChainNotificationsCache_cache = new WeakMap(), _OnChainNotificationsCache_TTL = new WeakMap(), _OnChainNotificationsCache_instances = new WeakSet(), _OnChainNotificationsCache_isExpired = function _OnChainNotificationsCache_isExpired() {
|
|
60
|
-
return !__classPrivateFieldGet(this, _OnChainNotificationsCache_cache, "f") || Date.now() - __classPrivateFieldGet(this, _OnChainNotificationsCache_cache, "f").timestamp > __classPrivateFieldGet(this, _OnChainNotificationsCache_TTL, "f");
|
|
61
|
-
}, _OnChainNotificationsCache_hasAllAddresses = function _OnChainNotificationsCache_hasAllAddresses(addresses) {
|
|
62
|
-
if (!__classPrivateFieldGet(this, _OnChainNotificationsCache_cache, "f")) {
|
|
63
|
-
return false;
|
|
64
|
-
}
|
|
65
|
-
return addresses.every((address) => __classPrivateFieldGet(this, _OnChainNotificationsCache_cache, "f")?.data.has(address));
|
|
66
|
-
};
|
|
67
|
-
export const notificationsConfigCache = new OnChainNotificationsCache();
|
|
68
|
-
//# sourceMappingURL=notification-config-cache.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"notification-config-cache.mjs","sourceRoot":"","sources":["../../../src/NotificationServicesController/services/notification-config-cache.ts"],"names":[],"mappings":";;;;;;;;;;;;AAKA,MAAM,CAAC,MAAM,0BAA0B,GAAG,IAAI,GAAG,EAAE,CAAC,CAAC,aAAa;AAElE,MAAM,OAAO,yBAAyB;IAAtC;;QACE,2CAAyC,IAAI,EAAC;QAErC,yCAAO,0BAA0B,EAAC;IA2D7C,CAAC;IA9CC,GAAG,CAAC,SAAmB;QACrB,IAAI,uBAAA,IAAI,kFAAW,MAAf,IAAI,CAAa,IAAI,CAAC,uBAAA,IAAI,wFAAiB,MAArB,IAAI,EAAkB,SAAS,CAAC,EAAE;YAC1D,OAAO,IAAI,CAAC;SACb;QAED,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;YACjC,OAAO;YACP,OAAO,EAAE,uBAAA,IAAI,wCAAO,EAAE,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,KAAK;SACjD,CAAC,CAAC,CAAC;IACN,CAAC;IAED,GAAG,CAAC,IAA6C;QAC/C,IAAI,GAAG,GAAyB,IAAI,GAAG,EAAmB,CAAC;QAE3D,kEAAkE;QAClE,IAAI,uBAAA,IAAI,wCAAO,IAAI,CAAC,uBAAA,IAAI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CAAC,CAAC;AACtE,CAAC;AAkDH,MAAM,CAAC,MAAM,wBAAwB,GAAG,IAAI,yBAAyB,EAAE,CAAC","sourcesContent":["type NotificationConfigCache = {\n data: Map<string, boolean>;\n timestamp: number;\n};\n\nexport const NotificationConfigCacheTTL = 1000 * 60; // 60 seconds\n\nexport class OnChainNotificationsCache {\n #cache: NotificationConfigCache | null = null;\n\n readonly #TTL = NotificationConfigCacheTTL;\n\n #isExpired(): boolean {\n return !this.#cache || Date.now() - this.#cache.timestamp > this.#TTL;\n }\n\n #hasAllAddresses(addresses: string[]): boolean {\n if (!this.#cache) {\n return false;\n }\n return addresses.every((address) => this.#cache?.data.has(address));\n }\n\n get(addresses: string[]): { address: string; enabled: boolean }[] | null {\n if (this.#isExpired() || !this.#hasAllAddresses(addresses)) {\n return null;\n }\n\n return addresses.map((address) => ({\n address,\n enabled: this.#cache?.data.get(address) ?? false,\n }));\n }\n\n set(data: { address: string; enabled: boolean }[]): void {\n let map: Map<string, boolean> = new Map<string, boolean>();\n\n // If we have existing cache, preserve it and update with new data\n if (this.#cache && !this.#isExpired()) {\n map = new Map(this.#cache.data);\n }\n\n // Update with new data\n data.forEach(({ address, enabled }) => {\n map.set(address, enabled);\n });\n\n this.#cache = {\n data: map,\n timestamp: Date.now(),\n };\n }\n\n // Full replace when updateOnChainNotifications is called\n replace(data: { address: string; enabled: boolean }[]): void {\n const map = new Map<string, boolean>();\n data.forEach(({ address, enabled }) => {\n map.set(address, enabled);\n });\n\n this.#cache = {\n data: map,\n timestamp: Date.now(),\n };\n }\n\n clear(): void {\n this.#cache = null;\n }\n}\n\nexport const notificationsConfigCache = new OnChainNotificationsCache();\n"]}
|