@elliemae/ssf-guest 2.30.0 → 2.32.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.
- package/dist/cjs/guest.js +58 -15
- package/dist/cjs/package.json +1 -4
- package/dist/cjs/v1-adapter.js +2 -1
- package/dist/esm/guest.js +58 -15
- package/dist/esm/package.json +1 -4
- package/dist/esm/v1-adapter.js +2 -1
- package/dist/public/callchain-grandchild.html +1 -1
- package/dist/public/creditService.html +1 -1
- package/dist/public/e2e-guest.html +1 -1
- package/dist/public/index.html +1 -1
- package/dist/public/js/emuiSsfGuest.3b53f24a26401c08b1cd.js +3 -0
- package/dist/public/js/emuiSsfGuest.3b53f24a26401c08b1cd.js.br +0 -0
- package/dist/public/js/emuiSsfGuest.3b53f24a26401c08b1cd.js.gz +0 -0
- package/dist/public/js/emuiSsfGuest.3b53f24a26401c08b1cd.js.map +1 -0
- package/dist/public/loanValidation.html +1 -1
- package/dist/public/pricingService.html +1 -1
- package/dist/public/titleService.html +1 -1
- package/dist/public/v2-guest.html +1 -1
- package/dist/types/lib/guest.d.ts +4 -0
- package/dist/types/lib/typings/window.d.ts +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/dist/umd/index.js +1 -1
- package/dist/umd/index.js.br +0 -0
- package/dist/umd/index.js.gz +0 -0
- package/dist/umd/index.js.map +1 -1
- package/package.json +6 -6
- package/dist/public/js/emuiSsfGuest.e1f3b91362e8df6f972d.js +0 -3
- package/dist/public/js/emuiSsfGuest.e1f3b91362e8df6f972d.js.br +0 -0
- package/dist/public/js/emuiSsfGuest.e1f3b91362e8df6f972d.js.gz +0 -0
- package/dist/public/js/emuiSsfGuest.e1f3b91362e8df6f972d.js.map +0 -1
package/dist/cjs/guest.js
CHANGED
|
@@ -425,7 +425,8 @@ class SSFGuest {
|
|
|
425
425
|
{
|
|
426
426
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
427
427
|
callback: window[body.eventHandler],
|
|
428
|
-
token: (0, import_uuid.v4)()
|
|
428
|
+
token: (0, import_uuid.v4)(),
|
|
429
|
+
eventId
|
|
429
430
|
}
|
|
430
431
|
];
|
|
431
432
|
} else {
|
|
@@ -434,7 +435,7 @@ class SSFGuest {
|
|
|
434
435
|
const promises = [];
|
|
435
436
|
listeners.forEach((callbackInfo) => {
|
|
436
437
|
if (callbackInfo?.callback) {
|
|
437
|
-
if (callbackInfo.criteria) {
|
|
438
|
+
if (callbackInfo.criteria && callbackInfo.filterOnGuest !== false) {
|
|
438
439
|
const criteriaMatched = body.eventParams ? this.#matchesCriteria(body.eventParams, callbackInfo.criteria) : false;
|
|
439
440
|
if (!criteriaMatched) {
|
|
440
441
|
this.#logger.debug(
|
|
@@ -616,22 +617,59 @@ class SSFGuest {
|
|
|
616
617
|
});
|
|
617
618
|
}
|
|
618
619
|
};
|
|
620
|
+
/**
|
|
621
|
+
* Notifies the host to drop every active guest event subscription and clears
|
|
622
|
+
* local listener state. Best-effort when host references are unavailable.
|
|
623
|
+
*/
|
|
624
|
+
#unsubscribeAllEventListeners = () => {
|
|
625
|
+
const hostWindow = this.#hostWindow;
|
|
626
|
+
const hostOrigin = this.#hostOrigin;
|
|
627
|
+
try {
|
|
628
|
+
if (hostWindow && hostOrigin) {
|
|
629
|
+
this.#eventListeners.forEach((listeners) => {
|
|
630
|
+
listeners.forEach(({ token, eventId }) => {
|
|
631
|
+
try {
|
|
632
|
+
this.#remoting.send({
|
|
633
|
+
targetWin: hostWindow,
|
|
634
|
+
targetOrigin: hostOrigin,
|
|
635
|
+
messageType: import_microfe_common.MessageType.GuestEventUnsubscribe,
|
|
636
|
+
messageBody: { eventId, token }
|
|
637
|
+
});
|
|
638
|
+
} catch (error) {
|
|
639
|
+
this.#logger.debug(
|
|
640
|
+
`Failed to notify host of unsubscribe for ${eventId}: ${error.message}`
|
|
641
|
+
);
|
|
642
|
+
}
|
|
643
|
+
});
|
|
644
|
+
});
|
|
645
|
+
}
|
|
646
|
+
} finally {
|
|
647
|
+
this.#eventListeners.clear();
|
|
648
|
+
}
|
|
649
|
+
};
|
|
619
650
|
/**
|
|
620
651
|
* Close the connection to the host
|
|
621
652
|
*/
|
|
622
653
|
close = async () => {
|
|
623
654
|
if (!this.#isConnected) return;
|
|
655
|
+
this.#unsubscribeAllEventListeners();
|
|
624
656
|
if (this.#hostWindow && this.#hostOrigin) {
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
657
|
+
try {
|
|
658
|
+
this.#remoting.send({
|
|
659
|
+
targetWin: this.#hostWindow,
|
|
660
|
+
targetOrigin: this.#hostOrigin,
|
|
661
|
+
messageType: import_microfe_common.MessageType.GuestClose,
|
|
662
|
+
messageBody: {}
|
|
663
|
+
});
|
|
664
|
+
this.#remoting.removeSender({
|
|
665
|
+
origin: this.#hostOrigin,
|
|
666
|
+
window: this.#hostWindow
|
|
667
|
+
});
|
|
668
|
+
} catch (error) {
|
|
669
|
+
this.#logger.debug(
|
|
670
|
+
`Failed to notify host of guest close: ${error.message}`
|
|
671
|
+
);
|
|
672
|
+
}
|
|
635
673
|
}
|
|
636
674
|
this.#remoting.close();
|
|
637
675
|
if (this.#parentCloseMonitor) {
|
|
@@ -807,11 +845,15 @@ class SSFGuest {
|
|
|
807
845
|
* @returns {string} subscription token
|
|
808
846
|
*/
|
|
809
847
|
subscribe = (param) => {
|
|
810
|
-
const { eventId, criteria, callback } = param;
|
|
848
|
+
const { eventId, criteria, callback, filterOnGuest } = param;
|
|
811
849
|
this.#logger.debug(`Registering subscription for event ${eventId}`);
|
|
812
850
|
const listeners = this.#eventListeners.get(eventId.toLowerCase()) || [];
|
|
813
851
|
const token = (0, import_uuid.v4)();
|
|
814
|
-
|
|
852
|
+
const listenerInfo = { callback, token, criteria, eventId };
|
|
853
|
+
if (filterOnGuest === false) {
|
|
854
|
+
listenerInfo.filterOnGuest = false;
|
|
855
|
+
}
|
|
856
|
+
listeners.push(listenerInfo);
|
|
815
857
|
this.#eventListeners.set(eventId.toLowerCase(), listeners);
|
|
816
858
|
const { hostWindow, hostOrigin } = this.#requireHost();
|
|
817
859
|
this.#remoting.send({
|
|
@@ -821,7 +863,8 @@ class SSFGuest {
|
|
|
821
863
|
messageBody: {
|
|
822
864
|
eventId,
|
|
823
865
|
criteria,
|
|
824
|
-
token
|
|
866
|
+
token,
|
|
867
|
+
...filterOnGuest === false ? { filterOnGuest: false } : {}
|
|
825
868
|
}
|
|
826
869
|
});
|
|
827
870
|
this.#logger.debug(`Subscribed to event ${eventId} with token ${token}`);
|
package/dist/cjs/package.json
CHANGED
package/dist/cjs/v1-adapter.js
CHANGED
|
@@ -75,7 +75,8 @@ const setupV1Adapter = (guestV2 = null) => {
|
|
|
75
75
|
// eslint-disable-line @typescript-eslint/no-unsafe-assignment
|
|
76
76
|
callback: (event) => callback(event?.obj, event?.eventParams, event?.eventOptions),
|
|
77
77
|
// eslint-disable-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call
|
|
78
|
-
criteria: options?.criteria
|
|
78
|
+
criteria: options?.criteria,
|
|
79
|
+
...options?.filterOnGuest === false ? { filterOnGuest: false } : {}
|
|
79
80
|
});
|
|
80
81
|
},
|
|
81
82
|
unsubscribe: (objectId, eventName, token) => {
|
package/dist/esm/guest.js
CHANGED
|
@@ -412,7 +412,8 @@ class SSFGuest {
|
|
|
412
412
|
{
|
|
413
413
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
414
414
|
callback: window[body.eventHandler],
|
|
415
|
-
token: uuidv4()
|
|
415
|
+
token: uuidv4(),
|
|
416
|
+
eventId
|
|
416
417
|
}
|
|
417
418
|
];
|
|
418
419
|
} else {
|
|
@@ -421,7 +422,7 @@ class SSFGuest {
|
|
|
421
422
|
const promises = [];
|
|
422
423
|
listeners.forEach((callbackInfo) => {
|
|
423
424
|
if (callbackInfo?.callback) {
|
|
424
|
-
if (callbackInfo.criteria) {
|
|
425
|
+
if (callbackInfo.criteria && callbackInfo.filterOnGuest !== false) {
|
|
425
426
|
const criteriaMatched = body.eventParams ? this.#matchesCriteria(body.eventParams, callbackInfo.criteria) : false;
|
|
426
427
|
if (!criteriaMatched) {
|
|
427
428
|
this.#logger.debug(
|
|
@@ -603,22 +604,59 @@ class SSFGuest {
|
|
|
603
604
|
});
|
|
604
605
|
}
|
|
605
606
|
};
|
|
607
|
+
/**
|
|
608
|
+
* Notifies the host to drop every active guest event subscription and clears
|
|
609
|
+
* local listener state. Best-effort when host references are unavailable.
|
|
610
|
+
*/
|
|
611
|
+
#unsubscribeAllEventListeners = () => {
|
|
612
|
+
const hostWindow = this.#hostWindow;
|
|
613
|
+
const hostOrigin = this.#hostOrigin;
|
|
614
|
+
try {
|
|
615
|
+
if (hostWindow && hostOrigin) {
|
|
616
|
+
this.#eventListeners.forEach((listeners) => {
|
|
617
|
+
listeners.forEach(({ token, eventId }) => {
|
|
618
|
+
try {
|
|
619
|
+
this.#remoting.send({
|
|
620
|
+
targetWin: hostWindow,
|
|
621
|
+
targetOrigin: hostOrigin,
|
|
622
|
+
messageType: MessageType.GuestEventUnsubscribe,
|
|
623
|
+
messageBody: { eventId, token }
|
|
624
|
+
});
|
|
625
|
+
} catch (error) {
|
|
626
|
+
this.#logger.debug(
|
|
627
|
+
`Failed to notify host of unsubscribe for ${eventId}: ${error.message}`
|
|
628
|
+
);
|
|
629
|
+
}
|
|
630
|
+
});
|
|
631
|
+
});
|
|
632
|
+
}
|
|
633
|
+
} finally {
|
|
634
|
+
this.#eventListeners.clear();
|
|
635
|
+
}
|
|
636
|
+
};
|
|
606
637
|
/**
|
|
607
638
|
* Close the connection to the host
|
|
608
639
|
*/
|
|
609
640
|
close = async () => {
|
|
610
641
|
if (!this.#isConnected) return;
|
|
642
|
+
this.#unsubscribeAllEventListeners();
|
|
611
643
|
if (this.#hostWindow && this.#hostOrigin) {
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
644
|
+
try {
|
|
645
|
+
this.#remoting.send({
|
|
646
|
+
targetWin: this.#hostWindow,
|
|
647
|
+
targetOrigin: this.#hostOrigin,
|
|
648
|
+
messageType: MessageType.GuestClose,
|
|
649
|
+
messageBody: {}
|
|
650
|
+
});
|
|
651
|
+
this.#remoting.removeSender({
|
|
652
|
+
origin: this.#hostOrigin,
|
|
653
|
+
window: this.#hostWindow
|
|
654
|
+
});
|
|
655
|
+
} catch (error) {
|
|
656
|
+
this.#logger.debug(
|
|
657
|
+
`Failed to notify host of guest close: ${error.message}`
|
|
658
|
+
);
|
|
659
|
+
}
|
|
622
660
|
}
|
|
623
661
|
this.#remoting.close();
|
|
624
662
|
if (this.#parentCloseMonitor) {
|
|
@@ -794,11 +832,15 @@ class SSFGuest {
|
|
|
794
832
|
* @returns {string} subscription token
|
|
795
833
|
*/
|
|
796
834
|
subscribe = (param) => {
|
|
797
|
-
const { eventId, criteria, callback } = param;
|
|
835
|
+
const { eventId, criteria, callback, filterOnGuest } = param;
|
|
798
836
|
this.#logger.debug(`Registering subscription for event ${eventId}`);
|
|
799
837
|
const listeners = this.#eventListeners.get(eventId.toLowerCase()) || [];
|
|
800
838
|
const token = uuidv4();
|
|
801
|
-
|
|
839
|
+
const listenerInfo = { callback, token, criteria, eventId };
|
|
840
|
+
if (filterOnGuest === false) {
|
|
841
|
+
listenerInfo.filterOnGuest = false;
|
|
842
|
+
}
|
|
843
|
+
listeners.push(listenerInfo);
|
|
802
844
|
this.#eventListeners.set(eventId.toLowerCase(), listeners);
|
|
803
845
|
const { hostWindow, hostOrigin } = this.#requireHost();
|
|
804
846
|
this.#remoting.send({
|
|
@@ -808,7 +850,8 @@ class SSFGuest {
|
|
|
808
850
|
messageBody: {
|
|
809
851
|
eventId,
|
|
810
852
|
criteria,
|
|
811
|
-
token
|
|
853
|
+
token,
|
|
854
|
+
...filterOnGuest === false ? { filterOnGuest: false } : {}
|
|
812
855
|
}
|
|
813
856
|
});
|
|
814
857
|
this.#logger.debug(`Subscribed to event ${eventId} with token ${token}`);
|
package/dist/esm/package.json
CHANGED
package/dist/esm/v1-adapter.js
CHANGED
|
@@ -51,7 +51,8 @@ const setupV1Adapter = (guestV2 = null) => {
|
|
|
51
51
|
// eslint-disable-line @typescript-eslint/no-unsafe-assignment
|
|
52
52
|
callback: (event) => callback(event?.obj, event?.eventParams, event?.eventOptions),
|
|
53
53
|
// eslint-disable-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call
|
|
54
|
-
criteria: options?.criteria
|
|
54
|
+
criteria: options?.criteria,
|
|
55
|
+
...options?.filterOnGuest === false ? { filterOnGuest: false } : {}
|
|
55
56
|
});
|
|
56
57
|
},
|
|
57
58
|
unsubscribe: (objectId, eventName, token) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<!doctype html><html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><title>Grandchild Guest (C)</title><script src="https://cdn.tailwindcss.com?plugins=forms"></script><script src="https://cdn.mortgagetech.q1.ice.com/pui-diagnostics@3"></script><script defer="defer" src="js/emuiSsfGuest.
|
|
1
|
+
<!doctype html><html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><title>Grandchild Guest (C)</title><script src="https://cdn.tailwindcss.com?plugins=forms"></script><script src="https://cdn.mortgagetech.q1.ice.com/pui-diagnostics@3"></script><script defer="defer" src="js/emuiSsfGuest.3b53f24a26401c08b1cd.js"></script></head><body class="bg-green-50 p-2"><h3 class="text-sm font-semibold text-green-800 mb-2">Grandchild Guest (C)</h3><div class="flex flex-wrap gap-2 mb-2"><button data-testid="btn-get-caller-info" id="btnGetCallerInfo" disabled="disabled" class="rounded bg-green-600 px-3 py-1 text-xs text-white hover:bg-green-700 disabled:opacity-50 disabled:cursor-not-allowed">Call getCallerInfo()</button> <button data-testid="btn-ping" id="btnPing" disabled="disabled" class="rounded bg-green-600 px-3 py-1 text-xs text-white hover:bg-green-700 disabled:opacity-50 disabled:cursor-not-allowed">Call ping("hello from C")</button> <button data-testid="btn-get-loan" id="btnGetLoan" disabled="disabled" class="rounded bg-green-600 px-3 py-1 text-xs text-white hover:bg-green-700 disabled:opacity-50 disabled:cursor-not-allowed">Call getLoanDetails()</button></div><div data-testid="grandchild-status" id="status" class="text-xs bg-green-100 rounded p-2 mb-2 min-h-[20px]">Connecting...</div><div data-testid="grandchild-result" id="result" class="text-xs bg-white rounded p-2 min-h-[40px]"><pre id="resultPre" class="whitespace-pre-wrap">No results yet</pre></div><script src="./callchain-grandchild.js" type="module"></script></body></html>
|
|
@@ -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.mortgagetech.q1.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.
|
|
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.mortgagetech.q1.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.3b53f24a26401c08b1cd.js"></script></head><body></body></html>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<!doctype html><html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><title>SSF E2E Guest</title><script src="https://cdn.tailwindcss.com?plugins=forms"></script><script src="https://cdn.mortgagetech.q1.ice.com/pui-diagnostics@3"></script><script defer="defer" src="js/emuiSsfGuest.
|
|
1
|
+
<!doctype html><html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><title>SSF E2E Guest</title><script src="https://cdn.tailwindcss.com?plugins=forms"></script><script src="https://cdn.mortgagetech.q1.ice.com/pui-diagnostics@3"></script><script defer="defer" src="js/emuiSsfGuest.3b53f24a26401c08b1cd.js"></script></head><body class="bg-emerald-50 p-2 text-xs"><div class="flex items-center justify-between mb-1"><h3 class="font-semibold text-emerald-800">E2E Guest</h3><span data-testid="guest-connection-status" id="connStatus" class="px-2 py-0.5 rounded text-white bg-gray-400">disconnected</span></div><div data-testid="guest-info" id="guestInfo" class="bg-emerald-100 rounded p-1 mb-1 text-xs text-emerald-700">Params: <span id="searchParams">—</span></div><details class="bg-emerald-100 rounded p-1 mb-1 text-[10px] text-emerald-700"><summary class="font-semibold cursor-pointer">Quick Guide (click to expand)</summary><ul class="mt-1 list-disc list-inside space-y-0.5"><li><strong>Objects tab:</strong> Use <code>getObject()</code> to fetch a scripting object, then <code>Invoke</code> to call a method. Result + errors appear below.</li><li><strong>Events tab:</strong> Subscribe to events (with or without criteria). When the host dispatches, received events appear below. Use the Feedback dropdown to control what the callback returns.</li><li><strong>Lifecycle tab:</strong> Change log level or disconnect/reconnect. Status badge at top right should reflect the state.</li><li><strong>Verify:</strong> Connection badge = <span class="text-green-700 font-bold">connected</span>. After getObject: methods are listed. After invoke: result appears. After subscribe+dispatch: events appear.</li></ul></details><div class="flex gap-1 mb-2 border-b border-emerald-300"><button data-testid="tab-objects" class="tab-btn px-2 py-1 rounded-t font-medium bg-emerald-200 text-emerald-800" data-tab="objects">Objects</button> <button data-testid="tab-events" class="tab-btn px-2 py-1 rounded-t text-emerald-600" data-tab="events">Events</button> <button data-testid="tab-lifecycle" class="tab-btn px-2 py-1 rounded-t text-emerald-600" data-tab="lifecycle">Lifecycle</button></div><div id="panel-objects" class="tab-panel"><div class="space-y-1"><button data-testid="btn-list-objects" id="btnListObjects" class="rounded bg-emerald-600 px-2 py-1 text-white hover:bg-emerald-700">listObjects()</button><div data-testid="objects-list" id="objectsList" class="bg-white rounded p-1 min-h-[20px]">—</div><div class="flex gap-1 items-center"><input data-testid="input-object-id" id="inputObjectId" value="Loan" class="rounded border-emerald-300 px-2 py-0.5 text-xs flex-1" placeholder="Object ID"/> <button data-testid="btn-get-object" id="btnGetObject" class="rounded bg-emerald-600 px-2 py-1 text-white hover:bg-emerald-700">getObject()</button></div><div data-testid="current-object" id="currentObject" class="bg-white rounded p-1 min-h-[20px]">—</div><div class="flex gap-1 items-center"><input data-testid="input-method" id="inputMethod" value="getLoanDetails" class="rounded border-emerald-300 px-2 py-0.5 text-xs flex-1" placeholder="Method name"/> <input data-testid="input-args" id="inputArgs" class="rounded border-emerald-300 px-2 py-0.5 text-xs w-24" placeholder="Args (JSON)"/> <button data-testid="btn-invoke" id="btnInvoke" class="rounded bg-emerald-600 px-2 py-1 text-white hover:bg-emerald-700">Invoke</button></div><div class="flex gap-1"><button data-testid="btn-invoke-error" id="btnInvokeError" class="rounded bg-red-500 px-2 py-1 text-white hover:bg-red-600">TC-SO-08: Call throwError()</button> <button data-testid="btn-invoke-async" id="btnInvokeAsync" class="rounded bg-blue-500 px-2 py-1 text-white hover:bg-blue-600">TC-SO-07: Call asyncMethod(200)</button></div><div data-testid="invoke-result" id="invokeResult" class="bg-white rounded p-1 min-h-[30px] whitespace-pre-wrap">—</div></div></div><div id="panel-events" class="tab-panel hidden"><div class="space-y-1"><div class="flex gap-1 items-center"><input data-testid="input-event-id" id="inputEventId" value="Loan.onPreSave" class="rounded border-emerald-300 px-2 py-0.5 text-xs flex-1" placeholder="Event ID"/> <button data-testid="btn-subscribe" id="btnSubscribe" class="rounded bg-purple-600 px-2 py-1 text-white hover:bg-purple-700">Subscribe</button></div><div class="flex gap-1 items-center"><input data-testid="input-criteria" id="inputCriteria" class="rounded border-emerald-300 px-2 py-0.5 text-xs flex-1" placeholder='Criteria JSON e.g. {"amount":{"gt":100000}}'/> <button data-testid="btn-subscribe-criteria" id="btnSubscribeCriteria" class="rounded bg-purple-600 px-2 py-1 text-white hover:bg-purple-700">Subscribe+Criteria</button></div><div class="flex gap-1 items-center"><select data-testid="select-unsub-token" id="selectUnsubToken" class="rounded border-emerald-300 px-2 py-0.5 text-xs flex-1"><option value="">— select token —</option></select> <button data-testid="btn-unsubscribe" id="btnUnsubscribe" class="rounded bg-yellow-600 px-2 py-1 text-white hover:bg-yellow-700">Unsubscribe</button></div><h4 class="font-medium text-emerald-700 mt-1">Active Subscriptions</h4><div data-testid="subscriptions-list" id="subscriptionsList" class="bg-white rounded p-1 min-h-[20px]">—</div><h4 class="font-medium text-emerald-700 mt-1">Received Events</h4><div data-testid="events-received" id="eventsReceived" class="bg-white rounded p-1 min-h-[40px] max-h-[120px] overflow-y-auto">—</div><h4 class="font-medium text-emerald-700 mt-1">Feedback Return Value</h4><div class="flex gap-1 items-center"><select data-testid="select-feedback" id="selectFeedback" class="rounded border-emerald-300 px-2 py-0.5 text-xs flex-1"><option value="true">return true (approve)</option><option value="false">return false (reject)</option><option value="object">return {status: "ok"}</option></select></div></div></div><div id="panel-lifecycle" class="tab-panel hidden"><div class="space-y-1"><button data-testid="btn-set-loglevel-0" id="btnLogLevel0" class="rounded bg-gray-600 px-2 py-1 text-white hover:bg-gray-700">setLogLevel(0) — Silent</button> <button data-testid="btn-set-loglevel-10" id="btnLogLevel10" class="rounded bg-gray-600 px-2 py-1 text-white hover:bg-gray-700">setLogLevel(10) — Debug</button> <button data-testid="btn-disconnect" id="btnDisconnect" class="rounded bg-red-600 px-2 py-1 text-white hover:bg-red-700">close() — Disconnect</button><p class="text-[10px] text-gray-400">Expected: status badge → "disconnected", further calls fail</p><button data-testid="btn-reconnect" id="btnReconnect" class="rounded bg-emerald-600 px-2 py-1 text-white hover:bg-emerald-700">connect() — Reconnect</button><p class="text-[10px] text-gray-400">Expected: status badge → "connected", calls work again</p></div></div><div class="mt-2"><h4 class="font-medium text-emerald-700">Guest Log</h4><div data-testid="guest-log" id="guestLog" class="bg-white rounded p-1 text-xs min-h-[40px] max-h-[100px] overflow-y-auto font-mono"></div></div><script src="./e2e-guest.js" type="module"></script></body></html>
|
package/dist/public/index.html
CHANGED
|
@@ -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.
|
|
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.3b53f24a26401c08b1cd.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>
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
(function(M,R){typeof exports=="object"&&typeof module=="object"?module.exports=R(require("emuiDiagnostics")):typeof define=="function"&&define.amd?define(["emuiDiagnostics"],R):typeof exports=="object"?exports.ice=R(require("emuiDiagnostics")):(M.ice=M.ice||{},M.ice.guest=R(M.emuiDiagnostics))})(globalThis,J=>(()=>{var M={759(o,l,c){var u=c(907),d=u.Symbol;o.exports=d},490(o,l,c){var u=c(759),d=c(817),O=c(748),h="[object Null]",p="[object Undefined]",L=u?u.toStringTag:void 0;function y(T){return T==null?T===void 0?p:h:L&&L in Object(T)?d(T):O(T)}o.exports=y},6(o,l,c){var u=c(82),d=/^\s+/;function O(h){return h&&h.slice(0,u(h)+1).replace(d,"")}o.exports=O},710(o){var l=typeof globalThis=="object"&&globalThis&&globalThis.Object===Object&&globalThis;o.exports=l},817(o,l,c){var u=c(759),d=Object.prototype,O=d.hasOwnProperty,h=d.toString,p=u?u.toStringTag:void 0;function L(y){var T=O.call(y,p),b=y[p];try{y[p]=void 0;var f=!0}catch{}var k=h.call(y);return f&&(T?y[p]=b:delete y[p]),k}o.exports=L},748(o){var l=Object.prototype,c=l.toString;function u(d){return c.call(d)}o.exports=u},907(o,l,c){var u=c(710),d=typeof self=="object"&&self&&self.Object===Object&&self,O=u||d||Function("return this")();o.exports=O},82(o){var l=/\s/;function c(u){for(var d=u.length;d--&&l.test(u.charAt(d)););return d}o.exports=c},671(o,l,c){var u=c(323),d=c(62),O=c(480),h="Expected a function",p=Math.max,L=Math.min;function y(T,b,f){var k,_,U,C,j,$,A=0,E=!1,G=!1,F=!0;if(typeof T!="function")throw new TypeError(h);b=O(b)||0,u(f)&&(E=!!f.leading,G="maxWait"in f,U=G?p(O(f.maxWait)||0,b):U,F="trailing"in f?!!f.trailing:F);function H(w){var I=k,P=_;return k=_=void 0,A=w,C=T.apply(P,I),C}function z(w){return A=w,j=setTimeout(W,b),E?H(w):C}function K(w){var I=w-$,P=w-A,D=b-I;return G?L(D,U-P):D}function Y(w){var I=w-$,P=w-A;return $===void 0||I>=b||I<0||G&&P>=U}function W(){var w=d();if(Y(w))return B(w);j=setTimeout(W,K(w))}function B(w){return j=void 0,F&&k?H(w):(k=_=void 0,C)}function ee(){j!==void 0&&clearTimeout(j),A=0,k=$=_=j=void 0}function X(){return j===void 0?C:B(d())}function N(){var w=d(),I=Y(w);if(k=arguments,_=this,$=w,I){if(j===void 0)return z($);if(G)return clearTimeout(j),j=setTimeout(W,b),H($)}return j===void 0&&(j=setTimeout(W,b)),C}return N.cancel=ee,N.flush=X,N}o.exports=y},323(o){function l(c){var u=typeof c;return c!=null&&(u=="object"||u=="function")}o.exports=l},292(o){function l(c){return c!=null&&typeof c=="object"}o.exports=l},964(o,l,c){var u=c(490),d=c(292),O="[object Symbol]";function h(p){return typeof p=="symbol"||d(p)&&u(p)==O}o.exports=h},62(o,l,c){var u=c(907),d=function(){return u.Date.now()};o.exports=d},712(o,l,c){var u=c(671),d=c(323),O="Expected a function";function h(p,L,y){var T=!0,b=!0;if(typeof p!="function")throw new TypeError(O);return d(y)&&(T="leading"in y?!!y.leading:T,b="trailing"in y?!!y.trailing:b),u(p,L,{leading:T,maxWait:L,trailing:b})}o.exports=h},480(o,l,c){var u=c(6),d=c(323),O=c(964),h=NaN,p=/^[-+]0x[0-9a-f]+$/i,L=/^0b[01]+$/i,y=/^0o[0-7]+$/i,T=parseInt;function b(f){if(typeof f=="number")return f;if(O(f))return h;if(d(f)){var k=typeof f.valueOf=="function"?f.valueOf():f;f=d(k)?k+"":k}if(typeof f!="string")return f===0?f:+f;f=u(f);var _=L.test(f);return _||y.test(f)?T(f.slice(2),_?2:8):p.test(f)?h:+f}o.exports=b},388(o){"use strict";o.exports=J}};const R={};function x(o){const l=R[o];if(l!==void 0)return l.exports;const c=R[o]={exports:{}};return M[o](c,c.exports,x),c.exports}x.n=o=>{const l=o&&o.__esModule?()=>o.default:()=>o;return x.d(l,{a:l}),l},x.d=(o,l)=>{if(Array.isArray(l))for(var c=0;c<l.length;){var u=l[c++],d=l[c++];x.o(o,u)?d===0&&c++:d===0?Object.defineProperty(o,u,{enumerable:!0,value:l[c++]}):Object.defineProperty(o,u,{enumerable:!0,get:d})}else for(var u in l)x.o(l,u)&&!x.o(o,u)&&Object.defineProperty(o,u,{enumerable:!0,get:l[u]})},x.o=(o,l)=>Object.hasOwn(o,l),x.r=o=>{Symbol.toStringTag&&Object.defineProperty(o,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(o,"__esModule",{value:!0})};let V={};return(()=>{"use strict";x.r(V),x.d(V,{SSFGuest:()=>be});const l={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};let c;const u=new Uint8Array(16);function d(){if(!c&&(c=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!c))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return c(u)}var O;const h=[];for(let i=0;i<256;++i)h.push((i+256).toString(16).slice(1));function p(i,e=0){return h[i[e+0]]+h[i[e+1]]+h[i[e+2]]+h[i[e+3]]+"-"+h[i[e+4]]+h[i[e+5]]+"-"+h[i[e+6]]+h[i[e+7]]+"-"+h[i[e+8]]+h[i[e+9]]+"-"+h[i[e+10]]+h[i[e+11]]+h[i[e+12]]+h[i[e+13]]+h[i[e+14]]+h[i[e+15]]}function L(i,e=0){const t=p(i,e);if(!O(t))throw TypeError("Stringified UUID is invalid");return t}const y=null;function T(i,e,t){if(l.randomUUID&&!e&&!i)return l.randomUUID();i=i||{};const s=i.random||(i.rng||d)();if(s[6]=s[6]&15|64,s[8]=s[8]&63|128,e){t=t||0;for(let n=0;n<16;++n)e[t+n]=s[n];return e}return p(s)}const b=T;var f=x(712),k=x.n(f);const _="elli:remoting",U="elli:remoting:response",C="elli:remoting:exception",j=({messageType:i,messageBody:e,requestId:t,onewayMsg:s=!1})=>({requestId:t??(s?null:b()),source:_,type:i,body:e}),$=i=>{const{targetWin:e,targetOrigin:t,messageType:s,messageBody:n}=i,r=j({messageType:s,messageBody:n});e.postMessage(r,t)};class A{#s;#e;#t=new Map;#i=new Map;#o=null;#n=null;#r=new Map;constructor(e,t){if(!e)throw new Error("logger is required");if(!t)throw new Error("correlationId is required");this.#s=t,this.#e=e}#p=()=>{this.#o=null;const e=Date.now(),t=[];let s=null;if(this.#i.forEach((n,r)=>{const{requestId:a,cancelTime:g}=n;g&&g<=e?(this.#e.debug(`Detected response timeout for requestId: ${a}...`),t.push(r),n.resolve(void 0)):g&&(s=s===null?g:Math.min(s,g))}),t.forEach(n=>{this.#i.delete(n)}),s!==null){const n=Math.max(s-Date.now(),0);this.#h(n)}};#h=e=>{this.#o===null&&(this.#o=window.setTimeout(this.#p,e))};#b=()=>{this.#o!==null&&(window.clearTimeout(this.#o),this.#o=null)};#c=e=>{const t=this.#i.get(e);return this.#e.debug(`serving requestId: ${e}`),this.#i.delete(e),t};#a=e=>{const{requestId:t}=e;this.#e.debug(`Response received for invocation requestId: ${t}`);const s=this.#c(t);return s?(s.resolve(e.body),!0):(this.#e.debug(`Received response to stale/invalid request with requestId: ${t}`),!1)};#g=e=>{this.#e.debug(`Exception received for invocation (requestId = ${e.requestId})`);const t=this.#c(e.requestId);return t?(t.reject(new Error(e.body)),!0):(this.#e.warn(`Received exception for stale/invalid request (requestId = ${e.requestId})`),!1)};#y=({sourceWin:e,sourceOrigin:t,message:s})=>{this.#e.debug(`Received message of type "${s.type}"`);const n=this.#t.get(s.type);return n?(n.forEach(r=>{this.#e.debug(`Invoking message handler ${r.name}`),r({sourceWin:e,sourceOrigin:t,requestId:s.requestId,type:s.type,body:s.body})}),!0):!1};#l=e=>{if(this.#r.size===0||!e.source)return!1;const t=this.#r.get(e.source);return!t||e?.data?.source!==_?!1:(this.#e.debug(`Remoting: Received message of type "${e.data.type}"`),e.data.type===U?this.#a(e.data):e.data.type===C?this.#g(e.data):this.#y({sourceWin:e.source,sourceOrigin:t,message:e.data}),!0)};addSender=e=>{const{origin:t,window:s}=e;if(!t)throw new Error("origin is required");if(!s)throw new Error("window is required");this.#r.set(s,t)};initialize=e=>{this.#n&&this.#n.removeEventListener("message",this.#l),e.addEventListener("message",this.#l),this.#n=e,this.#e.debug(`initialized remoting id: ${this.#s}`)};close=()=>{this.#n&&(this.#n.removeEventListener("message",this.#l),this.#n=null),this.#b(),this.#i.forEach(({reject:e})=>{e(new Error("Remoting closed"))}),this.#i.clear(),this.#t.clear(),this.#r.clear(),this.#e.debug(`closed remoting id: ${this.#s}`)};invoke=e=>{const{targetWin:t,targetOrigin:s,messageType:n,messageBody:r,responseTimeoutMs:a}=e;return new Promise((g,S)=>{const m=j({messageType:n,messageBody:r});this.#i.set(m.requestId,{requestId:m.requestId,resolve:g,reject:S,cancelTime:a?Date.now()+a:null}),t.postMessage(m,s);const{requestId:v}=m;this.#e.debug(`Posted invocation message of type ${n} requestId: ${v||""}`),a&&(this.#e.debug(`scheduling timeout check for requestId: ${v||""} in ${a} ms`),this.#h(a))})};listen=e=>{const{messageType:t,callback:s}=e,n=this.#t.get(t)||[];n.push(s),this.#t.set(t,n)};unlisten=e=>{const{messageType:t,callback:s}=e,n=this.#t.get(t);if(!n)return;const r=n.indexOf(s);r!==-1&&n.splice(r,1)};send=e=>{const{targetWin:t,targetOrigin:s,messageType:n,messageBody:r}=e,a=j({messageType:n,messageBody:r,onewayMsg:!0});t.postMessage(a,s),this.#e.debug(`Posted one-way message of type "${n}"`)};removeSender=e=>{const{window:t}=e;t&&this.#r.delete(t)};respond=e=>{const{targetWin:t,targetOrigin:s,requestId:n,response:r}=e,a=j({messageType:U,messageBody:r,requestId:n});t.postMessage(a,s),this.#e.debug(`Response sent to caller for invocation requestId: ${n}`)};raiseException=e=>{const{targetWin:t,targetOrigin:s,requestId:n,ex:r}=e,a=r instanceof Error?r.message:r,g=j({messageType:C,messageBody:a,requestId:n});t.postMessage(g,s),this.#e.debug(`Exception sent to caller for invocation. requestId: ${n}`)}}var E=(i=>(i.GuestClose="guest:close",i.GuestEventSubscribe="guest:eventSubscribe",i.GuestEventUnsubscribe="guest:eventUnsubscribe",i.GuestFocus="guest:focus",i.GuestReady="guest:ready",i.GuestReadyComplete="guest:readyComplete",i.GuestResize="guest:resize",i.HandShake="handshake",i.HandShakeAck="handshake:ack",i.HostClose="host:close",i.HostConfig="host:config",i.ListObjects="list:objects",i.ObjectEvent="object:event",i.ObjectGet="object:get",i.ObjectInvoke="object:invoke",i))(E||{});class G{#s;#e;#t;#i=new Map;static DEFAULT_THROTTLE_MS=1e4;constructor(e){this.#s=e.logger,this.#e=e.enabled??!0,this.#t=e.throttleMs??G.DEFAULT_THROTTLE_MS}get enabled(){return this.#e}log(e,t){if(!this.#e){this.#s.debug(t);return}if(this.#t>0){const s=performance.now(),n=this.#i.get(e);if(n!==void 0&&s-n<this.#t){this.#s.debug(t);return}this.#i.set(e,s)}this.#s.audit(t)}}class F{__TYPE__="Proxy";id;objectType;constructor(e,t){this.id=e,this.objectType=t}}const H=i=>i?.constructor?.name==="Proxy"||i?.constructor?.name==="ScriptingObjectProxy"||i?.__TYPE__==="Proxy";class z{name;objectId;id;constructor(e){const{name:t,objectId:s}=e;if(!t)throw new Error("Event name is required");if(!s)throw new Error("Scripting object id is required");this.objectId=s,this.name=t,this.id=`${this.objectId}.${this.name}`.toLowerCase()}}class K{static[Symbol.hasInstance](e){return typeof e=="object"&&e!==null&&"getType"in e&&typeof e.getType=="function"&&e.getType()==="ProxyEvent"}#s;objectId;name;id;getType(){return"ProxyEvent"}constructor(e){const{name:t,objectId:s,eventSrc:n}=e;if(!t)throw new Error("Event name is required");if(!s)throw new Error("Scripting object id is required");if(!n)throw new Error("Event source is required");this.objectId=s,this.name=t,this.#s=n,this.id=`${this.objectId}.${this.name}`.toLowerCase()}subscribe=e=>this.#s.subscribe({eventId:this.id,callback:e});unsubscribe=e=>{this.#s.unsubscribe({eventId:this.id,token:e})}}const Y=i=>i instanceof z,W=(i,e)=>`${i.toLowerCase()}.${e.toLowerCase()}`,B=new Map;function ee(i){return typeof i=="object"&&i!==null&&("eq"in i||"in"in i||"includes"in i||"gt"in i||"lt"in i||"regex"in i)}function X(i,e,t){if("eq"in e)return i===e.eq;if("in"in e)return Array.isArray(e.in)&&e.in.includes(i);if("includes"in e)return Array.isArray(i)&&i.includes(e.includes);if("gt"in e){const s=typeof i=="number"?i:Number(i);return!Number.isNaN(s)&&s>e.gt}if("lt"in e){const s=typeof i=="number"?i:Number(i);return!Number.isNaN(s)&&s<e.lt}if("regex"in e){const s=t??B;let n=s.get(e.regex);if(n===void 0){try{n=new RegExp(e.regex)}catch{n=null}s.set(e.regex,n)}return n!==null&&typeof i=="string"&&n.test(i)}return!1}function N(i){return i!=null&&Object.keys(i).length>0}function w(i,e,t){return Object.entries(e).every(([s,n])=>X(i[s],n,t?.regexCache))}var I=x(388);const P=()=>{const{parent:i}=window;try{return i?.location?.href}catch{return null}},D=i=>{if(!i||i==="about:blank")return"*";try{const{origin:e}=new URL(i);return e==="null"||!e?"*":e}catch{try{const{origin:e}=new URL(i,document.baseURI);return e==="null"||!e?"*":e}catch{return"*"}}},Q=()=>window.self!==window.parent,te=(i,e)=>{const t=e||document.body,s=document.defaultView?.getComputedStyle?.(t,null),n=s?s[i]:"0";return parseInt(n,10)},ae="elli:remoting",se=3e4,le=()=>{try{return new URLSearchParams(window.location.hash.slice(1)).get("hs")}catch{return null}},ue=(i,e)=>!!(window.opener&&i.source===window.opener||e&&i.data?.handshakeToken===e),de=()=>new Promise((i,e)=>{if(Q())i({origin:D(document.referrer||P()),window:window.parent});else{const t=window,s=le();let n;const r=a=>{if(ue(a,s)){const{source:g,type:S}=a.data||{};if(g===ae&&S===E.HandShake){const{origin:m}=a,v=a.source;clearTimeout(n),$({targetWin:v,targetOrigin:m,messageType:E.HandShakeAck,messageBody:{}}),t.removeEventListener("message",r),i({origin:m,window:v})}}};n=setTimeout(()=>{t.removeEventListener("message",r),e(new Error(`Host handshake timed out after ${se}ms`))},se),t.addEventListener("message",r)}});let q=!1;const he=i=>{q=i},ie=(i=null)=>{let e=i;const t=()=>{if(!e&&(e=window.ice?.guest?.SSFGuest?new window.ice.guest.SSFGuest:null,!e))throw new Error("Guest definition not found");return e};window.elli=window.elli??{},window.elli.script={guest:{create:(s,n)=>t().addScript(s,n,{asModule:!1})},connect:s=>t().connect(s),getObject:s=>t().getObject(s),setLogLevel:s=>t().setLogLevel(s),subscribe:(s,n,r,a)=>t().subscribe({eventId:`${s}.${n}`,callback:g=>r(g?.obj,g?.eventParams,g?.eventOptions),criteria:a?.criteria,...a?.filterOnGuest===!1?{filterOnGuest:!1}:{}}),unsubscribe:(s,n,r)=>t().unsubscribe({eventId:`${s}.${n}`,token:r})}};try{ie()}catch{}var ve=null;const ne=12e4,ge=2e3,fe=2e3,me={eventFeedback:!0},re=()=>{const{document:i}=window,e=i.body,t=i.documentElement,n={height:e.offsetHeight+te("marginTop")+te("marginBottom"),width:Math.max(e.scrollWidth,t.scrollWidth)};$({targetWin:window.parent,targetOrigin:D(i.referrer||P()),messageType:E.GuestResize,messageBody:n}),window.removeEventListener("load",re)};Q()&&window.addEventListener("load",re);const oe={"cdn.ice.com":"https://api.elliemae.com/diagnostics/v2/logging","cdn.np.ice.com":"https://stg.api.elliemae.com/diagnostics/v2/logging","cdn.uat.ice.com":"https://concept.api.elliemae.com/diagnostics/v2/logging","cdn.pt1.ice.com":"https://pel1.api.ellielabs.com/diagnostics/v2/logging","cdn.qa1.ice.com":"https://int.api.ellielabs.com/diagnostics/v2/logging","cdn.dev1.ice.com":"https://int.api.ellielabs.com/diagnostics/v2/logging","cdn.mortgagetech.ice.com":"https://api.elliemae.com/diagnostics/v2/logging","cdn.mortgagetech.s1.ice.com":"https://stg.api.elliemae.com/diagnostics/v2/logging","cdn.mortgagetech.uat1.ice.com":"https://concept.api.elliemae.com/diagnostics/v2/logging","cdn.mortgagetech.pl1.ice.com":"https://pel1.api.ellielabs.com/diagnostics/v2/logging","cdn.mortgagetech.q1.ice.com":"https://int.api.ellielabs.com/diagnostics/v2/logging","cdn.mortgagetech.d1.ice.com":"https://int.api.ellielabs.com/diagnostics/v2/logging",localhost:"https://int.api.ellielabs.com/diagnostics/v2/logging"},ce=["click","scroll","keypress","touchstart"],pe=()=>{const i=document.currentScript?.src||"file:///var/opt/jenkins/workspace/UIPlatform_pui-microfe_master/304/libs/ssf-guest/lib/guest.ts",e=i?new URL(i).hostname:"localhost";return oe[e]||oe["cdn.mortgagetech.q1.ice.com"]};class be{#s;#e;#t;#i=!1;#o=null;#n=!1;#r=new Map;#p=null;#h=null;#b=null;#c=null;#a=null;#g=null;#y=new Map;#l(){if(!this.#a||!this.#c)throw new Error("Guest is not connected to a host. Call connect() first.");return{hostWindow:this.#a,hostOrigin:this.#c}}#O(e){let t={...me};if(e){const s={...e};delete s.window,t={...t,...s}}return t}#T(e){const{hostWindow:t,hostOrigin:s}=this.#l();this.#t.send({targetWin:t,targetOrigin:s,messageType:E.GuestReady,messageBody:e})}#j=!1;#u=null;#f=null;#w=null;#S=!0;#x=ne;#k;#v=null;#m;constructor(e){const{console:t=!1,url:s=window.__ICE__?.diagnosticsUrl||pe(),index:n="ssf-guest-v2",team:r="ICE",appName:a="SSF Guest V2 Application"}=e?.logger??{};this.#k=e?.logger,this.#j=e?.usesDevConnectAPI??!1,this.#S=e?.keepAlive??!0,this.#x=e?.keepAliveInterval??ne;const g=t?(0,I.Console)():(0,I.http)(s);this.#e=e?.appLogger??(0,I.logger)({transport:g,index:n,team:r,appName:a}),this.#m=new G({logger:this.#e,enabled:e?.auditOperations,throttleMs:e?.auditThrottleMs}),(0,I.webvitals)(this.#e),(0,I.logUnhandledErrors)(this.#e),this.#s=b(),this.#t=new A(this.#e,this.#s),ie(this),this.#e.audit({message:"Guest created",guestUrl:window.location.href,correlationId:this.#s})}#d=()=>({guestId:this.#p,guestTitle:this.#h,guestUrl:this.#b});#E=e=>{if(!e||!e.objectId)throw this.#e.error("Deserialization of scripting object failed. Object does not have an Object ID."),new Error("Cannot deserialize object JSON into proxy.");const t=new F(e.objectId,e.objectType);return e.functions&&e.functions.forEach(s=>{Object.defineProperty(t,s,{value:async(...n)=>{const a=t[s]?.callContext?.callChain;return this.#I({objectId:t.id,functionName:s,functionParams:[...n],callerChain:a})},enumerable:!0})}),e.events&&e.events.forEach(s=>{Object.defineProperty(t,s,{value:new K({objectId:t.id,name:s,eventSrc:this}),enumerable:!0})}),this.#e.debug(`Created guest proxy for scripting object (id = "${t.id}")`),t};#I=async({objectId:e,functionName:t,functionParams:s,callerChain:n})=>{this.#e.debug(`Invoking scripting object method ${e}.${t}()...`);const r=[];if(s)for(let v=0;v<s.length;v+=1){const Z=s[v];Z instanceof Promise&&r.push(Z.then(we=>{s[v]=we}))}await Promise.all(r);const{hostWindow:a,hostOrigin:g}=this.#l(),S=await this.#t.invoke({targetWin:a,targetOrigin:g,messageType:E.ObjectInvoke,messageBody:{objectId:e,functionName:t,functionParams:s,...n?.length?{callerChain:n}:{}}}),m=this.#_(S);return this.#m.log(`invoke:${e}.${t}`,{message:"Guest proxy invoked Scripting Object method",scriptingObject:e,scriptingMethod:t,...this.#d()}),m};#L(e,t){return w(e,t,{regexCache:this.#y})}#_=e=>e?.type==="object"&&"object"in e?this.#E(e.object):e?.type==="value"?e.value:e;#$=({body:e})=>{e?.logLevel&&(this.#e.setLogLevel(e.logLevel),this.#e.debug(`Log level changed by host to ${e.logLevel}`)),this.#p=e?.guestId??null,this.#h=e?.guestTitle??null,this.#b=e?.guestUrl??null,this.#e.audit({message:"Received configuration from Host",...this.#d()})};#C=()=>{window.focus()};#G=async()=>{await this.close(),window.close()};#P=()=>{Q()||(this.#g=setInterval(()=>{this.#a?.closed&&this.close().then(()=>{window.close()}).catch(()=>{})},1e3))};#R=async({sourceWin:e,sourceOrigin:t,requestId:s,body:n})=>{const r=this.#E(n.object);if(r){const a=W(r.id,n.eventName);this.#e.debug(`Received event "${a}" from host`);let g;n.eventHandler?g=[{callback:window[n.eventHandler],token:b(),eventId:a}]:g=this.#r.get(a)||[];const S=[];if(g.forEach(m=>{if(m?.callback){if(m.criteria&&m.filterOnGuest!==!1&&!(n.eventParams?this.#L(n.eventParams,m.criteria):!1)){this.#e.debug(`Event ${a} did not match criteria for subscriber ${m.callback.name}`);return}this.#e.debug(`Invoking event subscriber ${m.callback.name} for event ${a}`);const v=m.callback({obj:r,eventName:n.eventName,eventParams:n.eventParams,eventOptions:n.eventOptions});v instanceof Promise?S.push(v):typeof v<"u"&&S.push(Promise.resolve(v))}}),s){const m=await Promise.all(S);this.#t.respond({targetWin:e,targetOrigin:t,requestId:s,response:m}),this.#m.log(`event:${a}`,{message:"Guest proxy processed event from host and responded",scriptingEventId:a,scriptingObject:r.id,...this.#d()})}else this.#m.log(`event:${a}`,{message:"Guest proxy processed event from host",scriptingEventId:a,scriptingObject:r.id,...this.#d()})}};#U=async()=>{if(!(!this.#u||!this.#f||!this.#w))try{await fetch(`${this.#w}/oauth2/v1/token/introspection?${new URLSearchParams({token:this.#u,client_id:this.#f}).toString()}`,{headers:{"content-type":"application/x-www-form-urlencoded;charset=UTF-8"},method:"POST"})}catch(e){this.#e.warn(`Failed to extend token lifetime: ${e.message}`)}};#A=async()=>{if(this.#u&&this.#f&&this.#w)try{await fetch(`${this.#w}/oauth2/v1/token/revocation?${new URLSearchParams({token:this.#u,client_id:this.#f}).toString()}`,{method:"POST"})}catch(e){this.#e.error(`Error revoking token. ${e.message}`)}finally{this.#u=null,this.#f=null}};#M=async()=>{if(this.#S)try{const e=await Promise.race([this.getObject("application"),new Promise(t=>{setTimeout(()=>t(null),ge)})]);e?(this.#v=k()(async()=>{try{await e.keepSessionAlive(),await this.#U()}catch(t){this.#e.error(`Error keeping session alive. ${t.message}`)}},this.#x,{leading:!1}),ce.forEach(t=>{document.addEventListener(t,this.#v)})):this.#e.warn("Application object not available to send keep alive")}catch(e){this.#e.error(`Error getting application object. ${e.message}`)}};addScript=async(e,t,s={})=>{const{asModule:n=!0}=s;if(!this.#i&&e){await this.connect();const r=document.createElement("script");r.setAttribute("src",e),n&&r.setAttribute("type","module"),await new Promise((a,g)=>{let S,m;const v=()=>{r.removeEventListener("load",S),r.removeEventListener("error",m)};S=()=>{v(),this.#i=!0,he(!0),a()},m=()=>{v(),g(new Error(`Failed to load script: ${e}`))},r.addEventListener("load",S),r.addEventListener("error",m),this.#o=t.appendChild(r)})}};#W=()=>{const e=this.#a,t=this.#c;try{e&&t&&this.#r.forEach(s=>{s.forEach(({token:n,eventId:r})=>{try{this.#t.send({targetWin:e,targetOrigin:t,messageType:E.GuestEventUnsubscribe,messageBody:{eventId:r,token:n}})}catch(a){this.#e.debug(`Failed to notify host of unsubscribe for ${r}: ${a.message}`)}})})}finally{this.#r.clear()}};close=async()=>{if(this.#n){if(this.#W(),this.#a&&this.#c)try{this.#t.send({targetWin:this.#a,targetOrigin:this.#c,messageType:E.GuestClose,messageBody:{}}),this.#t.removeSender({origin:this.#c,window:this.#a})}catch(e){this.#e.debug(`Failed to notify host of guest close: ${e.message}`)}this.#t.close(),this.#g&&(clearInterval(this.#g),this.#g=null),this.#v&&ce.forEach(e=>{document.removeEventListener(e,this.#v)}),await this.#A(),window.removeEventListener("beforeunload",this.close),this.#n=!1,this.#e.audit({message:"Guest disconnected from host",...this.#d()}),this.#p=null,this.#b=null,this.#h=null}};connect=async e=>{if(this.#n){this.#T(this.#O(e));return}let t=window;e?.window&&(t=e.window);const s=this.#O(e),n=await de();this.#c=n.origin,this.#a=n.window,this.#t.initialize(t),this.#t.addSender({origin:this.#c,window:this.#a}),this.#t.listen({messageType:E.ObjectEvent,callback:this.#R.bind(this)}),this.#t.listen({messageType:E.HostConfig,callback:this.#$.bind(this)}),this.#t.listen({messageType:E.GuestFocus,callback:this.#C.bind(this)}),this.#t.listen({messageType:E.HostClose,callback:this.#G.bind(this)}),this.#T(s),this.#n=!0,this.#P(),this.#j&&await this.getAuthToken(),await this.#M(),window.addEventListener("beforeunload",this.close),this.#e.audit({message:"Guest connected to host",guestUrl:window.location.href})};getAuthToken=async()=>{if(!this.#u&&this.#n)try{const e=await this.getObject("auth");if(e){const t=await e.getAccessToken();this.#u=t?.access_token,this.#w=t?.host_name,this.#f=t?.client_id}else this.#e.warn("Auth object not available to get access token from host")}catch(e){this.#e.error(`Error getting access token from auth object. ${e.message}`)}return this.#u};getObject=async e=>{if(this.#e.debug(`Retrieving scripting object "${e}" from host...`),!this.#n)throw new Error("Not connected to host");const{hostWindow:t,hostOrigin:s}=this.#l(),n=await this.#t.invoke({targetWin:t,targetOrigin:s,messageType:E.ObjectGet,messageBody:{objectId:e},responseTimeoutMs:fe});if(!n?.object)throw new Error(`The requested object (${e}) is not available`);const r=this.#E(n.object);return this.#m.log(`getObject:${e}`,{message:"Received scripting object from host",scriptingObject:e,...this.#d()}),r};listObjects=async()=>{if(this.#e.debug("Retrieving names of scripting objects exposed by host..."),!this.#n)throw new Error("Not connected to host");const{hostWindow:e,hostOrigin:t}=this.#l(),s=await this.#t.invoke({targetWin:e,targetOrigin:t,messageType:E.ListObjects,messageBody:{}});return this.#m.log("listObjects",{message:"Received names of all scripting objects exposed by host",objects:s,...this.#d()}),s};removeScript=()=>{if(this.#i&&this.#o){const{parentNode:e}=this.#o;e?.removeChild?.(this.#o)}};setLogLevel=e=>{this.#e.setLogLevel(e),this.#e.debug(`Log level changed by guest to ${e}`)};subscribe=e=>{const{eventId:t,criteria:s,callback:n,filterOnGuest:r}=e;this.#e.debug(`Registering subscription for event ${t}`);const a=this.#r.get(t.toLowerCase())||[],g=b(),S={callback:n,token:g,criteria:s,eventId:t};r===!1&&(S.filterOnGuest=!1),a.push(S),this.#r.set(t.toLowerCase(),a);const{hostWindow:m,hostOrigin:v}=this.#l();return this.#t.send({targetWin:m,targetOrigin:v,messageType:E.GuestEventSubscribe,messageBody:{eventId:t,criteria:s,token:g,...r===!1?{filterOnGuest:!1}:{}}}),this.#e.debug(`Subscribed to event ${t} with token ${g}`),g};unsubscribe=e=>{const{eventId:t,token:s}=e,n=this.#r.get(t.toLowerCase());if(n){const r=n.length,a=n.filter(g=>g.token!==s);if(a.length<r){this.#r.set(t.toLowerCase(),a);const{hostWindow:g,hostOrigin:S}=this.#l();this.#t.send({targetWin:g,targetOrigin:S,messageType:E.GuestEventUnsubscribe,messageBody:{eventId:t,token:s}}),this.#e.debug(`Unsubscribed from event ${t}`)}}}}})(),V})());
|
|
2
|
+
|
|
3
|
+
//# sourceMappingURL=emuiSsfGuest.3b53f24a26401c08b1cd.js.map
|
|
Binary file
|
|
Binary file
|