@elliemae/ssf-guest 2.28.6 → 2.29.0-alpha.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 +26 -35
- package/dist/cjs/tests/utils.js +0 -1
- package/dist/cjs/utils.js +4 -4
- package/dist/cjs/v1-adapter.js +8 -7
- package/dist/esm/guest.js +26 -35
- package/dist/esm/tests/utils.js +0 -1
- package/dist/esm/utils.js +4 -4
- package/dist/esm/v1-adapter.js +8 -7
- 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.e7547c98c8ccfd0654bd.js +3 -0
- package/dist/public/js/emuiSsfGuest.e7547c98c8ccfd0654bd.js.br +0 -0
- package/dist/public/js/emuiSsfGuest.e7547c98c8ccfd0654bd.js.gz +0 -0
- package/dist/public/js/emuiSsfGuest.e7547c98c8ccfd0654bd.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 +3 -3
- package/dist/types/lib/tests/utils.d.ts +2 -2
- package/dist/types/lib/typings/window.d.ts +9 -7
- 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 +8 -7
- package/dist/public/js/emuiSsfGuest.ee124e1dde329168b45d.js +0 -3
- package/dist/public/js/emuiSsfGuest.ee124e1dde329168b45d.js.br +0 -0
- package/dist/public/js/emuiSsfGuest.ee124e1dde329168b45d.js.gz +0 -0
- package/dist/public/js/emuiSsfGuest.ee124e1dde329168b45d.js.map +0 -1
package/dist/cjs/guest.js
CHANGED
|
@@ -90,7 +90,6 @@ const getDiagnosticsAPIUrl = () => {
|
|
|
90
90
|
return diagnosticsEndpoint[hostName] || diagnosticsEndpoint["cdn.mortgagetech.q1.ice.com"];
|
|
91
91
|
};
|
|
92
92
|
class SSFGuest {
|
|
93
|
-
/* eslint-enable indent */
|
|
94
93
|
#correlationId;
|
|
95
94
|
#logger;
|
|
96
95
|
#remoting;
|
|
@@ -138,10 +137,6 @@ class SSFGuest {
|
|
|
138
137
|
* interval to keep host session alive.
|
|
139
138
|
*/
|
|
140
139
|
#keepAliveInterval = KEEP_ALIVE_INTERVAL;
|
|
141
|
-
/**
|
|
142
|
-
* options for the logger
|
|
143
|
-
*/
|
|
144
|
-
#loggerOptions;
|
|
145
140
|
/**
|
|
146
141
|
* throttled keep alive function
|
|
147
142
|
*/
|
|
@@ -155,13 +150,11 @@ class SSFGuest {
|
|
|
155
150
|
constructor(options) {
|
|
156
151
|
const {
|
|
157
152
|
console: logToConsole = false,
|
|
158
|
-
// eslint-disable-next-line no-underscore-dangle
|
|
159
153
|
url = window.__ICE__?.diagnosticsUrl || getDiagnosticsAPIUrl(),
|
|
160
154
|
index = "ssf-guest-v2",
|
|
161
155
|
team = "ICE",
|
|
162
156
|
appName = "SSF Guest V2 Application"
|
|
163
157
|
} = options?.logger ?? {};
|
|
164
|
-
this.#loggerOptions = options?.logger;
|
|
165
158
|
this.#usesDevConnectAPI = options?.usesDevConnectAPI ?? false;
|
|
166
159
|
this.#keepAlive = options?.keepAlive ?? true;
|
|
167
160
|
this.#keepAliveInterval = options?.keepAliveInterval ?? KEEP_ALIVE_INTERVAL;
|
|
@@ -210,12 +203,11 @@ class SSFGuest {
|
|
|
210
203
|
soJSON.functions.forEach((functionName) => {
|
|
211
204
|
Object.defineProperty(ctrl, functionName, {
|
|
212
205
|
value: async (...args) => {
|
|
213
|
-
const
|
|
214
|
-
const callerChain =
|
|
206
|
+
const proxiedFn = ctrl[functionName];
|
|
207
|
+
const callerChain = proxiedFn?.callContext?.callChain;
|
|
215
208
|
return this.#invoke({
|
|
216
209
|
objectId: ctrl.id,
|
|
217
210
|
functionName,
|
|
218
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
219
211
|
functionParams: [...args],
|
|
220
212
|
callerChain
|
|
221
213
|
});
|
|
@@ -402,13 +394,8 @@ class SSFGuest {
|
|
|
402
394
|
this.#logger.debug(`Received event "${eventId}" from host`);
|
|
403
395
|
let listeners;
|
|
404
396
|
if (body.eventHandler) {
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
408
|
-
callback: window[body.eventHandler],
|
|
409
|
-
token: (0, import_uuid.v4)()
|
|
410
|
-
}
|
|
411
|
-
];
|
|
397
|
+
const handler = window[body.eventHandler];
|
|
398
|
+
listeners = handler ? [{ callback: handler, token: (0, import_uuid.v4)() }] : [];
|
|
412
399
|
} else {
|
|
413
400
|
listeners = this.#eventListeners.get(eventId) || [];
|
|
414
401
|
}
|
|
@@ -416,7 +403,10 @@ class SSFGuest {
|
|
|
416
403
|
listeners.forEach((callbackInfo) => {
|
|
417
404
|
if (callbackInfo?.callback) {
|
|
418
405
|
if (callbackInfo.criteria) {
|
|
419
|
-
const criteriaMatched = body.eventParams ? this.#matchesCriteria(
|
|
406
|
+
const criteriaMatched = body.eventParams ? this.#matchesCriteria(
|
|
407
|
+
body.eventParams,
|
|
408
|
+
callbackInfo.criteria
|
|
409
|
+
) : false;
|
|
420
410
|
if (!criteriaMatched) {
|
|
421
411
|
this.#logger.debug(
|
|
422
412
|
`Event ${eventId} did not match criteria for subscriber ${callbackInfo.callback.name}`
|
|
@@ -570,24 +560,24 @@ class SSFGuest {
|
|
|
570
560
|
scriptEle.setAttribute("src", scriptUri);
|
|
571
561
|
scriptEle.setAttribute("type", "module");
|
|
572
562
|
await new Promise((resolve, reject) => {
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
563
|
+
const handlers = {
|
|
564
|
+
cleanup: () => {
|
|
565
|
+
scriptEle.removeEventListener("load", handlers.onScriptLoad);
|
|
566
|
+
scriptEle.removeEventListener("error", handlers.onScriptError);
|
|
567
|
+
},
|
|
568
|
+
onScriptLoad: () => {
|
|
569
|
+
handlers.cleanup();
|
|
570
|
+
this.#created = true;
|
|
571
|
+
(0, import_v1_adapter.setScriptOnlyGuest)(true);
|
|
572
|
+
resolve();
|
|
573
|
+
},
|
|
574
|
+
onScriptError: () => {
|
|
575
|
+
handlers.cleanup();
|
|
576
|
+
reject(new Error(`Failed to load script: ${scriptUri}`));
|
|
577
|
+
}
|
|
588
578
|
};
|
|
589
|
-
scriptEle.addEventListener("load", onScriptLoad);
|
|
590
|
-
scriptEle.addEventListener("error", onScriptError);
|
|
579
|
+
scriptEle.addEventListener("load", handlers.onScriptLoad);
|
|
580
|
+
scriptEle.addEventListener("error", handlers.onScriptError);
|
|
591
581
|
this.#scriptElement = containerElement.appendChild(scriptEle);
|
|
592
582
|
});
|
|
593
583
|
}
|
|
@@ -595,6 +585,7 @@ class SSFGuest {
|
|
|
595
585
|
/**
|
|
596
586
|
* Close the connection to the host
|
|
597
587
|
*/
|
|
588
|
+
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
598
589
|
close = async () => {
|
|
599
590
|
if (!this.#isConnected) return;
|
|
600
591
|
if (this.#hostWindow && this.#hostOrigin) {
|
package/dist/cjs/tests/utils.js
CHANGED
|
@@ -59,7 +59,6 @@ const postMessage = ({
|
|
|
59
59
|
new MessageEvent("message", {
|
|
60
60
|
source: srcWindow,
|
|
61
61
|
origin: (0, import_utils.getOrigin)(srcWindow.location.href),
|
|
62
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
63
62
|
data: {
|
|
64
63
|
source: "elli:remoting",
|
|
65
64
|
...message
|
package/dist/cjs/utils.js
CHANGED
|
@@ -30,7 +30,7 @@ const getParentWindowLocation = () => {
|
|
|
30
30
|
const { parent } = window;
|
|
31
31
|
try {
|
|
32
32
|
return parent?.location?.href;
|
|
33
|
-
} catch
|
|
33
|
+
} catch {
|
|
34
34
|
return null;
|
|
35
35
|
}
|
|
36
36
|
};
|
|
@@ -74,14 +74,14 @@ const getHostDetails = () => new Promise((resolve, reject) => {
|
|
|
74
74
|
if (!isEmbedded()) {
|
|
75
75
|
const currentWindow = window;
|
|
76
76
|
const expectedToken = getHandshakeToken();
|
|
77
|
-
|
|
77
|
+
const timerRef = {};
|
|
78
78
|
const onMessage = (event) => {
|
|
79
79
|
if (isHandshakeTrusted(event, expectedToken)) {
|
|
80
80
|
const { source, type } = event.data || {};
|
|
81
81
|
if (source === MESSAGE_SOURCE && type === import_microfe_common.MessageType.HandShake) {
|
|
82
82
|
const { origin } = event;
|
|
83
83
|
const hostWindow = event.source;
|
|
84
|
-
clearTimeout(
|
|
84
|
+
clearTimeout(timerRef.id);
|
|
85
85
|
(0, import_microfe_common.sendMessage)({
|
|
86
86
|
targetWin: hostWindow,
|
|
87
87
|
targetOrigin: origin,
|
|
@@ -93,7 +93,7 @@ const getHostDetails = () => new Promise((resolve, reject) => {
|
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
};
|
|
96
|
-
|
|
96
|
+
timerRef.id = setTimeout(() => {
|
|
97
97
|
currentWindow.removeEventListener("message", onMessage);
|
|
98
98
|
reject(
|
|
99
99
|
new Error(`Host handshake timed out after ${HANDSHAKE_TIMEOUT_MS}ms`)
|
package/dist/cjs/v1-adapter.js
CHANGED
|
@@ -54,7 +54,9 @@ const setupV1Adapter = (guestV2 = null) => {
|
|
|
54
54
|
console.warn(
|
|
55
55
|
"elli.script.getObject is deprecated. Please use getObject method of SSFGuest class instead, const guest = new ice.guest.SSFGuest(); await guest.getObject(objectName);"
|
|
56
56
|
);
|
|
57
|
-
return getGuest().getObject(
|
|
57
|
+
return getGuest().getObject(
|
|
58
|
+
objectName
|
|
59
|
+
);
|
|
58
60
|
},
|
|
59
61
|
setLogLevel: (level) => {
|
|
60
62
|
if (!scriptOnlyGuest)
|
|
@@ -67,25 +69,24 @@ const setupV1Adapter = (guestV2 = null) => {
|
|
|
67
69
|
subscribe: (objectId, eventName, callback, options) => {
|
|
68
70
|
if (!scriptOnlyGuest)
|
|
69
71
|
console.warn(
|
|
70
|
-
// eslint-disable-next-line no-template-curly-in-string
|
|
71
72
|
"elli.script.subscribe is deprecated. Please use subscribe method of SSFGuest class instead, const guest = new ice.guest.SSFGuest(); guest.subscribe({ eventId: `${objectId}.${eventName}`, callback: (event) => { console.log(event); });"
|
|
72
73
|
);
|
|
73
74
|
return getGuest().subscribe({
|
|
74
75
|
eventId: `${objectId}.${eventName}`,
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
callback: ((event) => callback(
|
|
77
|
+
event?.obj,
|
|
78
|
+
event?.eventParams,
|
|
79
|
+
event?.eventOptions
|
|
80
|
+
)),
|
|
78
81
|
criteria: options?.criteria
|
|
79
82
|
});
|
|
80
83
|
},
|
|
81
84
|
unsubscribe: (objectId, eventName, token) => {
|
|
82
85
|
if (!scriptOnlyGuest)
|
|
83
86
|
console.warn(
|
|
84
|
-
// eslint-disable-next-line no-template-curly-in-string
|
|
85
87
|
"elli.script.unsubscribe is deprecated. Please use unsubscribe method of SSFGuest class instead, const guest = new ice.guest.SSFGuest(); guest.unsubscribe({ eventId: `${objectId}.${eventName}`, token });"
|
|
86
88
|
);
|
|
87
89
|
return getGuest().unsubscribe({
|
|
88
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
89
90
|
eventId: `${objectId}.${eventName}`,
|
|
90
91
|
token
|
|
91
92
|
});
|
package/dist/esm/guest.js
CHANGED
|
@@ -77,7 +77,6 @@ const getDiagnosticsAPIUrl = () => {
|
|
|
77
77
|
return diagnosticsEndpoint[hostName] || diagnosticsEndpoint["cdn.mortgagetech.q1.ice.com"];
|
|
78
78
|
};
|
|
79
79
|
class SSFGuest {
|
|
80
|
-
/* eslint-enable indent */
|
|
81
80
|
#correlationId;
|
|
82
81
|
#logger;
|
|
83
82
|
#remoting;
|
|
@@ -125,10 +124,6 @@ class SSFGuest {
|
|
|
125
124
|
* interval to keep host session alive.
|
|
126
125
|
*/
|
|
127
126
|
#keepAliveInterval = KEEP_ALIVE_INTERVAL;
|
|
128
|
-
/**
|
|
129
|
-
* options for the logger
|
|
130
|
-
*/
|
|
131
|
-
#loggerOptions;
|
|
132
127
|
/**
|
|
133
128
|
* throttled keep alive function
|
|
134
129
|
*/
|
|
@@ -142,13 +137,11 @@ class SSFGuest {
|
|
|
142
137
|
constructor(options) {
|
|
143
138
|
const {
|
|
144
139
|
console: logToConsole = false,
|
|
145
|
-
// eslint-disable-next-line no-underscore-dangle
|
|
146
140
|
url = window.__ICE__?.diagnosticsUrl || getDiagnosticsAPIUrl(),
|
|
147
141
|
index = "ssf-guest-v2",
|
|
148
142
|
team = "ICE",
|
|
149
143
|
appName = "SSF Guest V2 Application"
|
|
150
144
|
} = options?.logger ?? {};
|
|
151
|
-
this.#loggerOptions = options?.logger;
|
|
152
145
|
this.#usesDevConnectAPI = options?.usesDevConnectAPI ?? false;
|
|
153
146
|
this.#keepAlive = options?.keepAlive ?? true;
|
|
154
147
|
this.#keepAliveInterval = options?.keepAliveInterval ?? KEEP_ALIVE_INTERVAL;
|
|
@@ -197,12 +190,11 @@ class SSFGuest {
|
|
|
197
190
|
soJSON.functions.forEach((functionName) => {
|
|
198
191
|
Object.defineProperty(ctrl, functionName, {
|
|
199
192
|
value: async (...args) => {
|
|
200
|
-
const
|
|
201
|
-
const callerChain =
|
|
193
|
+
const proxiedFn = ctrl[functionName];
|
|
194
|
+
const callerChain = proxiedFn?.callContext?.callChain;
|
|
202
195
|
return this.#invoke({
|
|
203
196
|
objectId: ctrl.id,
|
|
204
197
|
functionName,
|
|
205
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
206
198
|
functionParams: [...args],
|
|
207
199
|
callerChain
|
|
208
200
|
});
|
|
@@ -389,13 +381,8 @@ class SSFGuest {
|
|
|
389
381
|
this.#logger.debug(`Received event "${eventId}" from host`);
|
|
390
382
|
let listeners;
|
|
391
383
|
if (body.eventHandler) {
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
395
|
-
callback: window[body.eventHandler],
|
|
396
|
-
token: uuidv4()
|
|
397
|
-
}
|
|
398
|
-
];
|
|
384
|
+
const handler = window[body.eventHandler];
|
|
385
|
+
listeners = handler ? [{ callback: handler, token: uuidv4() }] : [];
|
|
399
386
|
} else {
|
|
400
387
|
listeners = this.#eventListeners.get(eventId) || [];
|
|
401
388
|
}
|
|
@@ -403,7 +390,10 @@ class SSFGuest {
|
|
|
403
390
|
listeners.forEach((callbackInfo) => {
|
|
404
391
|
if (callbackInfo?.callback) {
|
|
405
392
|
if (callbackInfo.criteria) {
|
|
406
|
-
const criteriaMatched = body.eventParams ? this.#matchesCriteria(
|
|
393
|
+
const criteriaMatched = body.eventParams ? this.#matchesCriteria(
|
|
394
|
+
body.eventParams,
|
|
395
|
+
callbackInfo.criteria
|
|
396
|
+
) : false;
|
|
407
397
|
if (!criteriaMatched) {
|
|
408
398
|
this.#logger.debug(
|
|
409
399
|
`Event ${eventId} did not match criteria for subscriber ${callbackInfo.callback.name}`
|
|
@@ -557,24 +547,24 @@ class SSFGuest {
|
|
|
557
547
|
scriptEle.setAttribute("src", scriptUri);
|
|
558
548
|
scriptEle.setAttribute("type", "module");
|
|
559
549
|
await new Promise((resolve, reject) => {
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
550
|
+
const handlers = {
|
|
551
|
+
cleanup: () => {
|
|
552
|
+
scriptEle.removeEventListener("load", handlers.onScriptLoad);
|
|
553
|
+
scriptEle.removeEventListener("error", handlers.onScriptError);
|
|
554
|
+
},
|
|
555
|
+
onScriptLoad: () => {
|
|
556
|
+
handlers.cleanup();
|
|
557
|
+
this.#created = true;
|
|
558
|
+
setScriptOnlyGuest(true);
|
|
559
|
+
resolve();
|
|
560
|
+
},
|
|
561
|
+
onScriptError: () => {
|
|
562
|
+
handlers.cleanup();
|
|
563
|
+
reject(new Error(`Failed to load script: ${scriptUri}`));
|
|
564
|
+
}
|
|
575
565
|
};
|
|
576
|
-
scriptEle.addEventListener("load", onScriptLoad);
|
|
577
|
-
scriptEle.addEventListener("error", onScriptError);
|
|
566
|
+
scriptEle.addEventListener("load", handlers.onScriptLoad);
|
|
567
|
+
scriptEle.addEventListener("error", handlers.onScriptError);
|
|
578
568
|
this.#scriptElement = containerElement.appendChild(scriptEle);
|
|
579
569
|
});
|
|
580
570
|
}
|
|
@@ -582,6 +572,7 @@ class SSFGuest {
|
|
|
582
572
|
/**
|
|
583
573
|
* Close the connection to the host
|
|
584
574
|
*/
|
|
575
|
+
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
585
576
|
close = async () => {
|
|
586
577
|
if (!this.#isConnected) return;
|
|
587
578
|
if (this.#hostWindow && this.#hostOrigin) {
|
package/dist/esm/tests/utils.js
CHANGED
package/dist/esm/utils.js
CHANGED
|
@@ -3,7 +3,7 @@ const getParentWindowLocation = () => {
|
|
|
3
3
|
const { parent } = window;
|
|
4
4
|
try {
|
|
5
5
|
return parent?.location?.href;
|
|
6
|
-
} catch
|
|
6
|
+
} catch {
|
|
7
7
|
return null;
|
|
8
8
|
}
|
|
9
9
|
};
|
|
@@ -47,14 +47,14 @@ const getHostDetails = () => new Promise((resolve, reject) => {
|
|
|
47
47
|
if (!isEmbedded()) {
|
|
48
48
|
const currentWindow = window;
|
|
49
49
|
const expectedToken = getHandshakeToken();
|
|
50
|
-
|
|
50
|
+
const timerRef = {};
|
|
51
51
|
const onMessage = (event) => {
|
|
52
52
|
if (isHandshakeTrusted(event, expectedToken)) {
|
|
53
53
|
const { source, type } = event.data || {};
|
|
54
54
|
if (source === MESSAGE_SOURCE && type === MessageType.HandShake) {
|
|
55
55
|
const { origin } = event;
|
|
56
56
|
const hostWindow = event.source;
|
|
57
|
-
clearTimeout(
|
|
57
|
+
clearTimeout(timerRef.id);
|
|
58
58
|
sendMessage({
|
|
59
59
|
targetWin: hostWindow,
|
|
60
60
|
targetOrigin: origin,
|
|
@@ -66,7 +66,7 @@ const getHostDetails = () => new Promise((resolve, reject) => {
|
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
};
|
|
69
|
-
|
|
69
|
+
timerRef.id = setTimeout(() => {
|
|
70
70
|
currentWindow.removeEventListener("message", onMessage);
|
|
71
71
|
reject(
|
|
72
72
|
new Error(`Host handshake timed out after ${HANDSHAKE_TIMEOUT_MS}ms`)
|
package/dist/esm/v1-adapter.js
CHANGED
|
@@ -30,7 +30,9 @@ const setupV1Adapter = (guestV2 = null) => {
|
|
|
30
30
|
console.warn(
|
|
31
31
|
"elli.script.getObject is deprecated. Please use getObject method of SSFGuest class instead, const guest = new ice.guest.SSFGuest(); await guest.getObject(objectName);"
|
|
32
32
|
);
|
|
33
|
-
return getGuest().getObject(
|
|
33
|
+
return getGuest().getObject(
|
|
34
|
+
objectName
|
|
35
|
+
);
|
|
34
36
|
},
|
|
35
37
|
setLogLevel: (level) => {
|
|
36
38
|
if (!scriptOnlyGuest)
|
|
@@ -43,25 +45,24 @@ const setupV1Adapter = (guestV2 = null) => {
|
|
|
43
45
|
subscribe: (objectId, eventName, callback, options) => {
|
|
44
46
|
if (!scriptOnlyGuest)
|
|
45
47
|
console.warn(
|
|
46
|
-
// eslint-disable-next-line no-template-curly-in-string
|
|
47
48
|
"elli.script.subscribe is deprecated. Please use subscribe method of SSFGuest class instead, const guest = new ice.guest.SSFGuest(); guest.subscribe({ eventId: `${objectId}.${eventName}`, callback: (event) => { console.log(event); });"
|
|
48
49
|
);
|
|
49
50
|
return getGuest().subscribe({
|
|
50
51
|
eventId: `${objectId}.${eventName}`,
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
callback: ((event) => callback(
|
|
53
|
+
event?.obj,
|
|
54
|
+
event?.eventParams,
|
|
55
|
+
event?.eventOptions
|
|
56
|
+
)),
|
|
54
57
|
criteria: options?.criteria
|
|
55
58
|
});
|
|
56
59
|
},
|
|
57
60
|
unsubscribe: (objectId, eventName, token) => {
|
|
58
61
|
if (!scriptOnlyGuest)
|
|
59
62
|
console.warn(
|
|
60
|
-
// eslint-disable-next-line no-template-curly-in-string
|
|
61
63
|
"elli.script.unsubscribe is deprecated. Please use unsubscribe method of SSFGuest class instead, const guest = new ice.guest.SSFGuest(); guest.unsubscribe({ eventId: `${objectId}.${eventName}`, token });"
|
|
62
64
|
);
|
|
63
65
|
return getGuest().unsubscribe({
|
|
64
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
65
66
|
eventId: `${objectId}.${eventName}`,
|
|
66
67
|
token
|
|
67
68
|
});
|
|
@@ -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.e7547c98c8ccfd0654bd.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.e7547c98c8ccfd0654bd.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.e7547c98c8ccfd0654bd.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.e7547c98c8ccfd0654bd.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(U,A){typeof exports=="object"&&typeof module=="object"?module.exports=A(require("emuiDiagnostics")):typeof define=="function"&&define.amd?define(["emuiDiagnostics"],A):typeof exports=="object"?exports.ice=A(require("emuiDiagnostics")):(U.ice=U.ice||{},U.ice.guest=A(U.emuiDiagnostics))})(globalThis,Q=>(()=>{var U={759(c,u,a){var l=a(907),d=l.Symbol;c.exports=d},490(c,u,a){var l=a(759),d=a(817),S=a(748),v="[object Null]",w="[object Undefined]",k=l?l.toStringTag:void 0;function p(y){return y==null?y===void 0?w:v:k&&k in Object(y)?d(y):S(y)}c.exports=p},6(c,u,a){var l=a(82),d=/^\s+/;function S(v){return v&&v.slice(0,l(v)+1).replace(d,"")}c.exports=S},710(c){var u=typeof globalThis=="object"&&globalThis&&globalThis.Object===Object&&globalThis;c.exports=u},817(c,u,a){var l=a(759),d=Object.prototype,S=d.hasOwnProperty,v=d.toString,w=l?l.toStringTag:void 0;function k(p){var y=S.call(p,w),E=p[w];try{p[w]=void 0;var h=!0}catch{}var T=v.call(p);return h&&(y?p[w]=E:delete p[w]),T}c.exports=k},748(c){var u=Object.prototype,a=u.toString;function l(d){return a.call(d)}c.exports=l},907(c,u,a){var l=a(710),d=typeof self=="object"&&self&&self.Object===Object&&self,S=l||d||Function("return this")();c.exports=S},82(c){var u=/\s/;function a(l){for(var d=l.length;d--&&u.test(l.charAt(d)););return d}c.exports=a},671(c,u,a){var l=a(323),d=a(62),S=a(480),v="Expected a function",w=Math.max,k=Math.min;function p(y,E,h){var T,L,$,C,O,m,P=0,B=!1,W=!1,q=!0;if(typeof y!="function")throw new TypeError(v);E=S(E)||0,l(h)&&(B=!!h.leading,W="maxWait"in h,$=W?w(S(h.maxWait)||0,E):$,q="trailing"in h?!!h.trailing:q);function F(f){var _=T,G=L;return T=L=void 0,P=f,C=y.apply(G,_),C}function Z(f){return P=f,O=setTimeout(H,E),B?F(f):C}function K(f){var _=f-m,G=f-P,D=E-_;return W?k(D,$-G):D}function N(f){var _=f-m,G=f-P;return m===void 0||_>=E||_<0||W&&G>=$}function H(){var f=d();if(N(f))return V(f);O=setTimeout(H,K(f))}function V(f){return O=void 0,q&&T?F(f):(T=L=void 0,C)}function J(){O!==void 0&&clearTimeout(O),P=0,T=m=L=O=void 0}function Y(){return O===void 0?C:V(d())}function R(){var f=d(),_=N(f);if(T=arguments,L=this,m=f,_){if(O===void 0)return Z(m);if(W)return clearTimeout(O),O=setTimeout(H,E),F(m)}return O===void 0&&(O=setTimeout(H,E)),C}return R.cancel=J,R.flush=Y,R}c.exports=p},323(c){function u(a){var l=typeof a;return a!=null&&(l=="object"||l=="function")}c.exports=u},292(c){function u(a){return a!=null&&typeof a=="object"}c.exports=u},964(c,u,a){var l=a(490),d=a(292),S="[object Symbol]";function v(w){return typeof w=="symbol"||d(w)&&l(w)==S}c.exports=v},62(c,u,a){var l=a(907),d=function(){return l.Date.now()};c.exports=d},712(c,u,a){var l=a(671),d=a(323),S="Expected a function";function v(w,k,p){var y=!0,E=!0;if(typeof w!="function")throw new TypeError(S);return d(p)&&(y="leading"in p?!!p.leading:y,E="trailing"in p?!!p.trailing:E),l(w,k,{leading:y,maxWait:k,trailing:E})}c.exports=v},480(c,u,a){var l=a(6),d=a(323),S=a(964),v=NaN,w=/^[-+]0x[0-9a-f]+$/i,k=/^0b[01]+$/i,p=/^0o[0-7]+$/i,y=parseInt;function E(h){if(typeof h=="number")return h;if(S(h))return v;if(d(h)){var T=typeof h.valueOf=="function"?h.valueOf():h;h=d(T)?T+"":T}if(typeof h!="string")return h===0?h:+h;h=l(h);var L=k.test(h);return L||p.test(h)?y(h.slice(2),L?2:8):w.test(h)?v:+h}c.exports=E},388(c){"use strict";c.exports=Q}},A={};function x(c){var u=A[c];if(u!==void 0)return u.exports;var a=A[c]={exports:{}};return U[c](a,a.exports,x),a.exports}x.n=c=>{var u=c&&c.__esModule?()=>c.default:()=>c;return x.d(u,{a:u}),u},x.d=(c,u)=>{for(var a in u)x.o(u,a)&&!x.o(c,a)&&Object.defineProperty(c,a,{enumerable:!0,get:u[a]})},x.o=(c,u)=>Object.prototype.hasOwnProperty.call(c,u),x.r=c=>{typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(c,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(c,"__esModule",{value:!0})};var z={};return(()=>{"use strict";x.r(z),x.d(z,{SSFGuest:()=>pe});const c=new Uint8Array(16);function u(){return crypto.getRandomValues(c)}var a;const l=[];for(let i=0;i<256;++i)l.push((i+256).toString(16).slice(1));function d(i,e=0){return(l[i[e+0]]+l[i[e+1]]+l[i[e+2]]+l[i[e+3]]+"-"+l[i[e+4]]+l[i[e+5]]+"-"+l[i[e+6]]+l[i[e+7]]+"-"+l[i[e+8]]+l[i[e+9]]+"-"+l[i[e+10]]+l[i[e+11]]+l[i[e+12]]+l[i[e+13]]+l[i[e+14]]+l[i[e+15]]).toLowerCase()}function S(i,e=0){const t=d(i,e);if(!a(t))throw TypeError("Stringified UUID is invalid");return t}const v=null;function w(i,e,t){return!e&&!i&&crypto.randomUUID?crypto.randomUUID():k(i,e,t)}function k(i,e,t){i=i||{};const s=i.random??i.rng?.()??u();if(s.length<16)throw new Error("Random bytes length must be >= 16");if(s[6]=s[6]&15|64,s[8]=s[8]&63|128,e){if(t=t||0,t<0||t+16>e.length)throw new RangeError(`UUID byte range ${t}:${t+15} is out of buffer bounds`);for(let n=0;n<16;++n)e[t+n]=s[n];return e}return d(s)}const p=w;var y=x(712),E=x.n(y);const h="elli:remoting",T="elli:remoting:response",L="elli:remoting:exception",$=({messageType:i,messageBody:e,requestId:t,onewayMsg:s=!1})=>({requestId:t??(s?null:p()),source:h,type:i,body:e}),C=i=>{const{targetWin:e,targetOrigin:t,messageType:s,messageBody:n}=i,o=$({messageType:s,messageBody:n});e.postMessage(o,t)};class O{#s;#e;#t=new Map;#n=new Map;#r=null;#i=null;#a=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}#f=()=>{this.#r=null;const e=Date.now(),t=[];let s=null;if(this.#n.forEach((n,o)=>{const{requestId:r,cancelTime:g}=n;g&&g<=e?(this.#e.debug(`Detected response timeout for requestId: ${r}...`),t.push(o),n.resolve(void 0)):g&&(s=s===null?g:Math.min(s,g))}),t.forEach(n=>{this.#n.delete(n)}),s!==null){const n=Math.max(s-Date.now(),0);this.#h(n)}};#h=e=>{this.#r===null&&(this.#r=window.setTimeout(this.#f,e))};#b=()=>{this.#r!==null&&(window.clearTimeout(this.#r),this.#r=null)};#o=e=>{const t=this.#n.get(e);return this.#e.debug(`serving requestId: ${e}`),this.#n.delete(e),t};#c=e=>{const{requestId:t}=e;this.#e.debug(`Response received for invocation requestId: ${t}`);const s=this.#o(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.#o(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(o=>{this.#e.debug(`Invoking message handler ${o.name}`),o({sourceWin:e,sourceOrigin:t,requestId:s.requestId,type:s.type,body:s.body})}),!0):!1};#l=e=>{if(this.#a.size===0||!e.source)return!1;const t=this.#a.get(e.source);return!t||e?.data?.source!==h?!1:(this.#e.debug(`Remoting: Received message of type "${e.data.type}"`),e.data.type===T?this.#c(e.data):e.data.type===L?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.#a.set(s,t)};initialize=e=>{this.#i&&this.#i.removeEventListener("message",this.#l),e.addEventListener("message",this.#l),this.#i=e,this.#e.debug(`initialized remoting id: ${this.#s}`)};close=()=>{this.#i&&(this.#i.removeEventListener("message",this.#l),this.#i=null),this.#b(),this.#e.debug(`closed remoting id: ${this.#s}`)};invoke=e=>{const{targetWin:t,targetOrigin:s,messageType:n,messageBody:o,responseTimeoutMs:r}=e;return new Promise((g,I)=>{const b=$({messageType:n,messageBody:o});this.#n.set(b.requestId,{requestId:b.requestId,resolve:g,reject:I,cancelTime:r?Date.now()+r:null}),t.postMessage(b,s);const{requestId:j}=b;this.#e.debug(`Posted invocation message of type ${n} requestId: ${j||""}`),r&&(this.#e.debug(`scheduling timeout check for requestId: ${j||""} in ${r} ms`),this.#h(r))})};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 o=n.indexOf(s);o!==-1&&n.splice(o,1)};send=e=>{const{targetWin:t,targetOrigin:s,messageType:n,messageBody:o}=e,r=$({messageType:n,messageBody:o,onewayMsg:!0});t.postMessage(r,s),this.#e.debug(`Posted one-way message of type "${n}"`)};removeSender=e=>{const{window:t}=e;t&&this.#a.delete(t)};respond=e=>{const{targetWin:t,targetOrigin:s,requestId:n,response:o}=e,r=$({messageType:T,messageBody:o,requestId:n});t.postMessage(r,s),this.#e.debug(`Response sent to caller for invocation requestId: ${n}`)};raiseException=e=>{const{targetWin:t,targetOrigin:s,requestId:n,ex:o}=e,r=o instanceof Error?o.message:o,g=$({messageType:L,messageBody:r,requestId:n});t.postMessage(g,s),this.#e.debug(`Exception sent to caller for invocation. requestId: ${n}`)}}var m=(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))(m||{});class P{#s;#e;#t;#n=new Map;static DEFAULT_THROTTLE_MS=1e4;constructor(e){this.#s=e.logger,this.#e=e.enabled??!0,this.#t=e.throttleMs??P.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.#n.get(e);if(n!==void 0&&s-n<this.#t){this.#s.debug(t);return}this.#n.set(e,s)}this.#s.audit(t)}}class B{__TYPE__="Proxy";id;objectType;constructor(e,t){this.id=e,this.objectType=t}}const W=i=>{if(typeof i!="object"||i===null)return!1;const e=i;return e.constructor?.name==="Proxy"||e.constructor?.name==="ScriptingObjectProxy"||e.__TYPE__==="Proxy"};class q{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"}#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 Z=i=>i instanceof q,K=(i,e)=>`${i.toLowerCase()}.${e.toLowerCase()}`,N=new Map;function H(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 V(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??N;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 J(i){return i!=null&&Object.keys(i).length>0}function Y(i,e,t){return Object.entries(e).every(([s,n])=>V(i[s],n,t?.regexCache))}var R=x(388);const f=()=>{const{parent:i}=window;try{return i?.location?.href}catch{return null}},_=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"*"}}},G=()=>window.self!==window.parent,D=(i,e)=>{const t=e||document.body,s=document.defaultView?.getComputedStyle?.(t,null),n=s?s[i]:"0";return parseInt(n,10)},oe="elli:remoting",ee=3e4,ce=()=>{try{return new URLSearchParams(window.location.hash.slice(1)).get("hs")}catch{return null}},ae=(i,e)=>!!(window.opener&&i.source===window.opener||e&&i.data?.handshakeToken===e),le=()=>new Promise((i,e)=>{if(G())i({origin:_(document.referrer||f()),window:window.parent});else{const t=window,s=ce(),n={},o=r=>{if(ae(r,s)){const{source:g,type:I}=r.data||{};if(g===oe&&I===m.HandShake){const{origin:b}=r,j=r.source;clearTimeout(n.id),C({targetWin:j,targetOrigin:b,messageType:m.HandShakeAck,messageBody:{}}),t.removeEventListener("message",o),i({origin:b,window:j})}}};n.id=setTimeout(()=>{t.removeEventListener("message",o),e(new Error(`Host handshake timed out after ${ee}ms`))},ee),t.addEventListener("message",o)}});let M=!1;const ue=i=>{M=i},te=(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)},connect:s=>t().connect(s),getObject:s=>t().getObject(s),setLogLevel:s=>t().setLogLevel(s),subscribe:(s,n,o,r)=>t().subscribe({eventId:`${s}.${n}`,callback:(g=>o(g?.obj,g?.eventParams,g?.eventOptions)),criteria:r?.criteria}),unsubscribe:(s,n,o)=>t().unsubscribe({eventId:`${s}.${n}`,token:o})}};try{te()}catch{}var fe=null;const se=12e4,de=2e3,he={eventFeedback:!0},ie=()=>{const{document:i}=window,e=i.body,t=i.documentElement,n={height:e.offsetHeight+D("marginTop")+D("marginBottom"),width:Math.max(e.scrollWidth,t.scrollWidth)};C({targetWin:window.parent,targetOrigin:_(i.referrer||f()),messageType:m.GuestResize,messageBody:n}),window.removeEventListener("load",ie)};G()&&window.addEventListener("load",ie);const ne={"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"},re=["click","scroll","keypress","touchstart"],ge=()=>{const i=document.currentScript?.src||"file:///opt/jenkins/workspace/UIPlatform_pui-microfe_alpha/13/libs/ssf-guest/lib/guest.ts",e=i?new URL(i).hostname:"localhost";return ne[e]||ne["cdn.mortgagetech.q1.ice.com"]};class pe{#s;#e;#t;#n=!1;#r=null;#i=!1;#a=new Map;#f=null;#h=null;#b=null;#o=null;#c=null;#g=null;#y=new Map;#l(){if(!this.#c||!this.#o)throw new Error("Guest is not connected to a host. Call connect() first.");return{hostWindow:this.#c,hostOrigin:this.#o}}#S=!1;#u=null;#p=null;#w=null;#T=!0;#j=se;#v=null;#m;constructor(e){const{console:t=!1,url:s=window.__ICE__?.diagnosticsUrl||ge(),index:n="ssf-guest-v2",team:o="ICE",appName:r="SSF Guest V2 Application"}=e?.logger??{};this.#S=e?.usesDevConnectAPI??!1,this.#T=e?.keepAlive??!0,this.#j=e?.keepAliveInterval??se;const g=t?(0,R.Console)():(0,R.http)(s);this.#e=e?.appLogger??(0,R.logger)({transport:g,index:n,team:o,appName:r}),this.#m=new P({logger:this.#e,enabled:e?.auditOperations,throttleMs:e?.auditThrottleMs}),(0,R.webvitals)(this.#e),(0,R.logUnhandledErrors)(this.#e),this.#s=p(),this.#t=new O(this.#e,this.#s),te(this),this.#e.audit({message:"Guest created",guestUrl:window.location.href,correlationId:this.#s})}#d=()=>({guestId:this.#f,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 B(e.objectId,e.objectType);return e.functions&&e.functions.forEach(s=>{Object.defineProperty(t,s,{value:async(...n)=>{const r=t[s]?.callContext?.callChain;return this.#O({objectId:t.id,functionName:s,functionParams:[...n],callerChain:r})},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};#O=async({objectId:e,functionName:t,functionParams:s,callerChain:n})=>{this.#e.debug(`Invoking scripting object method ${e}.${t}()...`);const o=[];if(s)for(let j=0;j<s.length;j+=1){const X=s[j];X instanceof Promise&&o.push(X.then(me=>{s[j]=me}))}await Promise.all(o);const{hostWindow:r,hostOrigin:g}=this.#l(),I=await this.#t.invoke({targetWin:r,targetOrigin:g,messageType:m.ObjectInvoke,messageBody:{objectId:e,functionName:t,functionParams:s,...n?.length?{callerChain:n}:{}}}),b=this.#k(I);return this.#m.log(`invoke:${e}.${t}`,{message:"Guest proxy invoked Scripting Object method",scriptingObject:e,scriptingMethod:t,...this.#d()}),b};#x(e,t){return Y(e,t,{regexCache:this.#y})}#k=e=>e?.type==="object"&&"object"in e?this.#E(e.object):e?.type==="value"?e.value:e;#I=({body:e})=>{e?.logLevel&&(this.#e.setLogLevel(e.logLevel),this.#e.debug(`Log level changed by host to ${e.logLevel}`)),this.#f=e?.guestId??null,this.#h=e?.guestTitle??null,this.#b=e?.guestUrl??null,this.#e.audit({message:"Received configuration from Host",...this.#d()})};#L=()=>{window.focus()};#_=async()=>{await this.close(),window.close()};#$=()=>{G()||(this.#g=setInterval(()=>{this.#c?.closed&&this.close().then(()=>{window.close()}).catch(()=>{})},1e3))};#C=async({sourceWin:e,sourceOrigin:t,requestId:s,body:n})=>{const o=this.#E(n.object);if(o){const r=K(o.id,n.eventName);this.#e.debug(`Received event "${r}" from host`);let g;if(n.eventHandler){const b=window[n.eventHandler];g=b?[{callback:b,token:p()}]:[]}else g=this.#a.get(r)||[];const I=[];if(g.forEach(b=>{if(b?.callback){if(b.criteria&&!(n.eventParams?this.#x(n.eventParams,b.criteria):!1)){this.#e.debug(`Event ${r} did not match criteria for subscriber ${b.callback.name}`);return}this.#e.debug(`Invoking event subscriber ${b.callback.name} for event ${r}`);const j=b.callback({obj:o,eventName:n.eventName,eventParams:n.eventParams,eventOptions:n.eventOptions});j instanceof Promise?I.push(j):typeof j<"u"&&I.push(Promise.resolve(j))}}),s){const b=await Promise.all(I);this.#t.respond({targetWin:e,targetOrigin:t,requestId:s,response:b}),this.#m.log(`event:${r}`,{message:"Guest proxy processed event from host and responded",scriptingEventId:r,scriptingObject:o.id,...this.#d()})}else this.#m.log(`event:${r}`,{message:"Guest proxy processed event from host",scriptingEventId:r,scriptingObject:o.id,...this.#d()})}};#P=async()=>{if(!(!this.#u||!this.#p||!this.#w))try{await fetch(`${this.#w}/oauth2/v1/token/introspection?${new URLSearchParams({token:this.#u,client_id:this.#p}).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}`)}};#R=async()=>{if(this.#u&&this.#p&&this.#w)try{await fetch(`${this.#w}/oauth2/v1/token/revocation?${new URLSearchParams({token:this.#u,client_id:this.#p}).toString()}`,{method:"POST"})}catch(e){this.#e.error(`Error revoking token. ${e.message}`)}finally{this.#u=null,this.#p=null}};#G=async()=>{if(this.#T)try{const e=await Promise.race([this.getObject("application"),new Promise(t=>{setTimeout(()=>t(null),de)})]);e?(this.#v=E()(async()=>{try{await e.keepSessionAlive(),await this.#P()}catch(t){this.#e.error(`Error keeping session alive. ${t.message}`)}},this.#j,{leading:!1}),re.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)=>{if(!this.#n&&e){await this.connect();const s=document.createElement("script");s.setAttribute("src",e),s.setAttribute("type","module"),await new Promise((n,o)=>{const r={cleanup:()=>{s.removeEventListener("load",r.onScriptLoad),s.removeEventListener("error",r.onScriptError)},onScriptLoad:()=>{r.cleanup(),this.#n=!0,ue(!0),n()},onScriptError:()=>{r.cleanup(),o(new Error(`Failed to load script: ${e}`))}};s.addEventListener("load",r.onScriptLoad),s.addEventListener("error",r.onScriptError),this.#r=t.appendChild(s)})}};close=async()=>{this.#i&&(this.#c&&this.#o&&(this.#t.send({targetWin:this.#c,targetOrigin:this.#o,messageType:m.GuestClose,messageBody:{}}),this.#t.removeSender({origin:this.#o,window:this.#c})),this.#t.close(),this.#g&&(clearInterval(this.#g),this.#g=null),this.#v&&re.forEach(e=>{document.removeEventListener(e,this.#v)}),await this.#R(),window.removeEventListener("beforeunload",this.close),this.#i=!1,this.#e.audit({message:"Guest disconnected from host",...this.#d()}),this.#f=null,this.#b=null,this.#h=null)};connect=async e=>{if(!this.#i){let t=window,s={...he};if(e){const{window:o,...r}=e;o&&(t=o),s={...s,...r}}const n=await le();this.#o=n.origin,this.#c=n.window,this.#t.initialize(t),this.#t.addSender({origin:this.#o,window:this.#c}),this.#t.listen({messageType:m.ObjectEvent,callback:this.#C.bind(this)}),this.#t.listen({messageType:m.HostConfig,callback:this.#I.bind(this)}),this.#t.listen({messageType:m.GuestFocus,callback:this.#L.bind(this)}),this.#t.listen({messageType:m.HostClose,callback:this.#_.bind(this)}),this.#t.send({targetWin:this.#c,targetOrigin:this.#o,messageType:m.GuestReady,messageBody:s}),this.#i=!0,this.#$(),this.#S&&await this.getAuthToken(),await this.#G(),window.addEventListener("beforeunload",this.close),this.#e.audit({message:"Guest connected to host",guestUrl:window.location.href})}};getAuthToken=async()=>{if(!this.#u&&this.#i)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.#p=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.#i)throw new Error("Not connected to host");const{hostWindow:t,hostOrigin:s}=this.#l(),n=await this.#t.invoke({targetWin:t,targetOrigin:s,messageType:m.ObjectGet,messageBody:{objectId:e}}),o=this.#E(n.object);return this.#m.log(`getObject:${e}`,{message:"Received scripting object from host",scriptingObject:e,...this.#d()}),o};listObjects=async()=>{if(this.#e.debug("Retrieving names of scripting objects exposed by host..."),!this.#i)throw new Error("Not connected to host");const{hostWindow:e,hostOrigin:t}=this.#l(),s=await this.#t.invoke({targetWin:e,targetOrigin:t,messageType:m.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.#n&&this.#r){const{parentNode:e}=this.#r;e?.removeChild?.(this.#r)}};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}=e;this.#e.debug(`Registering subscription for event ${t}`);const o=this.#a.get(t.toLowerCase())||[],r=p();o.push({callback:n,token:r,criteria:s}),this.#a.set(t.toLowerCase(),o);const{hostWindow:g,hostOrigin:I}=this.#l();return this.#t.send({targetWin:g,targetOrigin:I,messageType:m.GuestEventSubscribe,messageBody:{eventId:t,criteria:s,token:r}}),this.#e.debug(`Subscribed to event ${t} with token ${r}`),r};unsubscribe=e=>{const{eventId:t,token:s}=e,n=this.#a.get(t.toLowerCase());if(n){const o=n.length,r=n.filter(g=>g.token!==s);if(r.length<o){this.#a.set(t.toLowerCase(),r);const{hostWindow:g,hostOrigin:I}=this.#l();this.#t.send({targetWin:g,targetOrigin:I,messageType:m.GuestEventUnsubscribe,messageBody:{eventId:t,token:s}}),this.#e.debug(`Unsubscribed from event ${t}`)}}}}})(),z})());
|
|
2
|
+
|
|
3
|
+
//# sourceMappingURL=emuiSsfGuest.e7547c98c8ccfd0654bd.js.map
|
|
Binary file
|
|
Binary file
|