@metamask-previews/messenger 0.0.0-preview-3713f9f

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.
@@ -0,0 +1,238 @@
1
+ "use strict";
2
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3
+ if (kind === "m") throw new TypeError("Private method is not writable");
4
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5
+ 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");
6
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
7
+ };
8
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10
+ 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");
11
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
+ };
13
+ var _RestrictedMessenger_instances, _RestrictedMessenger_messenger, _RestrictedMessenger_namespace, _RestrictedMessenger_allowedActions, _RestrictedMessenger_allowedEvents, _RestrictedMessenger_isAllowedEvent, _RestrictedMessenger_isAllowedAction, _RestrictedMessenger_isInCurrentNamespace;
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.RestrictedMessenger = void 0;
16
+ /**
17
+ * A restricted messenger.
18
+ *
19
+ * This acts as a wrapper around the messenger instance that restricts access to actions
20
+ * and events.
21
+ *
22
+ * @template Namespace - The namespace for this messenger. Typically this is the name of the controller or
23
+ * module that this messenger has been created for. The authority to publish events and register
24
+ * actions under this namespace is granted to this restricted messenger instance.
25
+ * @template Action - A type union of all Action types.
26
+ * @template Event - A type union of all Event types.
27
+ * @template AllowedAction - A type union of the 'type' string for any allowed actions.
28
+ * This must not include internal actions that are in the messenger's namespace.
29
+ * @template AllowedEvent - A type union of the 'type' string for any allowed events.
30
+ * This must not include internal events that are in the messenger's namespace.
31
+ */
32
+ class RestrictedMessenger {
33
+ /**
34
+ * Constructs a restricted messenger
35
+ *
36
+ * The provided allowlists grant the ability to call the listed actions and subscribe to the
37
+ * listed events. The "name" provided grants ownership of any actions and events under that
38
+ * namespace. Ownership allows registering actions and publishing events, as well as
39
+ * unregistering actions and clearing event subscriptions.
40
+ *
41
+ * @param options - Options.
42
+ * @param options.messenger - The messenger instance that is being wrapped.
43
+ * @param options.name - The name of the thing this messenger will be handed to (e.g. the
44
+ * controller name). This grants "ownership" of actions and events under this namespace to the
45
+ * restricted messenger returned.
46
+ * @param options.allowedActions - The list of actions that this restricted messenger should be
47
+ * allowed to call.
48
+ * @param options.allowedEvents - The list of events that this restricted messenger should be
49
+ * allowed to subscribe to.
50
+ */
51
+ constructor({ messenger, name, allowedActions, allowedEvents, }) {
52
+ _RestrictedMessenger_instances.add(this);
53
+ _RestrictedMessenger_messenger.set(this, void 0);
54
+ _RestrictedMessenger_namespace.set(this, void 0);
55
+ _RestrictedMessenger_allowedActions.set(this, void 0);
56
+ _RestrictedMessenger_allowedEvents.set(this, void 0);
57
+ if (!messenger) {
58
+ throw new Error('Messenger not provided');
59
+ }
60
+ // The above condition guarantees that one of these options is defined.
61
+ __classPrivateFieldSet(this, _RestrictedMessenger_messenger, messenger, "f");
62
+ __classPrivateFieldSet(this, _RestrictedMessenger_namespace, name, "f");
63
+ __classPrivateFieldSet(this, _RestrictedMessenger_allowedActions, allowedActions, "f");
64
+ __classPrivateFieldSet(this, _RestrictedMessenger_allowedEvents, allowedEvents, "f");
65
+ }
66
+ /**
67
+ * Register an action handler.
68
+ *
69
+ * This will make the registered function available to call via the `call` method.
70
+ *
71
+ * The action type this handler is registered under *must* be in the current namespace.
72
+ *
73
+ * @param action - The action type. This is a unique identifier for this action.
74
+ * @param handler - The action handler. This function gets called when the `call` method is
75
+ * invoked with the given action type.
76
+ * @throws Will throw if an action handler that is not in the current namespace is being registered.
77
+ * @template ActionType - A type union of Action type strings that are namespaced by Namespace.
78
+ */
79
+ registerActionHandler(action, handler) {
80
+ /* istanbul ignore if */ // Branch unreachable with valid types
81
+ if (!__classPrivateFieldGet(this, _RestrictedMessenger_instances, "m", _RestrictedMessenger_isInCurrentNamespace).call(this, action)) {
82
+ throw new Error(`Only allowed registering action handlers prefixed by '${__classPrivateFieldGet(this, _RestrictedMessenger_namespace, "f")}:'`);
83
+ }
84
+ __classPrivateFieldGet(this, _RestrictedMessenger_messenger, "f").registerActionHandler(action, handler);
85
+ }
86
+ /**
87
+ * Registers action handlers for a list of methods on a messenger client
88
+ *
89
+ * @param messengerClient - The object that is expected to make use of the messenger.
90
+ * @param methodNames - The names of the methods on the messenger client to register as action
91
+ * handlers
92
+ */
93
+ registerMethodActionHandlers(messengerClient, methodNames) {
94
+ __classPrivateFieldGet(this, _RestrictedMessenger_messenger, "f").registerMethodActionHandlers(messengerClient, methodNames);
95
+ }
96
+ /**
97
+ * Unregister an action handler.
98
+ *
99
+ * This will prevent this action from being called.
100
+ *
101
+ * The action type being unregistered *must* be in the current namespace.
102
+ *
103
+ * @param action - The action type. This is a unique identifier for this action.
104
+ * @throws Will throw if an action handler that is not in the current namespace is being unregistered.
105
+ * @template ActionType - A type union of Action type strings that are namespaced by Namespace.
106
+ */
107
+ unregisterActionHandler(action) {
108
+ /* istanbul ignore if */ // Branch unreachable with valid types
109
+ if (!__classPrivateFieldGet(this, _RestrictedMessenger_instances, "m", _RestrictedMessenger_isInCurrentNamespace).call(this, action)) {
110
+ throw new Error(`Only allowed unregistering action handlers prefixed by '${__classPrivateFieldGet(this, _RestrictedMessenger_namespace, "f")}:'`);
111
+ }
112
+ __classPrivateFieldGet(this, _RestrictedMessenger_messenger, "f").unregisterActionHandler(action);
113
+ }
114
+ /**
115
+ * Call an action.
116
+ *
117
+ * This function will call the action handler corresponding to the given action type, passing
118
+ * along any parameters given.
119
+ *
120
+ * The action type being called must be on the action allowlist.
121
+ *
122
+ * @param actionType - The action type. This is a unique identifier for this action.
123
+ * @param params - The action parameters. These must match the type of the parameters of the
124
+ * registered action handler.
125
+ * @throws Will throw when no handler has been registered for the given type.
126
+ * @template ActionType - A type union of allowed Action type strings.
127
+ * @returns The action return value.
128
+ */
129
+ call(actionType, ...params) {
130
+ if (!__classPrivateFieldGet(this, _RestrictedMessenger_instances, "m", _RestrictedMessenger_isAllowedAction).call(this, actionType)) {
131
+ throw new Error(`Action missing from allow list: ${actionType}`);
132
+ }
133
+ const response = __classPrivateFieldGet(this, _RestrictedMessenger_messenger, "f").call(actionType, ...params);
134
+ return response;
135
+ }
136
+ /**
137
+ * Register a function for getting the initial payload for an event.
138
+ *
139
+ * This is used for events that represent a state change, where the payload is the state.
140
+ * Registering a function for getting the payload allows event selectors to have a point of
141
+ * comparison the first time state changes.
142
+ *
143
+ * The event type *must* be in the current namespace
144
+ *
145
+ * @param args - The arguments to this function
146
+ * @param args.eventType - The event type to register a payload for.
147
+ * @param args.getPayload - A function for retrieving the event payload.
148
+ */
149
+ registerInitialEventPayload({ eventType, getPayload, }) {
150
+ /* istanbul ignore if */ // Branch unreachable with valid types
151
+ if (!__classPrivateFieldGet(this, _RestrictedMessenger_instances, "m", _RestrictedMessenger_isInCurrentNamespace).call(this, eventType)) {
152
+ throw new Error(`Only allowed publishing events prefixed by '${__classPrivateFieldGet(this, _RestrictedMessenger_namespace, "f")}:'`);
153
+ }
154
+ __classPrivateFieldGet(this, _RestrictedMessenger_messenger, "f").registerInitialEventPayload({
155
+ eventType,
156
+ getPayload,
157
+ });
158
+ }
159
+ /**
160
+ * Publish an event.
161
+ *
162
+ * Publishes the given payload to all subscribers of the given event type.
163
+ *
164
+ * The event type being published *must* be in the current namespace.
165
+ *
166
+ * @param event - The event type. This is a unique identifier for this event.
167
+ * @param payload - The event payload. The type of the parameters for each event handler must
168
+ * match the type of this payload.
169
+ * @throws Will throw if an event that is not in the current namespace is being published.
170
+ * @template EventType - A type union of Event type strings that are namespaced by Namespace.
171
+ */
172
+ publish(event, ...payload) {
173
+ /* istanbul ignore if */ // Branch unreachable with valid types
174
+ if (!__classPrivateFieldGet(this, _RestrictedMessenger_instances, "m", _RestrictedMessenger_isInCurrentNamespace).call(this, event)) {
175
+ throw new Error(`Only allowed publishing events prefixed by '${__classPrivateFieldGet(this, _RestrictedMessenger_namespace, "f")}:'`);
176
+ }
177
+ __classPrivateFieldGet(this, _RestrictedMessenger_messenger, "f").publish(event, ...payload);
178
+ }
179
+ subscribe(event, handler, selector) {
180
+ if (!__classPrivateFieldGet(this, _RestrictedMessenger_instances, "m", _RestrictedMessenger_isAllowedEvent).call(this, event)) {
181
+ throw new Error(`Event missing from allow list: ${event}`);
182
+ }
183
+ if (selector) {
184
+ return __classPrivateFieldGet(this, _RestrictedMessenger_messenger, "f").subscribe(event, handler, selector);
185
+ }
186
+ return __classPrivateFieldGet(this, _RestrictedMessenger_messenger, "f").subscribe(event, handler);
187
+ }
188
+ /**
189
+ * Unsubscribe from an event.
190
+ *
191
+ * Unregisters the given function as an event handler for the given event.
192
+ *
193
+ * The event type being unsubscribed to must be on the event allowlist.
194
+ *
195
+ * @param event - The event type. This is a unique identifier for this event.
196
+ * @param handler - The event handler to unregister.
197
+ * @throws Will throw if the given event is not an allowed event for this messenger.
198
+ * @template EventType - A type union of allowed Event type strings.
199
+ */
200
+ unsubscribe(event, handler) {
201
+ if (!__classPrivateFieldGet(this, _RestrictedMessenger_instances, "m", _RestrictedMessenger_isAllowedEvent).call(this, event)) {
202
+ throw new Error(`Event missing from allow list: ${event}`);
203
+ }
204
+ __classPrivateFieldGet(this, _RestrictedMessenger_messenger, "f").unsubscribe(event, handler);
205
+ }
206
+ /**
207
+ * Clear subscriptions for a specific event.
208
+ *
209
+ * This will remove all subscribed handlers for this event.
210
+ *
211
+ * The event type being cleared *must* be in the current namespace.
212
+ *
213
+ * @param event - The event type. This is a unique identifier for this event.
214
+ * @throws Will throw if a subscription for an event that is not in the current namespace is being cleared.
215
+ * @template EventType - A type union of Event type strings that are namespaced by Namespace.
216
+ */
217
+ clearEventSubscriptions(event) {
218
+ if (!__classPrivateFieldGet(this, _RestrictedMessenger_instances, "m", _RestrictedMessenger_isInCurrentNamespace).call(this, event)) {
219
+ throw new Error(`Only allowed clearing events prefixed by '${__classPrivateFieldGet(this, _RestrictedMessenger_namespace, "f")}:'`);
220
+ }
221
+ __classPrivateFieldGet(this, _RestrictedMessenger_messenger, "f").clearEventSubscriptions(event);
222
+ }
223
+ }
224
+ exports.RestrictedMessenger = RestrictedMessenger;
225
+ _RestrictedMessenger_messenger = new WeakMap(), _RestrictedMessenger_namespace = new WeakMap(), _RestrictedMessenger_allowedActions = new WeakMap(), _RestrictedMessenger_allowedEvents = new WeakMap(), _RestrictedMessenger_instances = new WeakSet(), _RestrictedMessenger_isAllowedEvent = function _RestrictedMessenger_isAllowedEvent(eventType) {
226
+ // Safely upcast to allow runtime check
227
+ const allowedEvents = __classPrivateFieldGet(this, _RestrictedMessenger_allowedEvents, "f");
228
+ return (__classPrivateFieldGet(this, _RestrictedMessenger_instances, "m", _RestrictedMessenger_isInCurrentNamespace).call(this, eventType) ||
229
+ (allowedEvents !== null && allowedEvents.includes(eventType)));
230
+ }, _RestrictedMessenger_isAllowedAction = function _RestrictedMessenger_isAllowedAction(actionType) {
231
+ // Safely upcast to allow runtime check
232
+ const allowedActions = __classPrivateFieldGet(this, _RestrictedMessenger_allowedActions, "f");
233
+ return (__classPrivateFieldGet(this, _RestrictedMessenger_instances, "m", _RestrictedMessenger_isInCurrentNamespace).call(this, actionType) ||
234
+ (allowedActions !== null && allowedActions.includes(actionType)));
235
+ }, _RestrictedMessenger_isInCurrentNamespace = function _RestrictedMessenger_isInCurrentNamespace(name) {
236
+ return name.startsWith(`${__classPrivateFieldGet(this, _RestrictedMessenger_namespace, "f")}:`);
237
+ };
238
+ //# sourceMappingURL=RestrictedMessenger.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RestrictedMessenger.cjs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,CAAC,uFAWC,UAA0B;IAI1B,uCAAuC;IACvC,MAAM,cAAc,GAAoB,uBAAA,IAAI,2CAAgB,CAAC;IAC7D,OAAO,CACL,uBAAA,IAAI,iFAAsB,MAA1B,IAAI,EAAuB,UAAU,CAAC;QACtC,CAAC,cAAc,KAAK,IAAI,IAAI,cAAc,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CACjE,CAAC;AACJ,CAAC,iGAQqB,IAAY;IAChC,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,uBAAA,IAAI,sCAAW,GAAG,CAAC,CAAC;AAChD,CAAC","sourcesContent":["import type {\n ActionConstraint,\n ActionHandler,\n Messenger,\n EventConstraint,\n ExtractActionParameters,\n ExtractActionResponse,\n ExtractEventHandler,\n ExtractEventPayload,\n NamespacedName,\n NotNamespacedBy,\n SelectorEventHandler,\n SelectorFunction,\n} from './Messenger';\n\n/**\n * A universal supertype of all `RestrictedMessenger` instances. This type can be assigned to any\n * `RestrictedMessenger` type.\n *\n * @template Namespace - Name of the module this messenger is for. Optionally can be used to\n * narrow this type to a constraint for the messenger of a specific module.\n */\nexport type RestrictedMessengerConstraint<Namespace extends string = string> =\n RestrictedMessenger<\n Namespace,\n ActionConstraint,\n EventConstraint,\n string,\n string\n >;\n\n/**\n * A restricted messenger.\n *\n * This acts as a wrapper around the messenger instance that restricts access to actions\n * and events.\n *\n * @template Namespace - The namespace for this messenger. Typically this is the name of the controller or\n * module that this messenger has been created for. The authority to publish events and register\n * actions under this namespace is granted to this restricted messenger instance.\n * @template Action - A type union of all Action types.\n * @template Event - A type union of all Event types.\n * @template AllowedAction - A type union of the 'type' string for any allowed actions.\n * This must not include internal actions that are in the messenger's namespace.\n * @template AllowedEvent - A type union of the 'type' string for any allowed events.\n * This must not include internal events that are in the messenger's namespace.\n */\nexport class RestrictedMessenger<\n Namespace extends string,\n Action extends ActionConstraint,\n Event extends EventConstraint,\n AllowedAction extends string,\n AllowedEvent extends string,\n> {\n readonly #messenger: Messenger<ActionConstraint, EventConstraint>;\n\n readonly #namespace: Namespace;\n\n readonly #allowedActions: NotNamespacedBy<Namespace, AllowedAction>[];\n\n readonly #allowedEvents: NotNamespacedBy<Namespace, AllowedEvent>[];\n\n /**\n * Constructs a restricted messenger\n *\n * The provided allowlists grant the ability to call the listed actions and subscribe to the\n * listed events. The \"name\" provided grants ownership of any actions and events under that\n * namespace. Ownership allows registering actions and publishing events, as well as\n * unregistering actions and clearing event subscriptions.\n *\n * @param options - Options.\n * @param options.messenger - The messenger instance that is being wrapped.\n * @param options.name - The name of the thing this messenger will be handed to (e.g. the\n * controller name). This grants \"ownership\" of actions and events under this namespace to the\n * restricted messenger returned.\n * @param options.allowedActions - The list of actions that this restricted messenger should be\n * allowed to call.\n * @param options.allowedEvents - The list of events that this restricted messenger should be\n * allowed to subscribe to.\n */\n constructor({\n messenger,\n name,\n allowedActions,\n allowedEvents,\n }: {\n messenger?: Messenger<ActionConstraint, EventConstraint>;\n name: Namespace;\n allowedActions: NotNamespacedBy<Namespace, AllowedAction>[];\n allowedEvents: NotNamespacedBy<Namespace, AllowedEvent>[];\n }) {\n if (!messenger) {\n throw new Error('Messenger not provided');\n }\n // The above condition guarantees that one of these options is defined.\n this.#messenger = messenger;\n this.#namespace = name;\n this.#allowedActions = allowedActions;\n this.#allowedEvents = allowedEvents;\n }\n\n /**\n * Register an action handler.\n *\n * This will make the registered function available to call via the `call` method.\n *\n * The action type this handler is registered under *must* be in the current namespace.\n *\n * @param action - The action type. This is a unique identifier for this action.\n * @param handler - The action handler. This function gets called when the `call` method is\n * invoked with the given action type.\n * @throws Will throw if an action handler that is not in the current namespace is being registered.\n * @template ActionType - A type union of Action type strings that are namespaced by Namespace.\n */\n registerActionHandler<\n ActionType extends Action['type'] & NamespacedName<Namespace>,\n >(action: ActionType, handler: ActionHandler<Action, ActionType>) {\n /* istanbul ignore if */ // Branch unreachable with valid types\n if (!this.#isInCurrentNamespace(action)) {\n throw new Error(\n `Only allowed registering action handlers prefixed by '${\n this.#namespace\n }:'`,\n );\n }\n this.#messenger.registerActionHandler(action, handler);\n }\n\n /**\n * Registers action handlers for a list of methods on a messenger client\n *\n * @param messengerClient - The object that is expected to make use of the messenger.\n * @param methodNames - The names of the methods on the messenger client to register as action\n * handlers\n */\n registerMethodActionHandlers<\n MessengerClient extends { name: string },\n MethodNames extends keyof MessengerClient & string,\n >(messengerClient: MessengerClient, methodNames: readonly MethodNames[]) {\n this.#messenger.registerMethodActionHandlers(messengerClient, methodNames);\n }\n\n /**\n * Unregister an action handler.\n *\n * This will prevent this action from being called.\n *\n * The action type being unregistered *must* be in the current namespace.\n *\n * @param action - The action type. This is a unique identifier for this action.\n * @throws Will throw if an action handler that is not in the current namespace is being unregistered.\n * @template ActionType - A type union of Action type strings that are namespaced by Namespace.\n */\n unregisterActionHandler<\n ActionType extends Action['type'] & NamespacedName<Namespace>,\n >(action: ActionType) {\n /* istanbul ignore if */ // Branch unreachable with valid types\n if (!this.#isInCurrentNamespace(action)) {\n throw new Error(\n `Only allowed unregistering action handlers prefixed by '${\n this.#namespace\n }:'`,\n );\n }\n this.#messenger.unregisterActionHandler(action);\n }\n\n /**\n * Call an action.\n *\n * This function will call the action handler corresponding to the given action type, passing\n * along any parameters given.\n *\n * The action type being called must be on the action allowlist.\n *\n * @param actionType - The action type. This is a unique identifier for this action.\n * @param params - The action parameters. These must match the type of the parameters of the\n * registered action handler.\n * @throws Will throw when no handler has been registered for the given type.\n * @template ActionType - A type union of allowed Action type strings.\n * @returns The action return value.\n */\n call<\n ActionType extends\n | AllowedAction\n | (Action['type'] & NamespacedName<Namespace>),\n >(\n actionType: ActionType,\n ...params: ExtractActionParameters<Action, ActionType>\n ): ExtractActionResponse<Action, ActionType> {\n if (!this.#isAllowedAction(actionType)) {\n throw new Error(`Action missing from allow list: ${actionType}`);\n }\n const response = this.#messenger.call<ActionType>(actionType, ...params);\n\n return response;\n }\n\n /**\n * Register a function for getting the initial payload for an event.\n *\n * This is used for events that represent a state change, where the payload is the state.\n * Registering a function for getting the payload allows event selectors to have a point of\n * comparison the first time state changes.\n *\n * The event type *must* be in the current namespace\n *\n * @param args - The arguments to this function\n * @param args.eventType - The event type to register a payload for.\n * @param args.getPayload - A function for retrieving the event payload.\n */\n registerInitialEventPayload<\n EventType extends Event['type'] & NamespacedName<Namespace>,\n >({\n eventType,\n getPayload,\n }: {\n eventType: EventType;\n getPayload: () => ExtractEventPayload<Event, EventType>;\n }) {\n /* istanbul ignore if */ // Branch unreachable with valid types\n if (!this.#isInCurrentNamespace(eventType)) {\n throw new Error(\n `Only allowed publishing events prefixed by '${this.#namespace}:'`,\n );\n }\n this.#messenger.registerInitialEventPayload({\n eventType,\n getPayload,\n });\n }\n\n /**\n * Publish an event.\n *\n * Publishes the given payload to all subscribers of the given event type.\n *\n * The event type being published *must* be in the current namespace.\n *\n * @param event - The event type. This is a unique identifier for this event.\n * @param payload - The event payload. The type of the parameters for each event handler must\n * match the type of this payload.\n * @throws Will throw if an event that is not in the current namespace is being published.\n * @template EventType - A type union of Event type strings that are namespaced by Namespace.\n */\n publish<EventType extends Event['type'] & NamespacedName<Namespace>>(\n event: EventType,\n ...payload: ExtractEventPayload<Event, EventType>\n ) {\n /* istanbul ignore if */ // Branch unreachable with valid types\n if (!this.#isInCurrentNamespace(event)) {\n throw new Error(\n `Only allowed publishing events prefixed by '${this.#namespace}:'`,\n );\n }\n this.#messenger.publish(event, ...payload);\n }\n\n /**\n * Subscribe to an event.\n *\n * Registers the given function as an event handler for the given event type.\n *\n * The event type being subscribed to must be on the event allowlist.\n *\n * @param eventType - The event type. This is a unique identifier for this event.\n * @param handler - The event handler. The type of the parameters for this event handler must\n * match the type of the payload for this event type.\n * @throws Will throw if the given event is not an allowed event for this messenger.\n * @template EventType - A type union of Event type strings.\n */\n subscribe<\n EventType extends\n | AllowedEvent\n | (Event['type'] & NamespacedName<Namespace>),\n >(eventType: EventType, handler: ExtractEventHandler<Event, EventType>): void;\n\n /**\n * Subscribe to an event, with a selector.\n *\n * Registers the given handler function as an event handler for the given\n * event type. When an event is published, its payload is first passed to the\n * selector. The event handler is only called if the selector's return value\n * differs from its last known return value.\n *\n * The event type being subscribed to must be on the event allowlist.\n *\n * @param eventType - The event type. This is a unique identifier for this event.\n * @param handler - The event handler. The type of the parameters for this event\n * handler must match the return type of the selector.\n * @param selector - The selector function used to select relevant data from\n * the event payload. The type of the parameters for this selector must match\n * the type of the payload for this event type.\n * @throws Will throw if the given event is not an allowed event for this messenger.\n * @template EventType - A type union of Event type strings.\n * @template SelectorReturnValue - The selector return value.\n */\n subscribe<\n EventType extends\n | AllowedEvent\n | (Event['type'] & NamespacedName<Namespace>),\n SelectorReturnValue,\n >(\n eventType: EventType,\n handler: SelectorEventHandler<SelectorReturnValue>,\n selector: SelectorFunction<Event, EventType, SelectorReturnValue>,\n ): void;\n\n subscribe<\n EventType extends\n | AllowedEvent\n | (Event['type'] & NamespacedName<Namespace>),\n SelectorReturnValue,\n >(\n event: EventType,\n handler: ExtractEventHandler<Event, EventType>,\n selector?: SelectorFunction<Event, EventType, SelectorReturnValue>,\n ) {\n if (!this.#isAllowedEvent(event)) {\n throw new Error(`Event missing from allow list: ${event}`);\n }\n\n if (selector) {\n return this.#messenger.subscribe(event, handler, selector);\n }\n return this.#messenger.subscribe(event, handler);\n }\n\n /**\n * Unsubscribe from an event.\n *\n * Unregisters the given function as an event handler for the given event.\n *\n * The event type being unsubscribed to must be on the event allowlist.\n *\n * @param event - The event type. This is a unique identifier for this event.\n * @param handler - The event handler to unregister.\n * @throws Will throw if the given event is not an allowed event for this messenger.\n * @template EventType - A type union of allowed Event type strings.\n */\n unsubscribe<\n EventType extends\n | AllowedEvent\n | (Event['type'] & NamespacedName<Namespace>),\n >(event: EventType, handler: ExtractEventHandler<Event, EventType>) {\n if (!this.#isAllowedEvent(event)) {\n throw new Error(`Event missing from allow list: ${event}`);\n }\n this.#messenger.unsubscribe(event, handler);\n }\n\n /**\n * Clear subscriptions for a specific event.\n *\n * This will remove all subscribed handlers for this event.\n *\n * The event type being cleared *must* be in the current namespace.\n *\n * @param event - The event type. This is a unique identifier for this event.\n * @throws Will throw if a subscription for an event that is not in the current namespace is being cleared.\n * @template EventType - A type union of Event type strings that are namespaced by Namespace.\n */\n clearEventSubscriptions<\n EventType extends Event['type'] & NamespacedName<Namespace>,\n >(event: EventType) {\n if (!this.#isInCurrentNamespace(event)) {\n throw new Error(\n `Only allowed clearing events prefixed by '${this.#namespace}:'`,\n );\n }\n this.#messenger.clearEventSubscriptions(event);\n }\n\n /**\n * Determine whether the given event type is allowed. Event types are\n * allowed if they are in the current namespace or on the list of\n * allowed events.\n *\n * @param eventType - The event type to check.\n * @returns Whether the event type is allowed.\n */\n #isAllowedEvent(\n eventType: Event['type'],\n ): eventType is\n | NamespacedName<Namespace>\n | NotNamespacedBy<Namespace, AllowedEvent> {\n // Safely upcast to allow runtime check\n const allowedEvents: string[] | null = this.#allowedEvents;\n return (\n this.#isInCurrentNamespace(eventType) ||\n (allowedEvents !== null && allowedEvents.includes(eventType))\n );\n }\n\n /**\n * Determine whether the given action type is allowed. Action types\n * are allowed if they are in the current namespace or on the list of\n * allowed actions.\n *\n * @param actionType - The action type to check.\n * @returns Whether the action type is allowed.\n */\n #isAllowedAction(\n actionType: Action['type'],\n ): actionType is\n | NamespacedName<Namespace>\n | NotNamespacedBy<Namespace, AllowedAction> {\n // Safely upcast to allow runtime check\n const allowedActions: string[] | null = this.#allowedActions;\n return (\n this.#isInCurrentNamespace(actionType) ||\n (allowedActions !== null && allowedActions.includes(actionType))\n );\n }\n\n /**\n * Determine whether the given name is within the current namespace.\n *\n * @param name - The name to check\n * @returns Whether the name is within the current namespace\n */\n #isInCurrentNamespace(name: string): name is NamespacedName<Namespace> {\n return name.startsWith(`${this.#namespace}:`);\n }\n}\n"]}
@@ -0,0 +1,196 @@
1
+ import type { ActionConstraint, ActionHandler, Messenger, EventConstraint, ExtractActionParameters, ExtractActionResponse, ExtractEventHandler, ExtractEventPayload, NamespacedName, NotNamespacedBy, SelectorEventHandler, SelectorFunction } from "./Messenger.cjs";
2
+ /**
3
+ * A universal supertype of all `RestrictedMessenger` instances. This type can be assigned to any
4
+ * `RestrictedMessenger` type.
5
+ *
6
+ * @template Namespace - Name of the module this messenger is for. Optionally can be used to
7
+ * narrow this type to a constraint for the messenger of a specific module.
8
+ */
9
+ export type RestrictedMessengerConstraint<Namespace extends string = string> = RestrictedMessenger<Namespace, ActionConstraint, EventConstraint, string, string>;
10
+ /**
11
+ * A restricted messenger.
12
+ *
13
+ * This acts as a wrapper around the messenger instance that restricts access to actions
14
+ * and events.
15
+ *
16
+ * @template Namespace - The namespace for this messenger. Typically this is the name of the controller or
17
+ * module that this messenger has been created for. The authority to publish events and register
18
+ * actions under this namespace is granted to this restricted messenger instance.
19
+ * @template Action - A type union of all Action types.
20
+ * @template Event - A type union of all Event types.
21
+ * @template AllowedAction - A type union of the 'type' string for any allowed actions.
22
+ * This must not include internal actions that are in the messenger's namespace.
23
+ * @template AllowedEvent - A type union of the 'type' string for any allowed events.
24
+ * This must not include internal events that are in the messenger's namespace.
25
+ */
26
+ export declare class RestrictedMessenger<Namespace extends string, Action extends ActionConstraint, Event extends EventConstraint, AllowedAction extends string, AllowedEvent extends string> {
27
+ #private;
28
+ /**
29
+ * Constructs a restricted messenger
30
+ *
31
+ * The provided allowlists grant the ability to call the listed actions and subscribe to the
32
+ * listed events. The "name" provided grants ownership of any actions and events under that
33
+ * namespace. Ownership allows registering actions and publishing events, as well as
34
+ * unregistering actions and clearing event subscriptions.
35
+ *
36
+ * @param options - Options.
37
+ * @param options.messenger - The messenger instance that is being wrapped.
38
+ * @param options.name - The name of the thing this messenger will be handed to (e.g. the
39
+ * controller name). This grants "ownership" of actions and events under this namespace to the
40
+ * restricted messenger returned.
41
+ * @param options.allowedActions - The list of actions that this restricted messenger should be
42
+ * allowed to call.
43
+ * @param options.allowedEvents - The list of events that this restricted messenger should be
44
+ * allowed to subscribe to.
45
+ */
46
+ constructor({ messenger, name, allowedActions, allowedEvents, }: {
47
+ messenger?: Messenger<ActionConstraint, EventConstraint>;
48
+ name: Namespace;
49
+ allowedActions: NotNamespacedBy<Namespace, AllowedAction>[];
50
+ allowedEvents: NotNamespacedBy<Namespace, AllowedEvent>[];
51
+ });
52
+ /**
53
+ * Register an action handler.
54
+ *
55
+ * This will make the registered function available to call via the `call` method.
56
+ *
57
+ * The action type this handler is registered under *must* be in the current namespace.
58
+ *
59
+ * @param action - The action type. This is a unique identifier for this action.
60
+ * @param handler - The action handler. This function gets called when the `call` method is
61
+ * invoked with the given action type.
62
+ * @throws Will throw if an action handler that is not in the current namespace is being registered.
63
+ * @template ActionType - A type union of Action type strings that are namespaced by Namespace.
64
+ */
65
+ registerActionHandler<ActionType extends Action['type'] & NamespacedName<Namespace>>(action: ActionType, handler: ActionHandler<Action, ActionType>): void;
66
+ /**
67
+ * Registers action handlers for a list of methods on a messenger client
68
+ *
69
+ * @param messengerClient - The object that is expected to make use of the messenger.
70
+ * @param methodNames - The names of the methods on the messenger client to register as action
71
+ * handlers
72
+ */
73
+ registerMethodActionHandlers<MessengerClient extends {
74
+ name: string;
75
+ }, MethodNames extends keyof MessengerClient & string>(messengerClient: MessengerClient, methodNames: readonly MethodNames[]): void;
76
+ /**
77
+ * Unregister an action handler.
78
+ *
79
+ * This will prevent this action from being called.
80
+ *
81
+ * The action type being unregistered *must* be in the current namespace.
82
+ *
83
+ * @param action - The action type. This is a unique identifier for this action.
84
+ * @throws Will throw if an action handler that is not in the current namespace is being unregistered.
85
+ * @template ActionType - A type union of Action type strings that are namespaced by Namespace.
86
+ */
87
+ unregisterActionHandler<ActionType extends Action['type'] & NamespacedName<Namespace>>(action: ActionType): void;
88
+ /**
89
+ * Call an action.
90
+ *
91
+ * This function will call the action handler corresponding to the given action type, passing
92
+ * along any parameters given.
93
+ *
94
+ * The action type being called must be on the action allowlist.
95
+ *
96
+ * @param actionType - The action type. This is a unique identifier for this action.
97
+ * @param params - The action parameters. These must match the type of the parameters of the
98
+ * registered action handler.
99
+ * @throws Will throw when no handler has been registered for the given type.
100
+ * @template ActionType - A type union of allowed Action type strings.
101
+ * @returns The action return value.
102
+ */
103
+ call<ActionType extends AllowedAction | (Action['type'] & NamespacedName<Namespace>)>(actionType: ActionType, ...params: ExtractActionParameters<Action, ActionType>): ExtractActionResponse<Action, ActionType>;
104
+ /**
105
+ * Register a function for getting the initial payload for an event.
106
+ *
107
+ * This is used for events that represent a state change, where the payload is the state.
108
+ * Registering a function for getting the payload allows event selectors to have a point of
109
+ * comparison the first time state changes.
110
+ *
111
+ * The event type *must* be in the current namespace
112
+ *
113
+ * @param args - The arguments to this function
114
+ * @param args.eventType - The event type to register a payload for.
115
+ * @param args.getPayload - A function for retrieving the event payload.
116
+ */
117
+ registerInitialEventPayload<EventType extends Event['type'] & NamespacedName<Namespace>>({ eventType, getPayload, }: {
118
+ eventType: EventType;
119
+ getPayload: () => ExtractEventPayload<Event, EventType>;
120
+ }): void;
121
+ /**
122
+ * Publish an event.
123
+ *
124
+ * Publishes the given payload to all subscribers of the given event type.
125
+ *
126
+ * The event type being published *must* be in the current namespace.
127
+ *
128
+ * @param event - The event type. This is a unique identifier for this event.
129
+ * @param payload - The event payload. The type of the parameters for each event handler must
130
+ * match the type of this payload.
131
+ * @throws Will throw if an event that is not in the current namespace is being published.
132
+ * @template EventType - A type union of Event type strings that are namespaced by Namespace.
133
+ */
134
+ publish<EventType extends Event['type'] & NamespacedName<Namespace>>(event: EventType, ...payload: ExtractEventPayload<Event, EventType>): void;
135
+ /**
136
+ * Subscribe to an event.
137
+ *
138
+ * Registers the given function as an event handler for the given event type.
139
+ *
140
+ * The event type being subscribed to must be on the event allowlist.
141
+ *
142
+ * @param eventType - The event type. This is a unique identifier for this event.
143
+ * @param handler - The event handler. The type of the parameters for this event handler must
144
+ * match the type of the payload for this event type.
145
+ * @throws Will throw if the given event is not an allowed event for this messenger.
146
+ * @template EventType - A type union of Event type strings.
147
+ */
148
+ subscribe<EventType extends AllowedEvent | (Event['type'] & NamespacedName<Namespace>)>(eventType: EventType, handler: ExtractEventHandler<Event, EventType>): void;
149
+ /**
150
+ * Subscribe to an event, with a selector.
151
+ *
152
+ * Registers the given handler function as an event handler for the given
153
+ * event type. When an event is published, its payload is first passed to the
154
+ * selector. The event handler is only called if the selector's return value
155
+ * differs from its last known return value.
156
+ *
157
+ * The event type being subscribed to must be on the event allowlist.
158
+ *
159
+ * @param eventType - The event type. This is a unique identifier for this event.
160
+ * @param handler - The event handler. The type of the parameters for this event
161
+ * handler must match the return type of the selector.
162
+ * @param selector - The selector function used to select relevant data from
163
+ * the event payload. The type of the parameters for this selector must match
164
+ * the type of the payload for this event type.
165
+ * @throws Will throw if the given event is not an allowed event for this messenger.
166
+ * @template EventType - A type union of Event type strings.
167
+ * @template SelectorReturnValue - The selector return value.
168
+ */
169
+ subscribe<EventType extends AllowedEvent | (Event['type'] & NamespacedName<Namespace>), SelectorReturnValue>(eventType: EventType, handler: SelectorEventHandler<SelectorReturnValue>, selector: SelectorFunction<Event, EventType, SelectorReturnValue>): void;
170
+ /**
171
+ * Unsubscribe from an event.
172
+ *
173
+ * Unregisters the given function as an event handler for the given event.
174
+ *
175
+ * The event type being unsubscribed to must be on the event allowlist.
176
+ *
177
+ * @param event - The event type. This is a unique identifier for this event.
178
+ * @param handler - The event handler to unregister.
179
+ * @throws Will throw if the given event is not an allowed event for this messenger.
180
+ * @template EventType - A type union of allowed Event type strings.
181
+ */
182
+ unsubscribe<EventType extends AllowedEvent | (Event['type'] & NamespacedName<Namespace>)>(event: EventType, handler: ExtractEventHandler<Event, EventType>): void;
183
+ /**
184
+ * Clear subscriptions for a specific event.
185
+ *
186
+ * This will remove all subscribed handlers for this event.
187
+ *
188
+ * The event type being cleared *must* be in the current namespace.
189
+ *
190
+ * @param event - The event type. This is a unique identifier for this event.
191
+ * @throws Will throw if a subscription for an event that is not in the current namespace is being cleared.
192
+ * @template EventType - A type union of Event type strings that are namespaced by Namespace.
193
+ */
194
+ clearEventSubscriptions<EventType extends Event['type'] & NamespacedName<Namespace>>(event: EventType): void;
195
+ }
196
+ //# sourceMappingURL=RestrictedMessenger.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RestrictedMessenger.d.cts","sourceRoot":"","sources":["../src/RestrictedMessenger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,aAAa,EACb,SAAS,EACT,eAAe,EACf,uBAAuB,EACvB,qBAAqB,EACrB,mBAAmB,EACnB,mBAAmB,EACnB,cAAc,EACd,eAAe,EACf,oBAAoB,EACpB,gBAAgB,EACjB,wBAAoB;AAErB;;;;;;GAMG;AACH,MAAM,MAAM,6BAA6B,CAAC,SAAS,SAAS,MAAM,GAAG,MAAM,IACzE,mBAAmB,CACjB,SAAS,EACT,gBAAgB,EAChB,eAAe,EACf,MAAM,EACN,MAAM,CACP,CAAC;AAEJ;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,mBAAmB,CAC9B,SAAS,SAAS,MAAM,EACxB,MAAM,SAAS,gBAAgB,EAC/B,KAAK,SAAS,eAAe,EAC7B,aAAa,SAAS,MAAM,EAC5B,YAAY,SAAS,MAAM;;IAU3B;;;;;;;;;;;;;;;;;OAiBG;gBACS,EACV,SAAS,EACT,IAAI,EACJ,cAAc,EACd,aAAa,GACd,EAAE;QACD,SAAS,CAAC,EAAE,SAAS,CAAC,gBAAgB,EAAE,eAAe,CAAC,CAAC;QACzD,IAAI,EAAE,SAAS,CAAC;QAChB,cAAc,EAAE,eAAe,CAAC,SAAS,EAAE,aAAa,CAAC,EAAE,CAAC;QAC5D,aAAa,EAAE,eAAe,CAAC,SAAS,EAAE,YAAY,CAAC,EAAE,CAAC;KAC3D;IAWD;;;;;;;;;;;;OAYG;IACH,qBAAqB,CACnB,UAAU,SAAS,MAAM,CAAC,MAAM,CAAC,GAAG,cAAc,CAAC,SAAS,CAAC,EAC7D,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,aAAa,CAAC,MAAM,EAAE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