@elliemae/ssf-guest 2.21.4 → 2.23.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/creditService.html +1 -1
- package/dist/cjs/guest.js +98 -74
- package/dist/cjs/loanValidation.html +1 -1
- package/dist/cjs/pricingService.html +1 -1
- package/dist/cjs/titleService.html +1 -1
- package/dist/cjs/utils.js +24 -14
- package/dist/cjs/v1-adapter.js +11 -7
- package/dist/cjs/v2-guest.html +1 -1
- package/dist/esm/creditService.html +1 -1
- package/dist/esm/guest.js +87 -74
- package/dist/esm/loanValidation.html +1 -1
- package/dist/esm/pricingService.html +1 -1
- package/dist/esm/titleService.html +1 -1
- package/dist/esm/utils.js +24 -14
- package/dist/esm/v1-adapter.js +11 -7
- package/dist/esm/v2-guest.html +1 -1
- package/dist/public/businessObjects.js.map +1 -1
- package/dist/public/creditScoreService.js.map +1 -1
- package/dist/public/creditService.html +1 -1
- package/dist/public/index.html +1 -1
- package/dist/public/js/emuiSsfGuest.e058aa48d90db357a043.js +3 -0
- package/dist/public/js/emuiSsfGuest.e058aa48d90db357a043.js.br +0 -0
- package/dist/public/js/emuiSsfGuest.e058aa48d90db357a043.js.gz +0 -0
- package/dist/public/js/emuiSsfGuest.e058aa48d90db357a043.js.map +1 -0
- package/dist/public/loanValidation.html +1 -1
- package/dist/public/loanValidation.js.map +1 -1
- package/dist/public/pricingService.html +1 -1
- package/dist/public/pricingService.js +1 -1
- package/dist/public/pricingService.js.br +0 -0
- package/dist/public/pricingService.js.gz +0 -0
- package/dist/public/pricingService.js.map +1 -1
- package/dist/public/titleService.html +1 -1
- package/dist/public/titleService.js.map +1 -1
- package/dist/public/util.js.map +1 -1
- package/dist/public/v2-guest.html +1 -1
- package/dist/types/lib/guest.d.ts +1 -1
- package/dist/types/lib/typings/window.d.ts +4 -3
- package/dist/types/lib/utils.d.ts +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/dist/umd/businessObjects.js.map +1 -1
- package/dist/umd/creditScoreService.js.map +1 -1
- package/dist/umd/creditService.html +1 -1
- package/dist/umd/index.js +1 -27
- 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/dist/umd/loanValidation.html +1 -1
- package/dist/umd/loanValidation.js.map +1 -1
- package/dist/umd/pricingService.html +1 -1
- package/dist/umd/pricingService.js +1 -1
- package/dist/umd/pricingService.js.br +0 -0
- package/dist/umd/pricingService.js.gz +0 -0
- package/dist/umd/pricingService.js.map +1 -1
- package/dist/umd/titleService.html +1 -1
- package/dist/umd/titleService.js.map +1 -1
- package/dist/umd/util.js.map +1 -1
- package/dist/umd/v2-guest.html +1 -1
- package/package.json +18 -19
- package/dist/public/js/emuiSsfGuest.7eac030a329ee1e7f98f.js +0 -29
- package/dist/public/js/emuiSsfGuest.7eac030a329ee1e7f98f.js.br +0 -0
- package/dist/public/js/emuiSsfGuest.7eac030a329ee1e7f98f.js.gz +0 -0
- package/dist/public/js/emuiSsfGuest.7eac030a329ee1e7f98f.js.map +0 -1
package/dist/esm/guest.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { v4 as uuidv4 } from "uuid";
|
|
2
|
-
import
|
|
2
|
+
import throttle from "lodash/throttle";
|
|
3
3
|
import {
|
|
4
4
|
Remoting,
|
|
5
5
|
sendMessage,
|
|
@@ -12,7 +12,6 @@ import {
|
|
|
12
12
|
logger as puiLogger,
|
|
13
13
|
Console,
|
|
14
14
|
http,
|
|
15
|
-
parentApp,
|
|
16
15
|
webvitals,
|
|
17
16
|
logUnhandledErrors
|
|
18
17
|
} from "@elliemae/pui-diagnostics";
|
|
@@ -72,7 +71,7 @@ const userInteractionEvents = ["click", "scroll", "keypress", "touchstart"];
|
|
|
72
71
|
const getDiagnosticsAPIUrl = () => {
|
|
73
72
|
const scriptUrl = document.currentScript?.src || import.meta.url;
|
|
74
73
|
const hostName = scriptUrl ? new URL(scriptUrl).hostname : "localhost";
|
|
75
|
-
return diagnosticsEndpoint[hostName] || diagnosticsEndpoint["cdn.
|
|
74
|
+
return diagnosticsEndpoint[hostName] || diagnosticsEndpoint["cdn.mortgagetech.q1.ice.com"];
|
|
76
75
|
};
|
|
77
76
|
class SSFGuest {
|
|
78
77
|
/* eslint-enable indent */
|
|
@@ -88,6 +87,17 @@ class SSFGuest {
|
|
|
88
87
|
#url = null;
|
|
89
88
|
#hostOrigin = null;
|
|
90
89
|
#hostWindow = null;
|
|
90
|
+
#parentCloseMonitor = null;
|
|
91
|
+
#regexCache = /* @__PURE__ */ new Map();
|
|
92
|
+
/** Returns non-null host references or throws a descriptive error. */
|
|
93
|
+
#requireHost() {
|
|
94
|
+
if (!this.#hostWindow || !this.#hostOrigin) {
|
|
95
|
+
throw new Error(
|
|
96
|
+
"Guest is not connected to a host. Call connect() first."
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
return { hostWindow: this.#hostWindow, hostOrigin: this.#hostOrigin };
|
|
100
|
+
}
|
|
91
101
|
/**
|
|
92
102
|
* get bearer token to access api during connect operation
|
|
93
103
|
*/
|
|
@@ -180,7 +190,8 @@ class SSFGuest {
|
|
|
180
190
|
value: async (...args) => this.#invoke({
|
|
181
191
|
objectId: ctrl.id,
|
|
182
192
|
functionName,
|
|
183
|
-
|
|
193
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
194
|
+
functionParams: [...args]
|
|
184
195
|
}),
|
|
185
196
|
enumerable: true
|
|
186
197
|
});
|
|
@@ -233,9 +244,10 @@ class SSFGuest {
|
|
|
233
244
|
}
|
|
234
245
|
}
|
|
235
246
|
await Promise.all(promises);
|
|
247
|
+
const { hostWindow, hostOrigin } = this.#requireHost();
|
|
236
248
|
const response = await this.#remoting.invoke({
|
|
237
|
-
targetWin:
|
|
238
|
-
targetOrigin:
|
|
249
|
+
targetWin: hostWindow,
|
|
250
|
+
targetOrigin: hostOrigin,
|
|
239
251
|
messageType: MessageType.ObjectInvoke,
|
|
240
252
|
messageBody: {
|
|
241
253
|
objectId,
|
|
@@ -285,7 +297,11 @@ class SSFGuest {
|
|
|
285
297
|
}
|
|
286
298
|
if ("regex" in condition) {
|
|
287
299
|
try {
|
|
288
|
-
|
|
300
|
+
let regex = this.#regexCache.get(condition.regex);
|
|
301
|
+
if (!regex) {
|
|
302
|
+
regex = new RegExp(condition.regex);
|
|
303
|
+
this.#regexCache.set(condition.regex, regex);
|
|
304
|
+
}
|
|
289
305
|
return typeof value === "string" && regex.test(value);
|
|
290
306
|
} catch {
|
|
291
307
|
return false;
|
|
@@ -344,7 +360,7 @@ class SSFGuest {
|
|
|
344
360
|
*/
|
|
345
361
|
#handleParentClose = () => {
|
|
346
362
|
if (!isEmbedded()) {
|
|
347
|
-
setInterval(() => {
|
|
363
|
+
this.#parentCloseMonitor = setInterval(() => {
|
|
348
364
|
if (this.#hostWindow?.closed) {
|
|
349
365
|
this.close().then(() => {
|
|
350
366
|
window.close();
|
|
@@ -449,18 +465,24 @@ class SSFGuest {
|
|
|
449
465
|
*/
|
|
450
466
|
#extendTokenLifetime = async () => {
|
|
451
467
|
if (!this.#authToken || !this.#authClientId || !this.#hostDomain) return;
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
token
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
468
|
+
try {
|
|
469
|
+
await fetch(
|
|
470
|
+
`${this.#hostDomain}/oauth2/v1/token/introspection?${new URLSearchParams({
|
|
471
|
+
token: this.#authToken,
|
|
472
|
+
client_id: this.#authClientId
|
|
473
|
+
}).toString()}`,
|
|
474
|
+
{
|
|
475
|
+
headers: {
|
|
476
|
+
"content-type": "application/x-www-form-urlencoded;charset=UTF-8"
|
|
477
|
+
},
|
|
478
|
+
method: "POST"
|
|
479
|
+
}
|
|
480
|
+
);
|
|
481
|
+
} catch (e) {
|
|
482
|
+
this.#logger.warn(
|
|
483
|
+
`Failed to extend token lifetime: ${e.message}`
|
|
484
|
+
);
|
|
485
|
+
}
|
|
464
486
|
};
|
|
465
487
|
/**
|
|
466
488
|
* revoke token
|
|
@@ -525,35 +547,6 @@ class SSFGuest {
|
|
|
525
547
|
}
|
|
526
548
|
}
|
|
527
549
|
};
|
|
528
|
-
/**
|
|
529
|
-
* send all log messages to parent
|
|
530
|
-
*/
|
|
531
|
-
#useParentApplicationLogger = async () => {
|
|
532
|
-
try {
|
|
533
|
-
const moduleObj = await this.getObject("module");
|
|
534
|
-
if (moduleObj?.log && !this.#loggerOptions.console) {
|
|
535
|
-
const {
|
|
536
|
-
index = "",
|
|
537
|
-
team = "",
|
|
538
|
-
appName = ""
|
|
539
|
-
} = this.#loggerOptions || {};
|
|
540
|
-
if (!index || !team || !appName)
|
|
541
|
-
throw new Error(
|
|
542
|
-
"Missing one of required logger options: index, team, appName"
|
|
543
|
-
);
|
|
544
|
-
this.#logger = puiLogger({
|
|
545
|
-
transport: parentApp(moduleObj),
|
|
546
|
-
index,
|
|
547
|
-
team,
|
|
548
|
-
appName
|
|
549
|
-
});
|
|
550
|
-
}
|
|
551
|
-
} catch (e) {
|
|
552
|
-
this.#logger.info(
|
|
553
|
-
`Module object not exposed from hosting application. using local logger instance. ${e.message}`
|
|
554
|
-
);
|
|
555
|
-
}
|
|
556
|
-
};
|
|
557
550
|
/**
|
|
558
551
|
* Initialize guest using script
|
|
559
552
|
* @param {string} scriptUri uri of the script
|
|
@@ -565,14 +558,25 @@ class SSFGuest {
|
|
|
565
558
|
const scriptEle = document.createElement("script");
|
|
566
559
|
scriptEle.setAttribute("src", scriptUri);
|
|
567
560
|
scriptEle.setAttribute("type", "module");
|
|
568
|
-
await new Promise((resolve) => {
|
|
569
|
-
|
|
570
|
-
|
|
561
|
+
await new Promise((resolve, reject) => {
|
|
562
|
+
let onScriptLoad;
|
|
563
|
+
let onScriptError;
|
|
564
|
+
const cleanup = () => {
|
|
565
|
+
scriptEle.removeEventListener("load", onScriptLoad);
|
|
566
|
+
scriptEle.removeEventListener("error", onScriptError);
|
|
567
|
+
};
|
|
568
|
+
onScriptLoad = () => {
|
|
569
|
+
cleanup();
|
|
571
570
|
this.#created = true;
|
|
572
571
|
setScriptOnlyGuest(true);
|
|
573
572
|
resolve();
|
|
574
573
|
};
|
|
574
|
+
onScriptError = () => {
|
|
575
|
+
cleanup();
|
|
576
|
+
reject(new Error(`Failed to load script: ${scriptUri}`));
|
|
577
|
+
};
|
|
575
578
|
scriptEle.addEventListener("load", onScriptLoad);
|
|
579
|
+
scriptEle.addEventListener("error", onScriptError);
|
|
576
580
|
this.#scriptElement = containerElement.appendChild(scriptEle);
|
|
577
581
|
});
|
|
578
582
|
}
|
|
@@ -582,17 +586,23 @@ class SSFGuest {
|
|
|
582
586
|
*/
|
|
583
587
|
close = async () => {
|
|
584
588
|
if (!this.#isConnected) return;
|
|
585
|
-
this.#
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
589
|
+
if (this.#hostWindow && this.#hostOrigin) {
|
|
590
|
+
this.#remoting.send({
|
|
591
|
+
targetWin: this.#hostWindow,
|
|
592
|
+
targetOrigin: this.#hostOrigin,
|
|
593
|
+
messageType: MessageType.GuestClose,
|
|
594
|
+
messageBody: {}
|
|
595
|
+
});
|
|
596
|
+
this.#remoting.removeSender({
|
|
597
|
+
origin: this.#hostOrigin,
|
|
598
|
+
window: this.#hostWindow
|
|
599
|
+
});
|
|
600
|
+
}
|
|
595
601
|
this.#remoting.close();
|
|
602
|
+
if (this.#parentCloseMonitor) {
|
|
603
|
+
clearInterval(this.#parentCloseMonitor);
|
|
604
|
+
this.#parentCloseMonitor = null;
|
|
605
|
+
}
|
|
596
606
|
if (this.#throttledKeepAlive) {
|
|
597
607
|
userInteractionEvents.forEach((eventType) => {
|
|
598
608
|
document.removeEventListener(eventType, this.#throttledKeepAlive);
|
|
@@ -619,10 +629,9 @@ class SSFGuest {
|
|
|
619
629
|
let guestWindow = window;
|
|
620
630
|
let guestOptions = { ...capabilities };
|
|
621
631
|
if (param) {
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
guestOptions = Object.assign(guestOptions, clonedOptions);
|
|
632
|
+
const { window: paramWindow, ...restOptions } = param;
|
|
633
|
+
if (paramWindow) guestWindow = paramWindow;
|
|
634
|
+
guestOptions = { ...guestOptions, ...restOptions };
|
|
626
635
|
}
|
|
627
636
|
const hostDetails = await getHostDetails();
|
|
628
637
|
this.#hostOrigin = hostDetails.origin;
|
|
@@ -702,9 +711,10 @@ class SSFGuest {
|
|
|
702
711
|
`Retrieving scripting object "${objectId}" from host...`
|
|
703
712
|
);
|
|
704
713
|
if (!this.#isConnected) throw new Error("Not connected to host");
|
|
714
|
+
const { hostWindow, hostOrigin } = this.#requireHost();
|
|
705
715
|
const response = await this.#remoting.invoke({
|
|
706
|
-
targetWin:
|
|
707
|
-
targetOrigin:
|
|
716
|
+
targetWin: hostWindow,
|
|
717
|
+
targetOrigin: hostOrigin,
|
|
708
718
|
messageType: MessageType.ObjectGet,
|
|
709
719
|
messageBody: {
|
|
710
720
|
objectId
|
|
@@ -727,9 +737,10 @@ class SSFGuest {
|
|
|
727
737
|
`Retrieving names of scripting objects exposed by host...`
|
|
728
738
|
);
|
|
729
739
|
if (!this.#isConnected) throw new Error("Not connected to host");
|
|
740
|
+
const { hostWindow, hostOrigin } = this.#requireHost();
|
|
730
741
|
const objects = await this.#remoting.invoke({
|
|
731
|
-
targetWin:
|
|
732
|
-
targetOrigin:
|
|
742
|
+
targetWin: hostWindow,
|
|
743
|
+
targetOrigin: hostOrigin,
|
|
733
744
|
messageType: MessageType.ListObjects,
|
|
734
745
|
messageBody: {}
|
|
735
746
|
});
|
|
@@ -770,9 +781,10 @@ class SSFGuest {
|
|
|
770
781
|
const token = uuidv4();
|
|
771
782
|
listeners.push({ callback, token, criteria });
|
|
772
783
|
this.#eventListeners.set(eventId.toLowerCase(), listeners);
|
|
784
|
+
const { hostWindow, hostOrigin } = this.#requireHost();
|
|
773
785
|
this.#remoting.send({
|
|
774
|
-
targetWin:
|
|
775
|
-
targetOrigin:
|
|
786
|
+
targetWin: hostWindow,
|
|
787
|
+
targetOrigin: hostOrigin,
|
|
776
788
|
messageType: MessageType.GuestEventSubscribe,
|
|
777
789
|
messageBody: {
|
|
778
790
|
eventId,
|
|
@@ -797,9 +809,10 @@ class SSFGuest {
|
|
|
797
809
|
);
|
|
798
810
|
if (filteredListeners.length < originalLength) {
|
|
799
811
|
this.#eventListeners.set(eventId.toLowerCase(), filteredListeners);
|
|
812
|
+
const { hostWindow, hostOrigin } = this.#requireHost();
|
|
800
813
|
this.#remoting.send({
|
|
801
|
-
targetWin:
|
|
802
|
-
targetOrigin:
|
|
814
|
+
targetWin: hostWindow,
|
|
815
|
+
targetOrigin: hostOrigin,
|
|
803
816
|
messageType: MessageType.GuestEventUnsubscribe,
|
|
804
817
|
messageBody: {
|
|
805
818
|
eventId,
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
margin: 0px;
|
|
11
11
|
}
|
|
12
12
|
</style>
|
|
13
|
-
<script src="https://cdn.
|
|
13
|
+
<script src="https://cdn.mortgagetech.q1.ice.com/pui-diagnostics@3"></script>
|
|
14
14
|
</head>
|
|
15
15
|
<body class="px-2">
|
|
16
16
|
<script src="./loanValidation.js" type="module"></script>
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
7
|
<title>Pricing Service</title>
|
|
8
8
|
<script src="https://cdn.tailwindcss.com?plugins=forms"></script>
|
|
9
|
-
<script src="https://cdn.
|
|
9
|
+
<script src="https://cdn.mortgagetech.q1.ice.com/pui-diagnostics@3"></script>
|
|
10
10
|
</head>
|
|
11
11
|
<body class="px-2">
|
|
12
12
|
<main>
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
}
|
|
12
12
|
</style>
|
|
13
13
|
<script src="https://cdn.tailwindcss.com?plugins=forms"></script>
|
|
14
|
-
<script src="https://cdn.
|
|
14
|
+
<script src="https://cdn.mortgagetech.q1.ice.com/pui-diagnostics@3"></script>
|
|
15
15
|
</head>
|
|
16
16
|
|
|
17
17
|
<body class="px-2">
|
package/dist/esm/utils.js
CHANGED
|
@@ -11,44 +11,54 @@ const getOrigin = (url) => {
|
|
|
11
11
|
if (!url || url === "about:blank") return "*";
|
|
12
12
|
try {
|
|
13
13
|
const { origin } = new URL(url);
|
|
14
|
-
return origin === "null" || !origin ?
|
|
15
|
-
} catch
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
return origin === "null" || !origin ? "*" : origin;
|
|
15
|
+
} catch {
|
|
16
|
+
try {
|
|
17
|
+
const { origin } = new URL(url, document.baseURI);
|
|
18
|
+
return origin === "null" || !origin ? "*" : origin;
|
|
19
|
+
} catch {
|
|
20
|
+
return "*";
|
|
21
|
+
}
|
|
18
22
|
}
|
|
19
23
|
};
|
|
20
24
|
const isEmbedded = () => window.self !== window.parent;
|
|
21
25
|
const getComputedStyle = (prop, el) => {
|
|
22
|
-
const
|
|
23
|
-
const retVal = document.defaultView?.getComputedStyle?.(
|
|
26
|
+
const element = el || document.body;
|
|
27
|
+
const retVal = document.defaultView?.getComputedStyle?.(element, null);
|
|
24
28
|
const propValue = retVal ? retVal[prop] : "0";
|
|
25
29
|
return parseInt(propValue, 10);
|
|
26
30
|
};
|
|
27
|
-
const originsRegex =
|
|
28
|
-
`^https?://(.*.elliemae.io|.*.ellielabs.com|.*.ellieservices.com|.*.encompassloconnect.com|.*.ice.com|localhost:[0-9]+)`,
|
|
29
|
-
"i"
|
|
30
|
-
);
|
|
31
|
+
const originsRegex = /^https?:\/\/([a-z0-9-]+\.)*(?:elliemae\.io|ellielabs\.com|ellieservices\.com|encompassloconnect\.com|ice\.com|localhost:[0-9]+)$/i;
|
|
31
32
|
const MESSAGE_SOURCE = "elli:remoting";
|
|
32
|
-
const
|
|
33
|
+
const HANDSHAKE_TIMEOUT_MS = 3e4;
|
|
34
|
+
const getHostDetails = () => new Promise((resolve, reject) => {
|
|
33
35
|
if (!isEmbedded()) {
|
|
34
36
|
const currentWindow = window;
|
|
37
|
+
let timer;
|
|
35
38
|
const onMessage = (event) => {
|
|
36
39
|
if (originsRegex.test(event.origin)) {
|
|
37
40
|
const { source, type } = event.data || {};
|
|
38
41
|
if (source === MESSAGE_SOURCE && type === MessageType.HandShake) {
|
|
39
42
|
const { origin } = event;
|
|
40
|
-
const
|
|
43
|
+
const hostWindow = event.source;
|
|
44
|
+
clearTimeout(timer);
|
|
41
45
|
sendMessage({
|
|
42
|
-
targetWin:
|
|
46
|
+
targetWin: hostWindow,
|
|
43
47
|
targetOrigin: origin,
|
|
44
48
|
messageType: MessageType.HandShakeAck,
|
|
45
49
|
messageBody: {}
|
|
46
50
|
});
|
|
47
51
|
currentWindow.removeEventListener("message", onMessage);
|
|
48
|
-
resolve({ origin, window:
|
|
52
|
+
resolve({ origin, window: hostWindow });
|
|
49
53
|
}
|
|
50
54
|
}
|
|
51
55
|
};
|
|
56
|
+
timer = setTimeout(() => {
|
|
57
|
+
currentWindow.removeEventListener("message", onMessage);
|
|
58
|
+
reject(
|
|
59
|
+
new Error(`Host handshake timed out after ${HANDSHAKE_TIMEOUT_MS}ms`)
|
|
60
|
+
);
|
|
61
|
+
}, HANDSHAKE_TIMEOUT_MS);
|
|
52
62
|
currentWindow.addEventListener("message", onMessage);
|
|
53
63
|
} else {
|
|
54
64
|
resolve({
|
package/dist/esm/v1-adapter.js
CHANGED
|
@@ -16,15 +16,16 @@ const setupV1Adapter = (guestV2 = null) => {
|
|
|
16
16
|
window.elli = window.elli ?? {};
|
|
17
17
|
window.elli.script = {
|
|
18
18
|
guest: {
|
|
19
|
-
create:
|
|
19
|
+
create: (scriptUri, element) => getGuest().addScript(scriptUri, element)
|
|
20
20
|
},
|
|
21
|
-
connect:
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
connect: (params) => {
|
|
22
|
+
if (!scriptOnlyGuest)
|
|
23
|
+
console.warn(
|
|
24
|
+
"elli.script.connect is deprecated. Please use connect method of SSFGuest class instead, const guest = new ice.guest.SSFGuest(); await guest.connect(params);"
|
|
25
|
+
);
|
|
25
26
|
return getGuest().connect(params);
|
|
26
27
|
},
|
|
27
|
-
getObject:
|
|
28
|
+
getObject: (objectName) => {
|
|
28
29
|
if (!scriptOnlyGuest)
|
|
29
30
|
console.warn(
|
|
30
31
|
"elli.script.getObject is deprecated. Please use getObject method of SSFGuest class instead, const guest = new ice.guest.SSFGuest(); await guest.getObject(objectName);"
|
|
@@ -67,7 +68,10 @@ const setupV1Adapter = (guestV2 = null) => {
|
|
|
67
68
|
}
|
|
68
69
|
};
|
|
69
70
|
};
|
|
70
|
-
|
|
71
|
+
try {
|
|
72
|
+
setupV1Adapter();
|
|
73
|
+
} catch {
|
|
74
|
+
}
|
|
71
75
|
export {
|
|
72
76
|
setScriptOnlyGuest,
|
|
73
77
|
setupV1Adapter
|
package/dist/esm/v2-guest.html
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title>Guest V2</title>
|
|
7
|
-
<script src="https://cdn.
|
|
7
|
+
<script src="https://cdn.mortgagetech.q1.ice.com/pui-diagnostics@3"></script>
|
|
8
8
|
</head>
|
|
9
9
|
<body>
|
|
10
10
|
<h2>Guest V2</h2>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["webpack://ice.guest/businessObjects.js"],"sourcesContent":["import { getGuest } from './util.js';\n\nlet loanObj = null;\nlet propertyObj = null;\n\nconst ssfGuest = getGuest();\n\nexport const getLoanObject = async () => {\n if (!loanObj) loanObj = await ssfGuest.getObject('Loan');\n return loanObj;\n};\n\nexport const getPropertyObject = async () => {\n if (!propertyObj) propertyObj = await ssfGuest.getObject('Loan');\n return propertyObj;\n};\n"],"mappings":"AAAA,OAAS,YAAAA,MAAgB,YAEzB,IAAIC,EAAU,KACVC,EAAc,KAElB,MAAMC,EAAWH,EAAS,EAEnB,aAAM,cAAgB,UACtBC,IAASA,EAAU,MAAME,EAAS,UAAU,MAAM,GAChDF,GAGI,kBAAoB,UAC1BC,IAAaA,EAAc,MAAMC,EAAS,UAAU,MAAM,GACxDD","names":["getGuest","loanObj","propertyObj","ssfGuest"],"sourceRoot":"","file":"businessObjects.js"}
|
|
1
|
+
{"version":3,"sources":["webpack://ice.guest/businessObjects.js"],"sourcesContent":["import { getGuest } from './util.js';\n\nlet loanObj = null;\nlet propertyObj = null;\n\nconst ssfGuest = getGuest();\n\nexport const getLoanObject = async () => {\n if (!loanObj) loanObj = await ssfGuest.getObject('Loan');\n return loanObj;\n};\n\nexport const getPropertyObject = async () => {\n if (!propertyObj) propertyObj = await ssfGuest.getObject('Loan');\n return propertyObj;\n};\n"],"mappings":"AAAA,OAAS,YAAAA,MAAgB,YAEzB,IAAIC,EAAU,KACVC,EAAc,KAElB,MAAMC,EAAWH,EAAS,EAEnB,aAAM,cAAgB,UACtBC,IAASA,EAAU,MAAME,EAAS,UAAU,MAAM,GAChDF,GAGI,kBAAoB,UAC1BC,IAAaA,EAAc,MAAMC,EAAS,UAAU,MAAM,GACxDD","names":["getGuest","loanObj","propertyObj","ssfGuest"],"ignoreList":[],"sourceRoot":"","file":"businessObjects.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["webpack://ice.guest/creditScoreService.js"],"sourcesContent":["(async () => {\n const loanObj = await window.__ICE__.ssfGuest.getObject('Loan');\n const { ssn } = await loanObj.getLoanDetails();\n setTimeout(async () => {\n const score = ssn === '123456789' ? 800 : 600;\n await loanObj.setCreditScore(score);\n }, 1000);\n})();\n"],"mappings":"CAAC,SAAY,CACX,MAAMA,EAAU,MAAM,OAAO,QAAQ,SAAS,UAAU,MAAM,EACxD,CAAE,IAAAC,CAAI,EAAI,MAAMD,EAAQ,eAAe,EAC7C,WAAW,SAAY,CACrB,MAAME,EAAQD,IAAQ,YAAc,IAAM,IAC1C,MAAMD,EAAQ,eAAeE,CAAK,CACpC,EAAG,GAAI,CACT,GAAG","names":["loanObj","ssn","score"],"sourceRoot":"","file":"creditScoreService.js"}
|
|
1
|
+
{"version":3,"sources":["webpack://ice.guest/creditScoreService.js"],"sourcesContent":["(async () => {\n const loanObj = await window.__ICE__.ssfGuest.getObject('Loan');\n const { ssn } = await loanObj.getLoanDetails();\n setTimeout(async () => {\n const score = ssn === '123456789' ? 800 : 600;\n await loanObj.setCreditScore(score);\n }, 1000);\n})();\n"],"mappings":"CAAC,SAAY,CACX,MAAMA,EAAU,MAAM,OAAO,QAAQ,SAAS,UAAU,MAAM,EACxD,CAAE,IAAAC,CAAI,EAAI,MAAMD,EAAQ,eAAe,EAC7C,WAAW,SAAY,CACrB,MAAME,EAAQD,IAAQ,YAAc,IAAM,IAC1C,MAAMD,EAAQ,eAAeE,CAAK,CACpC,EAAG,GAAI,CACT,GAAG","names":["loanObj","ssn","score"],"ignoreList":[],"sourceRoot":"","file":"creditScoreService.js"}
|
|
@@ -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.
|
|
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.e058aa48d90db357a043.js"></script></head><body></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.e058aa48d90db357a043.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(q,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")):(q.ice=q.ice||{},q.ice.guest=R(q.emuiDiagnostics))})(globalThis,X=>(()=>{var q={89(a,l,c){var g=c(561),h=c(470),u="[object Symbol]";function w(E){return typeof E=="symbol"||h(E)&&g(E)==u}a.exports=w},230(a){function l(c){var g=typeof c;return c!=null&&(g=="object"||g=="function")}a.exports=l},327(a){var l=/\s/;function c(g){for(var h=g.length;h--&&l.test(g.charAt(h)););return h}a.exports=c},345(a,l,c){var g=c(702),h=c(230),u="Expected a function";function w(E,T,y){var p=!0,S=!0;if(typeof E!="function")throw new TypeError(u);return h(y)&&(p="leading"in y?!!y.leading:p,S="trailing"in y?!!y.trailing:S),g(E,T,{leading:p,maxWait:T,trailing:S})}a.exports=w},381(a,l,c){var g=c(736),h=function(){return g.Date.now()};a.exports=h},388(a){"use strict";a.exports=X},433(a){var l=typeof globalThis=="object"&&globalThis&&globalThis.Object===Object&&globalThis;a.exports=l},470(a){function l(c){return c!=null&&typeof c=="object"}a.exports=l},504(a,l,c){var g=c(572),h=Object.prototype,u=h.hasOwnProperty,w=h.toString,E=g?g.toStringTag:void 0;function T(y){var p=u.call(y,E),S=y[E];try{y[E]=void 0;var m=!0}catch{}var O=w.call(y);return m&&(p?y[E]=S:delete y[E]),O}a.exports=T},561(a,l,c){var g=c(572),h=c(504),u=c(567),w="[object Null]",E="[object Undefined]",T=g?g.toStringTag:void 0;function y(p){return p==null?p===void 0?E:w:T&&T in Object(p)?h(p):u(p)}a.exports=y},567(a){var l=Object.prototype,c=l.toString;function g(h){return c.call(h)}a.exports=g},569(a,l,c){var g=c(605),h=c(230),u=c(89),w=NaN,E=/^[-+]0x[0-9a-f]+$/i,T=/^0b[01]+$/i,y=/^0o[0-7]+$/i,p=parseInt;function S(m){if(typeof m=="number")return m;if(u(m))return w;if(h(m)){var O=typeof m.valueOf=="function"?m.valueOf():m;m=h(O)?O+"":O}if(typeof m!="string")return m===0?m:+m;m=g(m);var k=T.test(m);return k||y.test(m)?p(m.slice(2),k?2:8):E.test(m)?w:+m}a.exports=S},572(a,l,c){var g=c(736),h=g.Symbol;a.exports=h},605(a,l,c){var g=c(327),h=/^\s+/;function u(w){return w&&w.slice(0,g(w)+1).replace(h,"")}a.exports=u},702(a,l,c){var g=c(230),h=c(381),u=c(569),w="Expected a function",E=Math.max,T=Math.min;function y(p,S,m){var O,k,U,L,x,P,f=0,V=!1,D=!1,M=!0;if(typeof p!="function")throw new TypeError(w);S=u(S)||0,g(m)&&(V=!!m.leading,D="maxWait"in m,U=D?E(u(m.maxWait)||0,S):U,M="trailing"in m?!!m.trailing:M);function F(b){var _=O,W=k;return O=k=void 0,f=b,L=p.apply(W,_),L}function Q(b){return f=b,x=setTimeout(A,S),V?F(b):L}function Y(b){var _=b-P,W=b-f,G=S-_;return D?T(G,U-W):G}function C(b){var _=b-P,W=b-f;return P===void 0||_>=S||_<0||D&&W>=U}function A(){var b=h();if(C(b))return H(b);x=setTimeout(A,Y(b))}function H(b){return x=void 0,M&&O?F(b):(O=k=void 0,L)}function N(){x!==void 0&&clearTimeout(x),f=0,O=P=k=x=void 0}function z(){return x===void 0?L:H(h())}function B(){var b=h(),_=C(b);if(O=arguments,k=this,P=b,_){if(x===void 0)return Q(P);if(D)return clearTimeout(x),x=setTimeout(A,S),F(P)}return x===void 0&&(x=setTimeout(A,S)),L}return B.cancel=N,B.flush=z,B}a.exports=y},736(a,l,c){var g=c(433),h=typeof self=="object"&&self&&self.Object===Object&&self,u=g||h||Function("return this")();a.exports=u}},R={};function I(a){var l=R[a];if(l!==void 0)return l.exports;var c=R[a]={exports:{}};return q[a](c,c.exports,I),c.exports}I.n=a=>{var l=a&&a.__esModule?()=>a.default:()=>a;return I.d(l,{a:l}),l},I.d=(a,l)=>{for(var c in l)I.o(l,c)&&!I.o(a,c)&&Object.defineProperty(a,c,{enumerable:!0,get:l[c]})},I.o=(a,l)=>Object.prototype.hasOwnProperty.call(a,l),I.r=a=>{typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(a,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(a,"__esModule",{value:!0})};var K={};return(()=>{"use strict";I.r(K),I.d(K,{SSFGuest:()=>ae});const l={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};let c;const g=new Uint8Array(16);function h(){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(g)}const u=[];for(let n=0;n<256;++n)u.push((n+256).toString(16).slice(1));function w(n,e=0){return u[n[e+0]]+u[n[e+1]]+u[n[e+2]]+u[n[e+3]]+"-"+u[n[e+4]]+u[n[e+5]]+"-"+u[n[e+6]]+u[n[e+7]]+"-"+u[n[e+8]]+u[n[e+9]]+"-"+u[n[e+10]]+u[n[e+11]]+u[n[e+12]]+u[n[e+13]]+u[n[e+14]]+u[n[e+15]]}function E(n,e=0){const t=w(n,e);if(!validate(t))throw TypeError("Stringified UUID is invalid");return t}const T=null;function y(n,e,t){if(l.randomUUID&&!e&&!n)return l.randomUUID();n=n||{};const s=n.random||(n.rng||h)();if(s[6]=s[6]&15|64,s[8]=s[8]&63|128,e){t=t||0;for(let i=0;i<16;++i)e[t+i]=s[i];return e}return w(s)}const p=y;var S=I(345),m=I.n(S);const O="elli:remoting",k="elli:remoting:response",U="elli:remoting:exception",L=({messageType:n,messageBody:e,requestId:t,onewayMsg:s=!1})=>({requestId:t??(s?null:p()),source:O,type:n,body:e}),x=n=>{const{targetWin:e,targetOrigin:t,messageType:s,messageBody:i}=n,r=L({messageType:s,messageBody:i});e.postMessage(r,t)};class P{#i;#e;#t=new Map;#a=new Map;#n=null;#s=null;#c=new Map;constructor(e,t){if(!e)throw new Error("logger is required");if(!t)throw new Error("correlationId is required");this.#i=t,this.#e=e}#p=()=>{this.#n=null;const e=Date.now(),t=[];let s=null;if(this.#a.forEach((i,r)=>{const{requestId:o,cancelTime:d}=i;d&&d<=e?(this.#e.debug(`Detected response timeout for requestId: ${o}...`),t.push(r),i.resolve(void 0)):d&&(s=s===null?d:Math.min(s,d))}),t.forEach(i=>{this.#a.delete(i)}),s!==null){const i=Math.max(s-Date.now(),0);this.#g(i)}};#g=e=>{this.#n===null&&(this.#n=window.setTimeout(this.#p,e))};#f=()=>{this.#n!==null&&(window.clearTimeout(this.#n),this.#n=null)};#r=e=>{const t=this.#a.get(e);return this.#e.debug(`serving requestId: ${e}`),this.#a.delete(e),t};#o=e=>{const{requestId:t}=e;this.#e.debug(`Response received for invocation requestId: ${t}`);const s=this.#r(t);return s?(s.resolve(e.body),!0):(this.#e.debug(`Received response to stale/invalid request with requestId: ${t}`),!1)};#h=e=>{this.#e.debug(`Exception received for invocation (requestId = ${e.requestId})`);const t=this.#r(e.requestId);return t?(t.reject(new Error(e.body)),!0):(this.#e.warn(`Received exception for stale/invalid request (requestId = ${e.requestId})`),!1)};#v=({sourceWin:e,sourceOrigin:t,message:s})=>{this.#e.debug(`Received message of type "${s.type}"`);const i=this.#t.get(s.type);return i?(i.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.#c.size===0||!e.source)return!1;const t=this.#c.get(e.source);return!t||e?.data?.source!==O?!1:(this.#e.debug(`Remoting: Received message of type "${e.data.type}"`),e.data.type===k?this.#o(e.data):e.data.type===U?this.#h(e.data):this.#v({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.#c.set(s,t)};initialize=e=>{this.#s&&this.#s.removeEventListener("message",this.#l),e.addEventListener("message",this.#l),this.#s=e,this.#e.debug(`initialized remoting id: ${this.#i}`)};close=()=>{this.#s&&(this.#s.removeEventListener("message",this.#l),this.#s=null),this.#f(),this.#e.debug(`closed remoting id: ${this.#i}`)};invoke=e=>{const{targetWin:t,targetOrigin:s,messageType:i,messageBody:r,responseTimeoutMs:o}=e;return new Promise((d,j)=>{const v=L({messageType:i,messageBody:r});this.#a.set(v.requestId,{requestId:v.requestId,resolve:d,reject:j,cancelTime:o?Date.now()+o:null}),t.postMessage(v,s);const{requestId:$}=v;this.#e.debug(`Posted invocation message of type ${i} requestId: ${$||""}`),o&&(this.#e.debug(`scheduling timeout check for requestId: ${$||""} in ${o} ms`),this.#g(o))})};listen=e=>{const{messageType:t,callback:s}=e,i=this.#t.get(t)||[];i.push(s),this.#t.set(t,i)};unlisten=e=>{const{messageType:t,callback:s}=e,i=this.#t.get(t);if(!i)return;const r=i.indexOf(s);r!==-1&&i.splice(r,1)};send=e=>{const{targetWin:t,targetOrigin:s,messageType:i,messageBody:r}=e,o=L({messageType:i,messageBody:r,onewayMsg:!0});t.postMessage(o,s),this.#e.debug(`Posted one-way message of type "${i}"`)};removeSender=e=>{const{window:t}=e;t&&this.#c.delete(t)};respond=e=>{const{targetWin:t,targetOrigin:s,requestId:i,response:r}=e,o=L({messageType:k,messageBody:r,requestId:i});t.postMessage(o,s),this.#e.debug(`Response sent to caller for invocation requestId: ${i}`)};raiseException=e=>{const{targetWin:t,targetOrigin:s,requestId:i,ex:r}=e,o=r instanceof Error?r.message:r,d=L({messageType:U,messageBody:o,requestId:i});t.postMessage(d,s),this.#e.debug(`Exception sent to caller for invocation. requestId: ${i}`)}}var f=(n=>(n.GuestClose="guest:close",n.GuestEventSubscribe="guest:eventSubscribe",n.GuestEventUnsubscribe="guest:eventUnsubscribe",n.GuestFocus="guest:focus",n.GuestReady="guest:ready",n.GuestReadyComplete="guest:readyComplete",n.GuestResize="guest:resize",n.HandShake="handshake",n.HandShakeAck="handshake:ack",n.HostClose="host:close",n.HostConfig="host:config",n.ListObjects="list:objects",n.ObjectEvent="object:event",n.ObjectGet="object:get",n.ObjectInvoke="object:invoke",n))(f||{});class V{__TYPE__="Proxy";id;objectType;constructor(e,t){this.id=e,this.objectType=t}}const D=n=>n?.constructor?.name==="Proxy"||n?.constructor?.name==="ScriptingObjectProxy"||n?.__TYPE__==="Proxy";class M{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 F{static[Symbol.hasInstance](e){return typeof e=="object"&&e!==null&&"getType"in e&&typeof e.getType=="function"&&e.getType()==="ProxyEvent"}#i;objectId;name;id;getType(){return"ProxyEvent"}constructor(e){const{name:t,objectId:s,eventSrc:i}=e;if(!t)throw new Error("Event name is required");if(!s)throw new Error("Scripting object id is required");if(!i)throw new Error("Event source is required");this.objectId=s,this.name=t,this.#i=i,this.id=`${this.objectId}.${this.name}`.toLowerCase()}subscribe=e=>this.#i.subscribe({eventId:this.id,callback:e});unsubscribe=e=>{this.#i.unsubscribe({eventId:this.id,token:e})}}const Q=n=>n instanceof M,Y=(n,e)=>`${n.toLowerCase()}.${e.toLowerCase()}`;var C=I(388);const A=()=>{const{parent:n}=window;try{return n?.location?.href}catch{return null}},H=n=>{if(!n||n==="about:blank")return"*";try{const{origin:e}=new URL(n);return e==="null"||!e?"*":e}catch{try{const{origin:e}=new URL(n,document.baseURI);return e==="null"||!e?"*":e}catch{return"*"}}},N=()=>window.self!==window.parent,z=(n,e)=>{const t=e||document.body,s=document.defaultView?.getComputedStyle?.(t,null),i=s?s[n]:"0";return parseInt(i,10)},B=/^https?:\/\/([a-z0-9-]+\.)*(?:elliemae\.io|ellielabs\.com|ellieservices\.com|encompassloconnect\.com|ice\.com|localhost:[0-9]+)$/i,b="elli:remoting",_=3e4,W=()=>new Promise((n,e)=>{if(N())n({origin:H(document.referrer||A()),window:window.parent});else{const t=window;let s;const i=r=>{if(B.test(r.origin)){const{source:o,type:d}=r.data||{};if(o===b&&d===f.HandShake){const{origin:j}=r,v=r.source;clearTimeout(s),x({targetWin:v,targetOrigin:j,messageType:f.HandShakeAck,messageBody:{}}),t.removeEventListener("message",i),n({origin:j,window:v})}}};s=setTimeout(()=>{t.removeEventListener("message",i),e(new Error(`Host handshake timed out after ${_}ms`))},_),t.addEventListener("message",i)}});let G=!1;const ne=n=>{G=n},Z=(n=null)=>{let e=n;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,i)=>t().addScript(s,i)},connect:s=>t().connect(s),getObject:s=>t().getObject(s),setLogLevel:s=>t().setLogLevel(s),subscribe:(s,i,r,o)=>t().subscribe({eventId:`${s}.${i}`,callback:d=>r(d?.obj,d?.eventParams,d?.eventOptions),criteria:o?.criteria}),unsubscribe:(s,i,r)=>t().unsubscribe({eventId:`${s}.${i}`,token:r})}};try{Z()}catch{}var re=(n=>(n.OBJECT="object",n.VALUE="value",n))(re||{});const J=12e4,oe={eventFeedback:!0},ee=()=>{const{document:n}=window,e=n.body,t=n.documentElement,i={height:e.offsetHeight+z("marginTop")+z("marginBottom"),width:Math.max(e.scrollWidth,t.scrollWidth)};x({targetWin:window.parent,targetOrigin:H(n.referrer||A()),messageType:f.GuestResize,messageBody:i}),window.removeEventListener("load",ee)};N()&&window.addEventListener("load",ee);const te={"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"},se=["click","scroll","keypress","touchstart"],ce=()=>{const n=document.currentScript?.src||"file:///opt/jenkins/workspace/UIPlatform_pui-microfe_master/236/libs/ssf-guest/lib/guest.ts",e=n?new URL(n).hostname:"localhost";return te[e]||te["cdn.mortgagetech.q1.ice.com"]};class ae{#i;#e;#t;#a=!1;#n=null;#s=!1;#c=new Map;#p=null;#g=null;#f=null;#r=null;#o=null;#h=null;#v=new Map;#l(){if(!this.#o||!this.#r)throw new Error("Guest is not connected to a host. Call connect() first.");return{hostWindow:this.#o,hostOrigin:this.#r}}#E=!1;#u=null;#m=null;#b=null;#S=!0;#j=J;#O;#w=null;constructor(e){const{console:t=!1,url:s=window.__ICE__?.diagnosticsUrl||ce(),index:i="ssf-guest-v2",team:r="ICE",appName:o="SSF Guest V2 Application"}=e?.logger??{};this.#O=e?.logger,this.#E=e?.usesDevConnectAPI??!1,this.#S=e?.keepAlive??!0,this.#j=e?.keepAliveInterval??J;const d=t?(0,C.Console)():(0,C.http)(s);this.#e=e?.appLogger??(0,C.logger)({transport:d,index:i,team:r,appName:o}),(0,C.webvitals)(this.#e),(0,C.logUnhandledErrors)(this.#e),this.#i=p(),this.#t=new P(this.#e,this.#i),Z(this),this.#e.audit({message:"Guest created",guestUrl:window.location.href,correlationId:this.#i})}#d=()=>({guestId:this.#p,guestTitle:this.#g,guestUrl:this.#f});#y=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 V(e.objectId,e.objectType);return e.functions&&e.functions.forEach(s=>{Object.defineProperty(t,s,{value:async(...i)=>this.#x({objectId:t.id,functionName:s,functionParams:[...i]}),enumerable:!0})}),e.events&&e.events.forEach(s=>{Object.defineProperty(t,s,{value:new F({objectId:t.id,name:s,eventSrc:this}),enumerable:!0})}),this.#e.debug(`Created guest proxy for scripting object (id = "${t.id}")`),t};#x=async({objectId:e,functionName:t,functionParams:s})=>{this.#e.debug(`Invoking scripting object method ${e}.${t}()...`);const i=[];if(s)for(let v=0;v<s.length;v+=1){const $=s[v];$ instanceof Promise&&i.push($.then(ie=>{s[v]=ie}))}await Promise.all(i);const{hostWindow:r,hostOrigin:o}=this.#l(),d=await this.#t.invoke({targetWin:r,targetOrigin:o,messageType:f.ObjectInvoke,messageBody:{objectId:e,functionName:t,functionParams:s}}),j=this.#T(d);return this.#e.audit({message:"Guest proxy invoked Scripting Object method",scriptingObject:e,scriptingMethod:t,...this.#d()}),j};#I(e,t){return Object.entries(t).every(([s,i])=>{const r=e[s];if("eq"in i)return r===i.eq;if("in"in i)return Array.isArray(i.in)&&i.in.includes(r);if("includes"in i)return Array.isArray(r)&&r.includes(i.includes);if("gt"in i){const o=typeof r=="number"?r:Number(r);return!Number.isNaN(o)&&o>i.gt}if("lt"in i){const o=typeof r=="number"?r:Number(r);return!Number.isNaN(o)&&o<i.lt}if("regex"in i)try{let o=this.#v.get(i.regex);return o||(o=new RegExp(i.regex),this.#v.set(i.regex,o)),typeof r=="string"&&o.test(r)}catch{return!1}return!1})}#T=e=>e?.type==="object"&&"object"in e?this.#y(e.object):e?.type==="value"?e.value:e;#k=({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.#g=e?.guestTitle??null,this.#f=e?.guestUrl??null,this.#e.audit({message:"Received configuration from Host",...this.#d()})};#L=()=>{window.focus()};#_=async()=>{await this.close(),window.close()};#$=()=>{N()||(this.#h=setInterval(()=>{this.#o?.closed&&this.close().then(()=>{window.close()}).catch(()=>{})},1e3))};#P=async({sourceWin:e,sourceOrigin:t,requestId:s,body:i})=>{const r=this.#y(i.object);if(r){const o=Y(r.id,i.eventName);this.#e.debug(`Received event "${o}" from host`);let d;i.eventHandler?d=[{callback:window[i.eventHandler],token:p()}]:d=this.#c.get(o)||[];const j=[];if(d.forEach(v=>{if(v?.callback){if(v.criteria&&!(i.eventParams?this.#I(i.eventParams,v.criteria):!1)){this.#e.debug(`Event ${o} did not match criteria for subscriber ${v.callback.name}`);return}this.#e.debug(`Invoking event subscriber ${v.callback.name} for event ${o}`);const $=v.callback({obj:r,eventName:i.eventName,eventParams:i.eventParams,eventOptions:i.eventOptions});$ instanceof Promise?j.push($):typeof $<"u"&&j.push(Promise.resolve($))}}),s){const v=await Promise.all(j);this.#t.respond({targetWin:e,targetOrigin:t,requestId:s,response:v}),this.#e.audit({message:"Guest proxy processed event from host and responded",scriptingEventId:o,scriptingObject:r.id,...this.#d()})}else this.#e.audit({message:"Guest proxy processed event from host",scriptingEventId:o,scriptingObject:r.id,...this.#d()})}};#G=async()=>{if(!(!this.#u||!this.#m||!this.#b))try{await fetch(`${this.#b}/oauth2/v1/token/introspection?${new URLSearchParams({token:this.#u,client_id:this.#m}).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}`)}};#C=async()=>{if(this.#u&&this.#m&&this.#b)try{await fetch(`${this.#b}/oauth2/v1/token/revocation?${new URLSearchParams({token:this.#u,client_id:this.#m}).toString()}`,{method:"POST"})}catch(e){this.#e.error(`Error revoking token. ${e.message}`)}finally{this.#u=null,this.#m=null}};#R=async()=>{if(this.#S)try{const e=await this.getObject("application");e?(this.#w=m()(async()=>{try{await e.keepSessionAlive(),await this.#G()}catch(t){this.#e.error(`Error keeping session alive. ${t.message}`)}},this.#j,{leading:!1}),se.forEach(t=>{document.addEventListener(t,this.#w)})):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)=>{if(!this.#a&&e){await this.connect();const s=document.createElement("script");s.setAttribute("src",e),s.setAttribute("type","module"),await new Promise((i,r)=>{let o,d;const j=()=>{s.removeEventListener("load",o),s.removeEventListener("error",d)};o=()=>{j(),this.#a=!0,ne(!0),i()},d=()=>{j(),r(new Error(`Failed to load script: ${e}`))},s.addEventListener("load",o),s.addEventListener("error",d),this.#n=t.appendChild(s)})}};close=async()=>{this.#s&&(this.#o&&this.#r&&(this.#t.send({targetWin:this.#o,targetOrigin:this.#r,messageType:f.GuestClose,messageBody:{}}),this.#t.removeSender({origin:this.#r,window:this.#o})),this.#t.close(),this.#h&&(clearInterval(this.#h),this.#h=null),this.#w&&se.forEach(e=>{document.removeEventListener(e,this.#w)}),await this.#C(),window.removeEventListener("beforeunload",this.close),this.#s=!1,this.#e.audit({message:"Guest disconnected from host",...this.#d()}),this.#p=null,this.#f=null,this.#g=null)};connect=async e=>{if(!this.#s){let t=window,s={...oe};if(e){const{window:r,...o}=e;r&&(t=r),s={...s,...o}}const i=await W();this.#r=i.origin,this.#o=i.window,this.#t.initialize(t),this.#t.addSender({origin:this.#r,window:this.#o}),this.#t.listen({messageType:f.ObjectEvent,callback:this.#P.bind(this)}),this.#t.listen({messageType:f.HostConfig,callback:this.#k.bind(this)}),this.#t.listen({messageType:f.GuestFocus,callback:this.#L.bind(this)}),this.#t.listen({messageType:f.HostClose,callback:this.#_.bind(this)}),this.#t.send({targetWin:this.#o,targetOrigin:this.#r,messageType:f.GuestReady,messageBody:s}),this.#s=!0,this.#$(),this.#E&&await this.getAuthToken(),await this.#R(),window.addEventListener("beforeunload",this.close),this.#e.audit({message:"Guest connected to host",guestUrl:window.location.href})}};getAuthToken=async()=>{if(!this.#u&&this.#s)try{const e=await this.getObject("auth");if(e){const t=await e.getAccessToken();this.#u=t?.access_token,this.#b=t?.host_name,this.#m=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.#s)throw new Error("Not connected to host");const{hostWindow:t,hostOrigin:s}=this.#l(),i=await this.#t.invoke({targetWin:t,targetOrigin:s,messageType:f.ObjectGet,messageBody:{objectId:e}}),r=this.#y(i.object);return this.#e.audit({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.#s)throw new Error("Not connected to host");const{hostWindow:e,hostOrigin:t}=this.#l(),s=await this.#t.invoke({targetWin:e,targetOrigin:t,messageType:f.ListObjects,messageBody:{}});return this.#e.audit({message:"Received names of all scripting objects exposed by host",objects:s,...this.#d()}),s};removeScript=()=>{if(this.#a&&this.#n){const{parentNode:e}=this.#n;e?.removeChild?.(this.#n)}};setLogLevel=e=>{this.#e.setLogLevel(e),this.#e.debug(`Log level changed by guest to ${e}`)};subscribe=e=>{const{eventId:t,criteria:s,callback:i}=e;this.#e.debug(`Registering subscription for event ${t}`);const r=this.#c.get(t.toLowerCase())||[],o=p();r.push({callback:i,token:o,criteria:s}),this.#c.set(t.toLowerCase(),r);const{hostWindow:d,hostOrigin:j}=this.#l();return this.#t.send({targetWin:d,targetOrigin:j,messageType:f.GuestEventSubscribe,messageBody:{eventId:t,criteria:s,token:o}}),this.#e.debug(`Subscribed to event ${t} with token ${o}`),o};unsubscribe=e=>{const{eventId:t,token:s}=e,i=this.#c.get(t.toLowerCase());if(i){const r=i.length,o=i.filter(d=>d.token!==s);if(o.length<r){this.#c.set(t.toLowerCase(),o);const{hostWindow:d,hostOrigin:j}=this.#l();this.#t.send({targetWin:d,targetOrigin:j,messageType:f.GuestEventUnsubscribe,messageBody:{eventId:t,token:s}}),this.#e.debug(`Unsubscribed from event ${t}`)}}}}})(),K})());
|
|
2
|
+
|
|
3
|
+
//# sourceMappingURL=emuiSsfGuest.e058aa48d90db357a043.js.map
|
|
Binary file
|
|
Binary file
|