@elliemae/ssf-guest 2.19.2 → 2.21.0

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.
Files changed (34) hide show
  1. package/dist/cjs/guest.js +121 -34
  2. package/dist/cjs/package.json +4 -1
  3. package/dist/esm/guest.js +121 -34
  4. package/dist/esm/package.json +4 -1
  5. package/dist/public/creditService.html +1 -1
  6. package/dist/public/index.html +1 -1
  7. package/dist/public/js/emuiSsfGuest.70d35ed24daaaae84bd5.js +29 -0
  8. package/dist/public/js/emuiSsfGuest.70d35ed24daaaae84bd5.js.br +0 -0
  9. package/dist/public/js/emuiSsfGuest.70d35ed24daaaae84bd5.js.gz +0 -0
  10. package/dist/public/js/emuiSsfGuest.70d35ed24daaaae84bd5.js.map +1 -0
  11. package/dist/public/loanValidation.html +1 -1
  12. package/dist/public/pricingService.html +1 -1
  13. package/dist/public/pricingService.js +1 -1
  14. package/dist/public/pricingService.js.br +0 -0
  15. package/dist/public/pricingService.js.gz +0 -0
  16. package/dist/public/pricingService.js.map +1 -1
  17. package/dist/public/titleService.html +1 -1
  18. package/dist/public/v2-guest.html +1 -1
  19. package/dist/types/lib/guest.d.ts +13 -13
  20. package/dist/types/lib/tests/guestMethods.test.d.ts +1 -0
  21. package/dist/types/tsconfig.tsbuildinfo +1 -1
  22. package/dist/umd/index.js +10 -10
  23. package/dist/umd/index.js.br +0 -0
  24. package/dist/umd/index.js.gz +0 -0
  25. package/dist/umd/index.js.map +1 -1
  26. package/dist/umd/pricingService.js +1 -1
  27. package/dist/umd/pricingService.js.br +0 -0
  28. package/dist/umd/pricingService.js.gz +0 -0
  29. package/dist/umd/pricingService.js.map +1 -1
  30. package/package.json +21 -18
  31. package/dist/public/js/emuiSsfGuest.13afd8df5cfc09123425.js +0 -29
  32. package/dist/public/js/emuiSsfGuest.13afd8df5cfc09123425.js.br +0 -0
  33. package/dist/public/js/emuiSsfGuest.13afd8df5cfc09123425.js.gz +0 -0
  34. package/dist/public/js/emuiSsfGuest.13afd8df5cfc09123425.js.map +0 -1
package/dist/cjs/guest.js CHANGED
@@ -64,6 +64,12 @@ const diagnosticsEndpoint = {
64
64
  "cdn.pt1.ice.com": "https://pel1.api.ellielabs.com/diagnostics/v2/logging",
65
65
  "cdn.qa1.ice.com": "https://int.api.ellielabs.com/diagnostics/v2/logging",
66
66
  "cdn.dev1.ice.com": "https://int.api.ellielabs.com/diagnostics/v2/logging",
67
+ "cdn.mortgagetech.ice.com": "https://api.elliemae.com/diagnostics/v2/logging",
68
+ "cdn.mortgagetech.s1.ice.com": "https://stg.api.elliemae.com/diagnostics/v2/logging",
69
+ "cdn.mortgagetech.uat1.ice.com": "https://concept.api.elliemae.com/diagnostics/v2/logging",
70
+ "cdn.mortgagetech.pl1.ice.com": "https://pel1.api.ellielabs.com/diagnostics/v2/logging",
71
+ "cdn.mortgagetech.q1.ice.com": "https://int.api.ellielabs.com/diagnostics/v2/logging",
72
+ "cdn.mortgagetech.d1.ice.com": "https://int.api.ellielabs.com/diagnostics/v2/logging",
67
73
  localhost: "https://int.api.ellielabs.com/diagnostics/v2/logging"
68
74
  };
69
75
  const userInteractionEvents = ["click", "scroll", "keypress", "touchstart"];
@@ -161,8 +167,8 @@ class SSFGuest {
161
167
  });
162
168
  /**
163
169
  * Marshals scripting object JSON into a proxy object
164
- * @param soJSON scripting object JSON
165
- * @returns marshaled proxy object
170
+ * @param {RemotingScriptingObject} soJSON scripting object JSON
171
+ * @returns {IScriptingObjectProxy} marshaled proxy object
166
172
  */
167
173
  #fromJSON = (soJSON) => {
168
174
  if (!soJSON || !soJSON.objectId) {
@@ -203,11 +209,11 @@ class SSFGuest {
203
209
  };
204
210
  /**
205
211
  * call scripting object api exposed by host
206
- * @param param0
207
- * @param param0.objectId
208
- * @param param0.functionName
209
- * @param param0.functionParams
210
- * @returns
212
+ * @param {object} param0 - The parameters object
213
+ * @param {string} param0.objectId - The object ID to invoke
214
+ * @param {string} param0.functionName - The function name to call
215
+ * @param {Array<any>} param0.functionParams - The parameters for the function
216
+ * @returns {Promise<any>} The result of the function call
211
217
  */
212
218
  #invoke = async ({
213
219
  objectId,
@@ -250,10 +256,52 @@ class SSFGuest {
250
256
  });
251
257
  return retVal;
252
258
  };
259
+ /**
260
+ * Checks if a given payload matches all specified filter criteria.
261
+ *
262
+ * Iterates over each entry in the criteria object and evaluates the corresponding condition
263
+ * against the payload's value for that key. Supported condition types include:
264
+ * - `eq`: Checks for strict equality.
265
+ * - `in`: Checks if the value is included in a provided array.
266
+ * - `includes`: Checks if the payload's value (an array) includes a specified element.
267
+ * - `gt`: Checks if the value is greater than a specified number.
268
+ * - `lt`: Checks if the value is less than a specified number.
269
+ * - `regex`: Checks if the value (a string) matches a provided regular expression.
270
+ * @param {Record<string, any>} payload - The object containing values to be checked against the criteria.
271
+ * @param {FilterCriteria} criteria - An object specifying filter conditions for each key.
272
+ * @returns {boolean} `true` if all criteria are satisfied by the payload, otherwise `false`.
273
+ */
274
+ #matchesCriteria(payload, criteria) {
275
+ return Object.entries(criteria).every(([key, condition]) => {
276
+ const value = payload[key];
277
+ if ("eq" in condition) return value === condition.eq;
278
+ if ("in" in condition)
279
+ return Array.isArray(condition.in) && condition.in.includes(value);
280
+ if ("includes" in condition)
281
+ return Array.isArray(value) && value.includes(condition.includes);
282
+ if ("gt" in condition) {
283
+ const numValue = typeof value === "number" ? value : Number(value);
284
+ return !Number.isNaN(numValue) && numValue > condition.gt;
285
+ }
286
+ if ("lt" in condition) {
287
+ const numValue = typeof value === "number" ? value : Number(value);
288
+ return !Number.isNaN(numValue) && numValue < condition.lt;
289
+ }
290
+ if ("regex" in condition) {
291
+ try {
292
+ const regex = new RegExp(condition.regex);
293
+ return typeof value === "string" && regex.test(value);
294
+ } catch {
295
+ return false;
296
+ }
297
+ }
298
+ return false;
299
+ });
300
+ }
253
301
  /**
254
302
  * handle response from host
255
- * @param response
256
- * @returns
303
+ * @param {ObjectResponse | ValueResponse} response - The response to handle
304
+ * @returns {any} The handled response value or proxy object
257
305
  */
258
306
  #handleResponse = (response) => {
259
307
  if (response?.type === "object" /* OBJECT */ && "object" in response) {
@@ -266,8 +314,8 @@ class SSFGuest {
266
314
  };
267
315
  /**
268
316
  * handle config change event
269
- * @param root0
270
- * @param root0.body
317
+ * @param {object} root0 - The event parameters
318
+ * @param {Config} root0.body - The configuration body
271
319
  */
272
320
  #handleConfigChangeEvent = ({ body }) => {
273
321
  if (body?.logLevel) {
@@ -311,12 +359,20 @@ class SSFGuest {
311
359
  }
312
360
  };
313
361
  /**
314
- * handle get object call
315
- * @param param0
316
- * @param param0.sourceWin
317
- * @param param0.sourceOrigin
318
- * @param param0.requestId
319
- * @param param0.body
362
+ * Handles an incoming object event from a remote source, deserializes the object,
363
+ * determines the appropriate event listeners, and invokes them with the event data.
364
+ * Collects responses from listeners (including promises) and sends them back to the source window if a requestId is provided.
365
+ * Audits the event processing for debugging and tracking purposes.
366
+ * @param {object} params - The parameters for the event listener callback, including source window, origin, request ID, and event body.
367
+ * @param {Window} params.sourceWin - The window from which the event originated.
368
+ * @param {string} params.sourceOrigin - The origin of the source window.
369
+ * @param {string} params.requestId - The unique identifier for the request, if a response is expected.
370
+ * @param {any} params.body - The event message body containing the object, event name, handler, parameters, and options.
371
+ * @description
372
+ * - If an event handler is specified in the body, only that handler is invoked.
373
+ * - If criteria are specified for a listener, the event is only delivered if the criteria match.
374
+ * - All listener responses are collected and returned as an array if a requestId is present.
375
+ * - Audit logs are generated for both handled and responded events.
320
376
  */
321
377
  #handleObjectEvent = async ({
322
378
  sourceWin,
@@ -343,6 +399,15 @@ class SSFGuest {
343
399
  const promises = [];
344
400
  listeners.forEach((callbackInfo) => {
345
401
  if (callbackInfo?.callback) {
402
+ if (callbackInfo.criteria) {
403
+ const criteriaMatched = body.eventParams ? this.#matchesCriteria(body.eventParams, callbackInfo.criteria) : false;
404
+ if (!criteriaMatched) {
405
+ this.#logger.debug(
406
+ `Event ${eventId} did not match criteria for subscriber ${callbackInfo.callback.name}`
407
+ );
408
+ return;
409
+ }
410
+ }
346
411
  this.#logger.debug(
347
412
  `Invoking event subscriber ${callbackInfo.callback.name} for event ${eventId}`
348
413
  );
@@ -495,8 +560,8 @@ class SSFGuest {
495
560
  };
496
561
  /**
497
562
  * Initialize guest using script
498
- * @param scriptUri uri of the script
499
- * @param containerElement dom element to inject the script at
563
+ * @param {string} scriptUri uri of the script
564
+ * @param {HTMLElement} containerElement dom element to inject the script at
500
565
  */
501
566
  addScript = async (scriptUri, containerElement) => {
502
567
  if (!this.#created && scriptUri) {
@@ -608,7 +673,7 @@ class SSFGuest {
608
673
  };
609
674
  /**
610
675
  * Get bearer token to access dev connect api
611
- * @returns auth token
676
+ * @returns {Promise<string>} auth token
612
677
  */
613
678
  getAuthToken = async () => {
614
679
  if (!this.#authToken && this.#isConnected) {
@@ -624,7 +689,6 @@ class SSFGuest {
624
689
  "Auth object not available to get access token from host"
625
690
  );
626
691
  } catch (e) {
627
- console.dir(e, { depth: null });
628
692
  this.#logger.error(
629
693
  `Error getting access token from auth object. ${e.message}`
630
694
  );
@@ -634,8 +698,8 @@ class SSFGuest {
634
698
  };
635
699
  /**
636
700
  * Get scripting object proxy by id
637
- * @param objectId unique id of the scripting object
638
- * @returns scripting object proxy
701
+ * @param {string} objectId unique id of the scripting object
702
+ * @returns {Promise<any>} scripting object proxy
639
703
  */
640
704
  getObject = async (objectId) => {
641
705
  this.#logger.debug(
@@ -660,7 +724,7 @@ class SSFGuest {
660
724
  };
661
725
  /**
662
726
  * Get names of scripting objects exposed by the host
663
- * @returns scripting objects exposed by the host
727
+ * @returns {Promise<any>} scripting objects exposed by the host
664
728
  */
665
729
  listObjects = async () => {
666
730
  this.#logger.debug(
@@ -692,8 +756,7 @@ class SSFGuest {
692
756
  };
693
757
  /**
694
758
  * Set the log level
695
- * @param {LogLevels} logLevel - log level
696
- * @param level
759
+ * @param {LogLevels} level - log level
697
760
  */
698
761
  setLogLevel = (level) => {
699
762
  this.#logger.setLogLevel(level);
@@ -701,30 +764,54 @@ class SSFGuest {
701
764
  };
702
765
  /**
703
766
  * subscribe to an scripting object event
704
- * @param {SubscribeParam<EventId, AppEvents[EventId]>} param - parameters for subscribing to an event
705
- * @returns subscription token
767
+ * @param {any} param - parameters for subscribing to an event
768
+ * @returns {string} subscription token
706
769
  */
707
770
  subscribe = (param) => {
708
- const { eventId, callback } = param;
771
+ const { eventId, criteria, callback } = param;
709
772
  this.#logger.debug(`Registering subscription for event ${eventId}`);
710
773
  const listeners = this.#eventListeners.get(eventId.toLowerCase()) || [];
711
774
  const token = (0, import_uuid.v4)();
712
- listeners.push({ callback, token });
775
+ listeners.push({ callback, token, criteria });
713
776
  this.#eventListeners.set(eventId.toLowerCase(), listeners);
777
+ this.#remoting.send({
778
+ targetWin: this.#hostWindow,
779
+ targetOrigin: this.#hostOrigin,
780
+ messageType: import_microfe_common.MessageType.GuestEventSubscribe,
781
+ messageBody: {
782
+ eventId,
783
+ criteria,
784
+ token
785
+ }
786
+ });
787
+ this.#logger.debug(`Subscribed to event ${eventId} with token ${token}`);
714
788
  return token;
715
789
  };
716
790
  /**
717
791
  * unsubscribe from an scripting object event
718
- * @param {UnsubscribeParam<EventId>} param - parameters for unsubscribing from an event
792
+ * @param {any} param - parameters for unsubscribing from an event
719
793
  */
720
794
  unsubscribe = (param) => {
721
795
  const { eventId, token } = param;
722
- let listeners = this.#eventListeners.get(eventId.toLowerCase());
796
+ const listeners = this.#eventListeners.get(eventId.toLowerCase());
723
797
  if (listeners) {
724
- listeners = listeners.filter(
798
+ const originalLength = listeners.length;
799
+ const filteredListeners = listeners.filter(
725
800
  (callbackInfo) => callbackInfo.token !== token
726
801
  );
727
- this.#eventListeners.set(eventId.toLowerCase(), listeners);
802
+ if (filteredListeners.length < originalLength) {
803
+ this.#eventListeners.set(eventId.toLowerCase(), filteredListeners);
804
+ this.#remoting.send({
805
+ targetWin: this.#hostWindow,
806
+ targetOrigin: this.#hostOrigin,
807
+ messageType: import_microfe_common.MessageType.GuestEventUnsubscribe,
808
+ messageBody: {
809
+ eventId,
810
+ token
811
+ }
812
+ });
813
+ this.#logger.debug(`Unsubscribed from event ${eventId}`);
814
+ }
728
815
  }
729
816
  };
730
817
  }
@@ -1,4 +1,7 @@
1
1
  {
2
2
  "type": "commonjs",
3
- "sideEffects": false
3
+ "sideEffects": false,
4
+ "publishConfig": {
5
+ "access": "public"
6
+ }
4
7
  }
package/dist/esm/guest.js CHANGED
@@ -60,6 +60,12 @@ const diagnosticsEndpoint = {
60
60
  "cdn.pt1.ice.com": "https://pel1.api.ellielabs.com/diagnostics/v2/logging",
61
61
  "cdn.qa1.ice.com": "https://int.api.ellielabs.com/diagnostics/v2/logging",
62
62
  "cdn.dev1.ice.com": "https://int.api.ellielabs.com/diagnostics/v2/logging",
63
+ "cdn.mortgagetech.ice.com": "https://api.elliemae.com/diagnostics/v2/logging",
64
+ "cdn.mortgagetech.s1.ice.com": "https://stg.api.elliemae.com/diagnostics/v2/logging",
65
+ "cdn.mortgagetech.uat1.ice.com": "https://concept.api.elliemae.com/diagnostics/v2/logging",
66
+ "cdn.mortgagetech.pl1.ice.com": "https://pel1.api.ellielabs.com/diagnostics/v2/logging",
67
+ "cdn.mortgagetech.q1.ice.com": "https://int.api.ellielabs.com/diagnostics/v2/logging",
68
+ "cdn.mortgagetech.d1.ice.com": "https://int.api.ellielabs.com/diagnostics/v2/logging",
63
69
  localhost: "https://int.api.ellielabs.com/diagnostics/v2/logging"
64
70
  };
65
71
  const userInteractionEvents = ["click", "scroll", "keypress", "touchstart"];
@@ -157,8 +163,8 @@ class SSFGuest {
157
163
  });
158
164
  /**
159
165
  * Marshals scripting object JSON into a proxy object
160
- * @param soJSON scripting object JSON
161
- * @returns marshaled proxy object
166
+ * @param {RemotingScriptingObject} soJSON scripting object JSON
167
+ * @returns {IScriptingObjectProxy} marshaled proxy object
162
168
  */
163
169
  #fromJSON = (soJSON) => {
164
170
  if (!soJSON || !soJSON.objectId) {
@@ -199,11 +205,11 @@ class SSFGuest {
199
205
  };
200
206
  /**
201
207
  * call scripting object api exposed by host
202
- * @param param0
203
- * @param param0.objectId
204
- * @param param0.functionName
205
- * @param param0.functionParams
206
- * @returns
208
+ * @param {object} param0 - The parameters object
209
+ * @param {string} param0.objectId - The object ID to invoke
210
+ * @param {string} param0.functionName - The function name to call
211
+ * @param {Array<any>} param0.functionParams - The parameters for the function
212
+ * @returns {Promise<any>} The result of the function call
207
213
  */
208
214
  #invoke = async ({
209
215
  objectId,
@@ -246,10 +252,52 @@ class SSFGuest {
246
252
  });
247
253
  return retVal;
248
254
  };
255
+ /**
256
+ * Checks if a given payload matches all specified filter criteria.
257
+ *
258
+ * Iterates over each entry in the criteria object and evaluates the corresponding condition
259
+ * against the payload's value for that key. Supported condition types include:
260
+ * - `eq`: Checks for strict equality.
261
+ * - `in`: Checks if the value is included in a provided array.
262
+ * - `includes`: Checks if the payload's value (an array) includes a specified element.
263
+ * - `gt`: Checks if the value is greater than a specified number.
264
+ * - `lt`: Checks if the value is less than a specified number.
265
+ * - `regex`: Checks if the value (a string) matches a provided regular expression.
266
+ * @param {Record<string, any>} payload - The object containing values to be checked against the criteria.
267
+ * @param {FilterCriteria} criteria - An object specifying filter conditions for each key.
268
+ * @returns {boolean} `true` if all criteria are satisfied by the payload, otherwise `false`.
269
+ */
270
+ #matchesCriteria(payload, criteria) {
271
+ return Object.entries(criteria).every(([key, condition]) => {
272
+ const value = payload[key];
273
+ if ("eq" in condition) return value === condition.eq;
274
+ if ("in" in condition)
275
+ return Array.isArray(condition.in) && condition.in.includes(value);
276
+ if ("includes" in condition)
277
+ return Array.isArray(value) && value.includes(condition.includes);
278
+ if ("gt" in condition) {
279
+ const numValue = typeof value === "number" ? value : Number(value);
280
+ return !Number.isNaN(numValue) && numValue > condition.gt;
281
+ }
282
+ if ("lt" in condition) {
283
+ const numValue = typeof value === "number" ? value : Number(value);
284
+ return !Number.isNaN(numValue) && numValue < condition.lt;
285
+ }
286
+ if ("regex" in condition) {
287
+ try {
288
+ const regex = new RegExp(condition.regex);
289
+ return typeof value === "string" && regex.test(value);
290
+ } catch {
291
+ return false;
292
+ }
293
+ }
294
+ return false;
295
+ });
296
+ }
249
297
  /**
250
298
  * handle response from host
251
- * @param response
252
- * @returns
299
+ * @param {ObjectResponse | ValueResponse} response - The response to handle
300
+ * @returns {any} The handled response value or proxy object
253
301
  */
254
302
  #handleResponse = (response) => {
255
303
  if (response?.type === "object" /* OBJECT */ && "object" in response) {
@@ -262,8 +310,8 @@ class SSFGuest {
262
310
  };
263
311
  /**
264
312
  * handle config change event
265
- * @param root0
266
- * @param root0.body
313
+ * @param {object} root0 - The event parameters
314
+ * @param {Config} root0.body - The configuration body
267
315
  */
268
316
  #handleConfigChangeEvent = ({ body }) => {
269
317
  if (body?.logLevel) {
@@ -307,12 +355,20 @@ class SSFGuest {
307
355
  }
308
356
  };
309
357
  /**
310
- * handle get object call
311
- * @param param0
312
- * @param param0.sourceWin
313
- * @param param0.sourceOrigin
314
- * @param param0.requestId
315
- * @param param0.body
358
+ * Handles an incoming object event from a remote source, deserializes the object,
359
+ * determines the appropriate event listeners, and invokes them with the event data.
360
+ * Collects responses from listeners (including promises) and sends them back to the source window if a requestId is provided.
361
+ * Audits the event processing for debugging and tracking purposes.
362
+ * @param {object} params - The parameters for the event listener callback, including source window, origin, request ID, and event body.
363
+ * @param {Window} params.sourceWin - The window from which the event originated.
364
+ * @param {string} params.sourceOrigin - The origin of the source window.
365
+ * @param {string} params.requestId - The unique identifier for the request, if a response is expected.
366
+ * @param {any} params.body - The event message body containing the object, event name, handler, parameters, and options.
367
+ * @description
368
+ * - If an event handler is specified in the body, only that handler is invoked.
369
+ * - If criteria are specified for a listener, the event is only delivered if the criteria match.
370
+ * - All listener responses are collected and returned as an array if a requestId is present.
371
+ * - Audit logs are generated for both handled and responded events.
316
372
  */
317
373
  #handleObjectEvent = async ({
318
374
  sourceWin,
@@ -339,6 +395,15 @@ class SSFGuest {
339
395
  const promises = [];
340
396
  listeners.forEach((callbackInfo) => {
341
397
  if (callbackInfo?.callback) {
398
+ if (callbackInfo.criteria) {
399
+ const criteriaMatched = body.eventParams ? this.#matchesCriteria(body.eventParams, callbackInfo.criteria) : false;
400
+ if (!criteriaMatched) {
401
+ this.#logger.debug(
402
+ `Event ${eventId} did not match criteria for subscriber ${callbackInfo.callback.name}`
403
+ );
404
+ return;
405
+ }
406
+ }
342
407
  this.#logger.debug(
343
408
  `Invoking event subscriber ${callbackInfo.callback.name} for event ${eventId}`
344
409
  );
@@ -491,8 +556,8 @@ class SSFGuest {
491
556
  };
492
557
  /**
493
558
  * Initialize guest using script
494
- * @param scriptUri uri of the script
495
- * @param containerElement dom element to inject the script at
559
+ * @param {string} scriptUri uri of the script
560
+ * @param {HTMLElement} containerElement dom element to inject the script at
496
561
  */
497
562
  addScript = async (scriptUri, containerElement) => {
498
563
  if (!this.#created && scriptUri) {
@@ -604,7 +669,7 @@ class SSFGuest {
604
669
  };
605
670
  /**
606
671
  * Get bearer token to access dev connect api
607
- * @returns auth token
672
+ * @returns {Promise<string>} auth token
608
673
  */
609
674
  getAuthToken = async () => {
610
675
  if (!this.#authToken && this.#isConnected) {
@@ -620,7 +685,6 @@ class SSFGuest {
620
685
  "Auth object not available to get access token from host"
621
686
  );
622
687
  } catch (e) {
623
- console.dir(e, { depth: null });
624
688
  this.#logger.error(
625
689
  `Error getting access token from auth object. ${e.message}`
626
690
  );
@@ -630,8 +694,8 @@ class SSFGuest {
630
694
  };
631
695
  /**
632
696
  * Get scripting object proxy by id
633
- * @param objectId unique id of the scripting object
634
- * @returns scripting object proxy
697
+ * @param {string} objectId unique id of the scripting object
698
+ * @returns {Promise<any>} scripting object proxy
635
699
  */
636
700
  getObject = async (objectId) => {
637
701
  this.#logger.debug(
@@ -656,7 +720,7 @@ class SSFGuest {
656
720
  };
657
721
  /**
658
722
  * Get names of scripting objects exposed by the host
659
- * @returns scripting objects exposed by the host
723
+ * @returns {Promise<any>} scripting objects exposed by the host
660
724
  */
661
725
  listObjects = async () => {
662
726
  this.#logger.debug(
@@ -688,8 +752,7 @@ class SSFGuest {
688
752
  };
689
753
  /**
690
754
  * Set the log level
691
- * @param {LogLevels} logLevel - log level
692
- * @param level
755
+ * @param {LogLevels} level - log level
693
756
  */
694
757
  setLogLevel = (level) => {
695
758
  this.#logger.setLogLevel(level);
@@ -697,30 +760,54 @@ class SSFGuest {
697
760
  };
698
761
  /**
699
762
  * subscribe to an scripting object event
700
- * @param {SubscribeParam<EventId, AppEvents[EventId]>} param - parameters for subscribing to an event
701
- * @returns subscription token
763
+ * @param {any} param - parameters for subscribing to an event
764
+ * @returns {string} subscription token
702
765
  */
703
766
  subscribe = (param) => {
704
- const { eventId, callback } = param;
767
+ const { eventId, criteria, callback } = param;
705
768
  this.#logger.debug(`Registering subscription for event ${eventId}`);
706
769
  const listeners = this.#eventListeners.get(eventId.toLowerCase()) || [];
707
770
  const token = uuidv4();
708
- listeners.push({ callback, token });
771
+ listeners.push({ callback, token, criteria });
709
772
  this.#eventListeners.set(eventId.toLowerCase(), listeners);
773
+ this.#remoting.send({
774
+ targetWin: this.#hostWindow,
775
+ targetOrigin: this.#hostOrigin,
776
+ messageType: MessageType.GuestEventSubscribe,
777
+ messageBody: {
778
+ eventId,
779
+ criteria,
780
+ token
781
+ }
782
+ });
783
+ this.#logger.debug(`Subscribed to event ${eventId} with token ${token}`);
710
784
  return token;
711
785
  };
712
786
  /**
713
787
  * unsubscribe from an scripting object event
714
- * @param {UnsubscribeParam<EventId>} param - parameters for unsubscribing from an event
788
+ * @param {any} param - parameters for unsubscribing from an event
715
789
  */
716
790
  unsubscribe = (param) => {
717
791
  const { eventId, token } = param;
718
- let listeners = this.#eventListeners.get(eventId.toLowerCase());
792
+ const listeners = this.#eventListeners.get(eventId.toLowerCase());
719
793
  if (listeners) {
720
- listeners = listeners.filter(
794
+ const originalLength = listeners.length;
795
+ const filteredListeners = listeners.filter(
721
796
  (callbackInfo) => callbackInfo.token !== token
722
797
  );
723
- this.#eventListeners.set(eventId.toLowerCase(), listeners);
798
+ if (filteredListeners.length < originalLength) {
799
+ this.#eventListeners.set(eventId.toLowerCase(), filteredListeners);
800
+ this.#remoting.send({
801
+ targetWin: this.#hostWindow,
802
+ targetOrigin: this.#hostOrigin,
803
+ messageType: MessageType.GuestEventUnsubscribe,
804
+ messageBody: {
805
+ eventId,
806
+ token
807
+ }
808
+ });
809
+ this.#logger.debug(`Unsubscribed from event ${eventId}`);
810
+ }
724
811
  }
725
812
  };
726
813
  }
@@ -1,4 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
- "sideEffects": false
3
+ "sideEffects": false,
4
+ "publishConfig": {
5
+ "access": "public"
6
+ }
4
7
  }
@@ -1 +1 @@
1
- <!doctype html><html lang="en"><head><meta charset="UTF-8"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><meta name="viewport" content="width=device-width,initial-scale=1"/><title>Credit Service</title><style>body{margin:0}</style><script src="https://cdn.qa1.ice.com/pui-diagnostics@3"></script><script>window.addEventListener("DOMContentLoaded",async()=>{window.__ICE__={diagnosticsUrl:"https://int.api.ellielabs.com/diagnostics/v2/logging"};const e=new URL(window.location),i=e?.searchParams?.get?.("src");window.__ICE__.ssfGuest=new ice.guest.SSFGuest({logger:{index:"creditServiceGuest",team:"ui platform",appName:"credit-service"}}),await window.__ICE__.ssfGuest.addScript(i,document.body)})</script><script defer="defer" src="js/emuiSsfGuest.13afd8df5cfc09123425.js"></script></head><body></body></html>
1
+ <!doctype html><html lang="en"><head><meta charset="UTF-8"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><meta name="viewport" content="width=device-width,initial-scale=1"/><title>Credit Service</title><style>body{margin:0}</style><script src="https://cdn.qa1.ice.com/pui-diagnostics@3"></script><script>window.addEventListener("DOMContentLoaded",async()=>{window.__ICE__={diagnosticsUrl:"https://int.api.ellielabs.com/diagnostics/v2/logging"};const e=new URL(window.location),i=e?.searchParams?.get?.("src");window.__ICE__.ssfGuest=new ice.guest.SSFGuest({logger:{index:"creditServiceGuest",team:"ui platform",appName:"credit-service"}}),await window.__ICE__.ssfGuest.addScript(i,document.body)})</script><script defer="defer" src="js/emuiSsfGuest.70d35ed24daaaae84bd5.js"></script></head><body></body></html>
@@ -1 +1 @@
1
- <!doctype html><html lang="en" style="height:100%"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Plugin</title><script src="https://cdn.tailwindcss.com?plugins=forms"></script><script defer="defer" src="js/emuiSsfGuest.13afd8df5cfc09123425.js"></script></head><body class="px-2 h-full"><main class="h-full"><h1 class="text-md font-bold">Credit Score Service</h1><div class="h-full mt-2"><output id="msg" class="mt-2 p-2"></output></div></main></body></html>
1
+ <!doctype html><html lang="en" style="height:100%"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Plugin</title><script src="https://cdn.tailwindcss.com?plugins=forms"></script><script defer="defer" src="js/emuiSsfGuest.70d35ed24daaaae84bd5.js"></script></head><body class="px-2 h-full"><main class="h-full"><h1 class="text-md font-bold">Credit Score Service</h1><div class="h-full mt-2"><output id="msg" class="mt-2 p-2"></output></div></main></body></html>