@interopio/desktop 6.2.2 → 6.4.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/changelog.md +13 -0
- package/desktop.d.ts +265 -22
- package/dist/desktop.browser.js +1196 -1015
- package/dist/desktop.browser.js.map +1 -1
- package/dist/desktop.browser.min.js +1 -1
- package/dist/desktop.browser.min.js.map +1 -1
- package/dist/desktop.es.js +1196 -1015
- package/dist/desktop.es.js.map +1 -1
- package/dist/desktop.umd.js +1196 -1015
- package/dist/desktop.umd.js.map +1 -1
- package/dist/desktop.umd.min.js +1 -1
- package/dist/desktop.umd.min.js.map +1 -1
- package/package.json +5 -5
package/dist/desktop.browser.js
CHANGED
|
@@ -1321,6 +1321,7 @@
|
|
|
1321
1321
|
return __generator(this, function (_b) {
|
|
1322
1322
|
switch (_b.label) {
|
|
1323
1323
|
case 0:
|
|
1324
|
+
this.logger.info("opening ws to ".concat(this.settings.ws, ", retryInterval: ").concat(retryInterval, ", retriesLeft: ").concat(retriesLeft, "..."));
|
|
1324
1325
|
this.startupTimer.mark("opening-socket");
|
|
1325
1326
|
if (retryInterval === undefined) {
|
|
1326
1327
|
retryInterval = this.settings.reconnectInterval;
|
|
@@ -1358,9 +1359,10 @@
|
|
|
1358
1359
|
};
|
|
1359
1360
|
WS.prototype.initiateSocket = function () {
|
|
1360
1361
|
var _this = this;
|
|
1362
|
+
var _a;
|
|
1361
1363
|
var pw = new PromiseWrapper();
|
|
1362
1364
|
this.logger.debug("initiating ws to ".concat(this.settings.ws, "..."));
|
|
1363
|
-
this.ws = new WebSocketConstructor(this.settings.ws
|
|
1365
|
+
this.ws = new WebSocketConstructor((_a = this.settings.ws) !== null && _a !== void 0 ? _a : "");
|
|
1364
1366
|
this.ws.onerror = function (err) {
|
|
1365
1367
|
var reason = "";
|
|
1366
1368
|
try {
|
|
@@ -1379,11 +1381,12 @@
|
|
|
1379
1381
|
};
|
|
1380
1382
|
reason = JSON.stringify(err, replacer);
|
|
1381
1383
|
}
|
|
1384
|
+
_this.logger.info("ws error - reason: ".concat(reason));
|
|
1382
1385
|
pw.reject("error");
|
|
1383
1386
|
_this.notifyStatusChanged(false, reason);
|
|
1384
1387
|
};
|
|
1385
1388
|
this.ws.onclose = function (err) {
|
|
1386
|
-
_this.logger.info("ws closed ".concat(err));
|
|
1389
|
+
_this.logger.info("ws closed - code: ".concat(err === null || err === void 0 ? void 0 : err.code, " reason: ").concat(err === null || err === void 0 ? void 0 : err.reason));
|
|
1387
1390
|
pw.reject("closed");
|
|
1388
1391
|
_this.notifyStatusChanged(false);
|
|
1389
1392
|
};
|
|
@@ -1418,6 +1421,80 @@
|
|
|
1418
1421
|
return WS;
|
|
1419
1422
|
}());
|
|
1420
1423
|
|
|
1424
|
+
var MessageReplayerImpl = (function () {
|
|
1425
|
+
function MessageReplayerImpl(specs) {
|
|
1426
|
+
this.specsNames = [];
|
|
1427
|
+
this.messages = {};
|
|
1428
|
+
this.subs = {};
|
|
1429
|
+
this.subsRefCount = {};
|
|
1430
|
+
this.specs = {};
|
|
1431
|
+
for (var _i = 0, specs_1 = specs; _i < specs_1.length; _i++) {
|
|
1432
|
+
var spec = specs_1[_i];
|
|
1433
|
+
this.specs[spec.name] = spec;
|
|
1434
|
+
this.specsNames.push(spec.name);
|
|
1435
|
+
}
|
|
1436
|
+
}
|
|
1437
|
+
MessageReplayerImpl.prototype.init = function (connection) {
|
|
1438
|
+
var _this = this;
|
|
1439
|
+
this.connection = connection;
|
|
1440
|
+
for (var _i = 0, _a = this.specsNames; _i < _a.length; _i++) {
|
|
1441
|
+
var name_1 = _a[_i];
|
|
1442
|
+
var _loop_1 = function (type) {
|
|
1443
|
+
var refCount = this_1.subsRefCount[type];
|
|
1444
|
+
if (!refCount) {
|
|
1445
|
+
refCount = 0;
|
|
1446
|
+
}
|
|
1447
|
+
refCount += 1;
|
|
1448
|
+
this_1.subsRefCount[type] = refCount;
|
|
1449
|
+
if (refCount > 1) {
|
|
1450
|
+
return "continue";
|
|
1451
|
+
}
|
|
1452
|
+
var sub = connection.on(type, function (msg) { return _this.processMessage(type, msg); });
|
|
1453
|
+
this_1.subs[type] = sub;
|
|
1454
|
+
};
|
|
1455
|
+
var this_1 = this;
|
|
1456
|
+
for (var _b = 0, _c = this.specs[name_1].types; _b < _c.length; _b++) {
|
|
1457
|
+
var type = _c[_b];
|
|
1458
|
+
_loop_1(type);
|
|
1459
|
+
}
|
|
1460
|
+
}
|
|
1461
|
+
};
|
|
1462
|
+
MessageReplayerImpl.prototype.processMessage = function (type, msg) {
|
|
1463
|
+
if (this.isDone || !msg) {
|
|
1464
|
+
return;
|
|
1465
|
+
}
|
|
1466
|
+
for (var _i = 0, _a = this.specsNames; _i < _a.length; _i++) {
|
|
1467
|
+
var name_2 = _a[_i];
|
|
1468
|
+
if (this.specs[name_2].types.indexOf(type) !== -1) {
|
|
1469
|
+
var messages = this.messages[name_2] || [];
|
|
1470
|
+
this.messages[name_2] = messages;
|
|
1471
|
+
messages.push(msg);
|
|
1472
|
+
}
|
|
1473
|
+
}
|
|
1474
|
+
};
|
|
1475
|
+
MessageReplayerImpl.prototype.drain = function (name, callback) {
|
|
1476
|
+
var _a;
|
|
1477
|
+
if (callback) {
|
|
1478
|
+
(this.messages[name] || []).forEach(callback);
|
|
1479
|
+
}
|
|
1480
|
+
delete this.messages[name];
|
|
1481
|
+
for (var _i = 0, _b = this.specs[name].types; _i < _b.length; _i++) {
|
|
1482
|
+
var type = _b[_i];
|
|
1483
|
+
this.subsRefCount[type] -= 1;
|
|
1484
|
+
if (this.subsRefCount[type] <= 0) {
|
|
1485
|
+
(_a = this.connection) === null || _a === void 0 ? void 0 : _a.off(this.subs[type]);
|
|
1486
|
+
delete this.subs[type];
|
|
1487
|
+
delete this.subsRefCount[type];
|
|
1488
|
+
}
|
|
1489
|
+
}
|
|
1490
|
+
delete this.specs[name];
|
|
1491
|
+
if (!this.specs.length) {
|
|
1492
|
+
this.isDone = true;
|
|
1493
|
+
}
|
|
1494
|
+
};
|
|
1495
|
+
return MessageReplayerImpl;
|
|
1496
|
+
}());
|
|
1497
|
+
|
|
1421
1498
|
var shortidExports = {};
|
|
1422
1499
|
var shortid$1 = {
|
|
1423
1500
|
get exports(){ return shortidExports; },
|
|
@@ -1766,743 +1843,127 @@
|
|
|
1766
1843
|
|
|
1767
1844
|
var shortid = /*@__PURE__*/getDefaultExportFromCjs(shortidExports);
|
|
1768
1845
|
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
connection.on("result", function (msg) { return handleSuccessMessage(msg); });
|
|
1785
|
-
if (successMessages) {
|
|
1786
|
-
successMessages.forEach(function (sm) {
|
|
1787
|
-
connection.on(sm, function (msg) { return handleSuccessMessage(msg); });
|
|
1846
|
+
var PromisePlus$1 = function (executor, timeoutMilliseconds, timeoutMessage) {
|
|
1847
|
+
return new Promise(function (resolve, reject) {
|
|
1848
|
+
var timeout = setTimeout(function () {
|
|
1849
|
+
var message = timeoutMessage || "Promise timeout hit: ".concat(timeoutMilliseconds);
|
|
1850
|
+
reject(message);
|
|
1851
|
+
}, timeoutMilliseconds);
|
|
1852
|
+
var providedPromise = new Promise(executor);
|
|
1853
|
+
providedPromise
|
|
1854
|
+
.then(function (result) {
|
|
1855
|
+
clearTimeout(timeout);
|
|
1856
|
+
resolve(result);
|
|
1857
|
+
})
|
|
1858
|
+
.catch(function (error) {
|
|
1859
|
+
clearTimeout(timeout);
|
|
1860
|
+
reject(error);
|
|
1788
1861
|
});
|
|
1862
|
+
});
|
|
1863
|
+
};
|
|
1864
|
+
|
|
1865
|
+
var WebPlatformTransport = (function () {
|
|
1866
|
+
function WebPlatformTransport(settings, logger, identity) {
|
|
1867
|
+
this.settings = settings;
|
|
1868
|
+
this.logger = logger;
|
|
1869
|
+
this.identity = identity;
|
|
1870
|
+
this.iAmConnected = false;
|
|
1871
|
+
this.parentReady = false;
|
|
1872
|
+
this.rejected = false;
|
|
1873
|
+
this.children = [];
|
|
1874
|
+
this.extContentAvailable = false;
|
|
1875
|
+
this.extContentConnecting = false;
|
|
1876
|
+
this.extContentConnected = false;
|
|
1877
|
+
this.parentInExtMode = false;
|
|
1878
|
+
this.webNamespace = "g42_core_web";
|
|
1879
|
+
this.parentPingTimeout = 5000;
|
|
1880
|
+
this.connectionRequestTimeout = 7000;
|
|
1881
|
+
this.defaultTargetString = "*";
|
|
1882
|
+
this.registry = lib$1();
|
|
1883
|
+
this.messages = {
|
|
1884
|
+
connectionAccepted: { name: "connectionAccepted", handle: this.handleConnectionAccepted.bind(this) },
|
|
1885
|
+
connectionRejected: { name: "connectionRejected", handle: this.handleConnectionRejected.bind(this) },
|
|
1886
|
+
connectionRequest: { name: "connectionRequest", handle: this.handleConnectionRequest.bind(this) },
|
|
1887
|
+
parentReady: {
|
|
1888
|
+
name: "parentReady", handle: function () {
|
|
1889
|
+
}
|
|
1890
|
+
},
|
|
1891
|
+
parentPing: { name: "parentPing", handle: this.handleParentPing.bind(this) },
|
|
1892
|
+
platformPing: { name: "platformPing", handle: this.handlePlatformPing.bind(this) },
|
|
1893
|
+
platformReady: { name: "platformReady", handle: this.handlePlatformReady.bind(this) },
|
|
1894
|
+
clientUnload: { name: "clientUnload", handle: this.handleClientUnload.bind(this) },
|
|
1895
|
+
manualUnload: { name: "manualUnload", handle: this.handleManualUnload.bind(this) },
|
|
1896
|
+
extConnectionResponse: { name: "extConnectionResponse", handle: this.handleExtConnectionResponse.bind(this) },
|
|
1897
|
+
extSetupRequest: { name: "extSetupRequest", handle: this.handleExtSetupRequest.bind(this) },
|
|
1898
|
+
gatewayDisconnect: { name: "gatewayDisconnect", handle: this.handleGatewayDisconnect.bind(this) },
|
|
1899
|
+
gatewayInternalConnect: { name: "gatewayInternalConnect", handle: this.handleGatewayInternalConnect.bind(this) }
|
|
1900
|
+
};
|
|
1901
|
+
this.extContentAvailable = !!window.glue42ext;
|
|
1902
|
+
this.setUpMessageListener();
|
|
1903
|
+
this.setUpUnload();
|
|
1904
|
+
this.setupPlatformUnloadListener();
|
|
1905
|
+
this.parentType = window.name.includes("#wsp") ? "workspace" : undefined;
|
|
1789
1906
|
}
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1907
|
+
WebPlatformTransport.prototype.manualSetReadyState = function () {
|
|
1908
|
+
this.iAmConnected = true;
|
|
1909
|
+
this.parentReady = true;
|
|
1910
|
+
};
|
|
1911
|
+
Object.defineProperty(WebPlatformTransport.prototype, "transportWindowId", {
|
|
1912
|
+
get: function () {
|
|
1913
|
+
return this.publicWindowId;
|
|
1914
|
+
},
|
|
1915
|
+
enumerable: false,
|
|
1916
|
+
configurable: true
|
|
1917
|
+
});
|
|
1918
|
+
Object.defineProperty(WebPlatformTransport.prototype, "communicationId", {
|
|
1919
|
+
get: function () {
|
|
1920
|
+
return this._communicationId;
|
|
1921
|
+
},
|
|
1922
|
+
enumerable: false,
|
|
1923
|
+
configurable: true
|
|
1924
|
+
});
|
|
1925
|
+
WebPlatformTransport.prototype.sendObject = function (msg) {
|
|
1926
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1927
|
+
return __generator(this, function (_a) {
|
|
1928
|
+
if (this.extContentConnected) {
|
|
1929
|
+
return [2, window.postMessage({ glue42ExtOut: msg }, this.defaultTargetString)];
|
|
1930
|
+
}
|
|
1931
|
+
if (!this.port) {
|
|
1932
|
+
throw new Error("Cannot send message, because the port was not opened yet");
|
|
1933
|
+
}
|
|
1934
|
+
this.port.postMessage(msg);
|
|
1935
|
+
return [2];
|
|
1936
|
+
});
|
|
1793
1937
|
});
|
|
1794
|
-
}
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
logger.debug("error joining " + domain + " domain: " + JSON.stringify(err));
|
|
1824
|
-
reject(err);
|
|
1825
|
-
});
|
|
1826
|
-
});
|
|
1827
|
-
}
|
|
1828
|
-
function leave() {
|
|
1829
|
-
if (domain === "global") {
|
|
1830
|
-
return Promise.resolve();
|
|
1831
|
-
}
|
|
1832
|
-
logger.debug("stopping session " + domain + "...");
|
|
1833
|
-
var leaveMsg = {
|
|
1834
|
-
type: "leave",
|
|
1835
|
-
destination: domain,
|
|
1836
|
-
domain: "global",
|
|
1837
|
-
};
|
|
1838
|
-
tryReconnecting = false;
|
|
1839
|
-
return send(leaveMsg)
|
|
1840
|
-
.then(function () {
|
|
1841
|
-
isJoined = false;
|
|
1842
|
-
callbacks.execute("onLeft");
|
|
1843
|
-
})
|
|
1844
|
-
.catch(function () {
|
|
1845
|
-
isJoined = false;
|
|
1846
|
-
callbacks.execute("onLeft");
|
|
1847
|
-
});
|
|
1848
|
-
}
|
|
1849
|
-
function handleJoined() {
|
|
1850
|
-
logger.debug("did join " + domain);
|
|
1851
|
-
isJoined = true;
|
|
1852
|
-
var wasReconnect = tryReconnecting;
|
|
1853
|
-
tryReconnecting = false;
|
|
1854
|
-
callbacks.execute("onJoined", wasReconnect);
|
|
1855
|
-
}
|
|
1856
|
-
function handleConnectionDisconnected() {
|
|
1857
|
-
_connectionOn = false;
|
|
1858
|
-
logger.debug("connection is down");
|
|
1859
|
-
isJoined = false;
|
|
1860
|
-
tryReconnecting = true;
|
|
1861
|
-
callbacks.execute("onLeft", { disconnected: true });
|
|
1862
|
-
}
|
|
1863
|
-
function handleConnectionLoggedIn() {
|
|
1864
|
-
_connectionOn = true;
|
|
1865
|
-
if (tryReconnecting) {
|
|
1866
|
-
logger.debug("connection is now up - trying to reconnect...");
|
|
1867
|
-
join(_latestOptions);
|
|
1868
|
-
}
|
|
1869
|
-
}
|
|
1870
|
-
function onJoined(callback) {
|
|
1871
|
-
if (isJoined) {
|
|
1872
|
-
callback(false);
|
|
1873
|
-
}
|
|
1874
|
-
return callbacks.add("onJoined", callback);
|
|
1875
|
-
}
|
|
1876
|
-
function onLeft(callback) {
|
|
1877
|
-
if (!isJoined) {
|
|
1878
|
-
callback();
|
|
1879
|
-
}
|
|
1880
|
-
return callbacks.add("onLeft", callback);
|
|
1881
|
-
}
|
|
1882
|
-
function handleErrorMessage(msg) {
|
|
1883
|
-
if (domain !== msg.domain) {
|
|
1884
|
-
return;
|
|
1885
|
-
}
|
|
1886
|
-
var requestId = msg.request_id;
|
|
1887
|
-
if (!requestId) {
|
|
1888
|
-
return;
|
|
1889
|
-
}
|
|
1890
|
-
var entry = requestsMap[requestId];
|
|
1891
|
-
if (!entry) {
|
|
1892
|
-
return;
|
|
1893
|
-
}
|
|
1894
|
-
entry.error(msg);
|
|
1895
|
-
}
|
|
1896
|
-
function handleSuccessMessage(msg) {
|
|
1897
|
-
if (msg.domain !== domain) {
|
|
1898
|
-
return;
|
|
1899
|
-
}
|
|
1900
|
-
var requestId = msg.request_id;
|
|
1901
|
-
if (!requestId) {
|
|
1902
|
-
return;
|
|
1903
|
-
}
|
|
1904
|
-
var entry = requestsMap[requestId];
|
|
1905
|
-
if (!entry) {
|
|
1906
|
-
return;
|
|
1907
|
-
}
|
|
1908
|
-
entry.success(msg);
|
|
1909
|
-
}
|
|
1910
|
-
function getNextRequestId() {
|
|
1911
|
-
return shortid();
|
|
1912
|
-
}
|
|
1913
|
-
function send(msg, tag, options) {
|
|
1914
|
-
options = options || {};
|
|
1915
|
-
msg.request_id = msg.request_id || getNextRequestId();
|
|
1916
|
-
msg.domain = msg.domain || domain;
|
|
1917
|
-
if (!options.skipPeerId) {
|
|
1918
|
-
msg.peer_id = connection.peerId;
|
|
1919
|
-
}
|
|
1920
|
-
var requestId = msg.request_id;
|
|
1921
|
-
return new Promise(function (resolve, reject) {
|
|
1922
|
-
requestsMap[requestId] = {
|
|
1923
|
-
success: function (successMsg) {
|
|
1924
|
-
delete requestsMap[requestId];
|
|
1925
|
-
successMsg._tag = tag;
|
|
1926
|
-
resolve(successMsg);
|
|
1927
|
-
},
|
|
1928
|
-
error: function (errorMsg) {
|
|
1929
|
-
logger.warn("GW error - ".concat(JSON.stringify(errorMsg), " for request ").concat(JSON.stringify(msg)));
|
|
1930
|
-
delete requestsMap[requestId];
|
|
1931
|
-
errorMsg._tag = tag;
|
|
1932
|
-
reject(errorMsg);
|
|
1933
|
-
},
|
|
1934
|
-
};
|
|
1935
|
-
connection
|
|
1936
|
-
.send(msg, options)
|
|
1937
|
-
.catch(function (err) {
|
|
1938
|
-
requestsMap[requestId].error({ err: err });
|
|
1939
|
-
});
|
|
1940
|
-
});
|
|
1941
|
-
}
|
|
1942
|
-
function sendFireAndForget(msg) {
|
|
1943
|
-
msg.request_id = msg.request_id ? msg.request_id : getNextRequestId();
|
|
1944
|
-
msg.domain = msg.domain || domain;
|
|
1945
|
-
msg.peer_id = connection.peerId;
|
|
1946
|
-
return connection.send(msg);
|
|
1947
|
-
}
|
|
1948
|
-
return {
|
|
1949
|
-
join: join,
|
|
1950
|
-
leave: leave,
|
|
1951
|
-
onJoined: onJoined,
|
|
1952
|
-
onLeft: onLeft,
|
|
1953
|
-
send: send,
|
|
1954
|
-
sendFireAndForget: sendFireAndForget,
|
|
1955
|
-
on: function (type, callback) {
|
|
1956
|
-
connection.on(type, function (msg) {
|
|
1957
|
-
if (msg.domain !== domain) {
|
|
1958
|
-
return;
|
|
1959
|
-
}
|
|
1960
|
-
try {
|
|
1961
|
-
callback(msg);
|
|
1962
|
-
}
|
|
1963
|
-
catch (e) {
|
|
1964
|
-
logger.error("Callback failed: ".concat(e, " \n ").concat(e.stack, " \n msg was: ").concat(JSON.stringify(msg)), e);
|
|
1965
|
-
}
|
|
1966
|
-
});
|
|
1967
|
-
},
|
|
1968
|
-
loggedIn: function (callback) { return connection.loggedIn(callback); },
|
|
1969
|
-
connected: function (callback) { return connection.connected(callback); },
|
|
1970
|
-
disconnected: function (callback) { return connection.disconnected(callback); },
|
|
1971
|
-
get peerId() {
|
|
1972
|
-
return connection.peerId;
|
|
1973
|
-
},
|
|
1974
|
-
get domain() {
|
|
1975
|
-
return domain;
|
|
1976
|
-
},
|
|
1977
|
-
};
|
|
1978
|
-
}
|
|
1979
|
-
|
|
1980
|
-
var GW3ProtocolImpl = (function () {
|
|
1981
|
-
function GW3ProtocolImpl(connection, settings, logger) {
|
|
1982
|
-
var _this = this;
|
|
1983
|
-
this.connection = connection;
|
|
1984
|
-
this.settings = settings;
|
|
1985
|
-
this.logger = logger;
|
|
1986
|
-
this.protocolVersion = 3;
|
|
1987
|
-
this.datePrefix = "#T42_DATE#";
|
|
1988
|
-
this.datePrefixLen = this.datePrefix.length;
|
|
1989
|
-
this.dateMinLen = this.datePrefixLen + 1;
|
|
1990
|
-
this.datePrefixFirstChar = this.datePrefix[0];
|
|
1991
|
-
this.registry = lib$1();
|
|
1992
|
-
this._isLoggedIn = false;
|
|
1993
|
-
this.shouldTryLogin = true;
|
|
1994
|
-
this.initialLogin = true;
|
|
1995
|
-
this.initialLoginAttempts = 3;
|
|
1996
|
-
this.sessions = [];
|
|
1997
|
-
connection.disconnected(function () {
|
|
1998
|
-
_this.handleDisconnected();
|
|
1999
|
-
});
|
|
2000
|
-
this.ping();
|
|
2001
|
-
}
|
|
2002
|
-
Object.defineProperty(GW3ProtocolImpl.prototype, "isLoggedIn", {
|
|
2003
|
-
get: function () {
|
|
2004
|
-
return this._isLoggedIn;
|
|
2005
|
-
},
|
|
2006
|
-
enumerable: false,
|
|
2007
|
-
configurable: true
|
|
2008
|
-
});
|
|
2009
|
-
GW3ProtocolImpl.prototype.processStringMessage = function (message) {
|
|
2010
|
-
var _this = this;
|
|
2011
|
-
var msg = JSON.parse(message, function (key, value) {
|
|
2012
|
-
if (typeof value !== "string") {
|
|
2013
|
-
return value;
|
|
2014
|
-
}
|
|
2015
|
-
if (value.length < _this.dateMinLen) {
|
|
2016
|
-
return value;
|
|
2017
|
-
}
|
|
2018
|
-
if (value[0] !== _this.datePrefixFirstChar) {
|
|
2019
|
-
return value;
|
|
2020
|
-
}
|
|
2021
|
-
if (value.substring(0, _this.datePrefixLen) !== _this.datePrefix) {
|
|
2022
|
-
return value;
|
|
2023
|
-
}
|
|
2024
|
-
try {
|
|
2025
|
-
var milliseconds = parseInt(value.substring(_this.datePrefixLen, value.length), 10);
|
|
2026
|
-
if (isNaN(milliseconds)) {
|
|
2027
|
-
return value;
|
|
2028
|
-
}
|
|
2029
|
-
return new Date(milliseconds);
|
|
2030
|
-
}
|
|
2031
|
-
catch (ex) {
|
|
2032
|
-
return value;
|
|
2033
|
-
}
|
|
2034
|
-
});
|
|
2035
|
-
return {
|
|
2036
|
-
msg: msg,
|
|
2037
|
-
msgType: msg.type,
|
|
2038
|
-
};
|
|
2039
|
-
};
|
|
2040
|
-
GW3ProtocolImpl.prototype.createStringMessage = function (message) {
|
|
2041
|
-
var oldToJson = Date.prototype.toJSON;
|
|
2042
|
-
try {
|
|
2043
|
-
var datePrefix_1 = this.datePrefix;
|
|
2044
|
-
Date.prototype.toJSON = function () {
|
|
2045
|
-
return datePrefix_1 + this.getTime();
|
|
2046
|
-
};
|
|
2047
|
-
var result = JSON.stringify(message);
|
|
2048
|
-
return result;
|
|
2049
|
-
}
|
|
2050
|
-
finally {
|
|
2051
|
-
Date.prototype.toJSON = oldToJson;
|
|
2052
|
-
}
|
|
2053
|
-
};
|
|
2054
|
-
GW3ProtocolImpl.prototype.processObjectMessage = function (message) {
|
|
2055
|
-
if (!message.type) {
|
|
2056
|
-
throw new Error("Object should have type property");
|
|
2057
|
-
}
|
|
2058
|
-
return {
|
|
2059
|
-
msg: message,
|
|
2060
|
-
msgType: message.type,
|
|
2061
|
-
};
|
|
2062
|
-
};
|
|
2063
|
-
GW3ProtocolImpl.prototype.createObjectMessage = function (message) {
|
|
2064
|
-
return message;
|
|
2065
|
-
};
|
|
2066
|
-
GW3ProtocolImpl.prototype.login = function (config, reconnect) {
|
|
2067
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
2068
|
-
var authentication, token, e_1, _a, helloMsg, sendOptions, welcomeMsg, msg, token, _b, err_1;
|
|
2069
|
-
return __generator(this, function (_c) {
|
|
2070
|
-
switch (_c.label) {
|
|
2071
|
-
case 0:
|
|
2072
|
-
this.logger.debug("logging in...");
|
|
2073
|
-
this.loginConfig = config;
|
|
2074
|
-
if (!this.loginConfig) {
|
|
2075
|
-
this.loginConfig = { username: "", password: "" };
|
|
2076
|
-
}
|
|
2077
|
-
this.shouldTryLogin = true;
|
|
2078
|
-
authentication = {};
|
|
2079
|
-
this.connection.gatewayToken = config.gatewayToken;
|
|
2080
|
-
if (!config.gatewayToken) return [3, 5];
|
|
2081
|
-
if (!reconnect) return [3, 4];
|
|
2082
|
-
_c.label = 1;
|
|
2083
|
-
case 1:
|
|
2084
|
-
_c.trys.push([1, 3, , 4]);
|
|
2085
|
-
return [4, this.getNewGWToken()];
|
|
2086
|
-
case 2:
|
|
2087
|
-
token = _c.sent();
|
|
2088
|
-
config.gatewayToken = token;
|
|
2089
|
-
return [3, 4];
|
|
2090
|
-
case 3:
|
|
2091
|
-
e_1 = _c.sent();
|
|
2092
|
-
this.logger.warn("failed to get GW token when reconnecting ".concat((e_1 === null || e_1 === void 0 ? void 0 : e_1.message) || e_1));
|
|
2093
|
-
return [3, 4];
|
|
2094
|
-
case 4:
|
|
2095
|
-
authentication.method = "gateway-token";
|
|
2096
|
-
authentication.token = config.gatewayToken;
|
|
2097
|
-
this.connection.gatewayToken = config.gatewayToken;
|
|
2098
|
-
return [3, 10];
|
|
2099
|
-
case 5:
|
|
2100
|
-
if (!(config.flowName === "sspi")) return [3, 9];
|
|
2101
|
-
authentication.provider = "win";
|
|
2102
|
-
authentication.method = "access-token";
|
|
2103
|
-
if (!(config.flowCallback && config.sessionId)) return [3, 7];
|
|
2104
|
-
_a = authentication;
|
|
2105
|
-
return [4, config.flowCallback(config.sessionId, null)];
|
|
2106
|
-
case 6:
|
|
2107
|
-
_a.token =
|
|
2108
|
-
(_c.sent())
|
|
2109
|
-
.data
|
|
2110
|
-
.toString("base64");
|
|
2111
|
-
return [3, 8];
|
|
2112
|
-
case 7: throw new Error("Invalid SSPI config");
|
|
2113
|
-
case 8: return [3, 10];
|
|
2114
|
-
case 9:
|
|
2115
|
-
if (config.token) {
|
|
2116
|
-
authentication.method = "access-token";
|
|
2117
|
-
authentication.token = config.token;
|
|
2118
|
-
}
|
|
2119
|
-
else if (config.username) {
|
|
2120
|
-
authentication.method = "secret";
|
|
2121
|
-
authentication.login = config.username;
|
|
2122
|
-
authentication.secret = config.password;
|
|
2123
|
-
}
|
|
2124
|
-
else if (config.provider) {
|
|
2125
|
-
authentication.provider = config.provider;
|
|
2126
|
-
authentication.providerContext = config.providerContext;
|
|
2127
|
-
}
|
|
2128
|
-
else {
|
|
2129
|
-
throw new Error("invalid auth message" + JSON.stringify(config));
|
|
2130
|
-
}
|
|
2131
|
-
_c.label = 10;
|
|
2132
|
-
case 10:
|
|
2133
|
-
helloMsg = {
|
|
2134
|
-
type: "hello",
|
|
2135
|
-
identity: this.settings.identity,
|
|
2136
|
-
authentication: authentication
|
|
2137
|
-
};
|
|
2138
|
-
if (config.sessionId) {
|
|
2139
|
-
helloMsg.request_id = config.sessionId;
|
|
2140
|
-
}
|
|
2141
|
-
this.globalDomain = domainSession("global", this.connection, this.logger.subLogger("global-domain"), [
|
|
2142
|
-
"welcome",
|
|
2143
|
-
"token",
|
|
2144
|
-
"authentication-request"
|
|
2145
|
-
]);
|
|
2146
|
-
sendOptions = { skipPeerId: true };
|
|
2147
|
-
if (this.initialLogin) {
|
|
2148
|
-
sendOptions.retryInterval = this.settings.reconnectInterval;
|
|
2149
|
-
sendOptions.maxRetries = this.settings.reconnectAttempts;
|
|
2150
|
-
}
|
|
2151
|
-
_c.label = 11;
|
|
2152
|
-
case 11:
|
|
2153
|
-
_c.trys.push([11, 19, 20, 21]);
|
|
2154
|
-
welcomeMsg = void 0;
|
|
2155
|
-
_c.label = 12;
|
|
2156
|
-
case 12:
|
|
2157
|
-
return [4, this.globalDomain.send(helloMsg, undefined, sendOptions)];
|
|
2158
|
-
case 13:
|
|
2159
|
-
msg = _c.sent();
|
|
2160
|
-
if (!(msg.type === "authentication-request")) return [3, 16];
|
|
2161
|
-
token = Buffer.from(msg.authentication.token, "base64");
|
|
2162
|
-
if (!(config.flowCallback && config.sessionId)) return [3, 15];
|
|
2163
|
-
_b = helloMsg.authentication;
|
|
2164
|
-
return [4, config.flowCallback(config.sessionId, token)];
|
|
2165
|
-
case 14:
|
|
2166
|
-
_b.token =
|
|
2167
|
-
(_c.sent())
|
|
2168
|
-
.data
|
|
2169
|
-
.toString("base64");
|
|
2170
|
-
_c.label = 15;
|
|
2171
|
-
case 15:
|
|
2172
|
-
helloMsg.request_id = config.sessionId;
|
|
2173
|
-
return [3, 12];
|
|
2174
|
-
case 16:
|
|
2175
|
-
if (msg.type === "welcome") {
|
|
2176
|
-
welcomeMsg = msg;
|
|
2177
|
-
return [3, 18];
|
|
2178
|
-
}
|
|
2179
|
-
else if (msg.type === "error") {
|
|
2180
|
-
throw new Error("Authentication failed: " + msg.reason);
|
|
2181
|
-
}
|
|
2182
|
-
else {
|
|
2183
|
-
throw new Error("Unexpected message type during authentication: " + msg.type);
|
|
2184
|
-
}
|
|
2185
|
-
case 17: return [3, 12];
|
|
2186
|
-
case 18:
|
|
2187
|
-
this.initialLogin = false;
|
|
2188
|
-
this.logger.debug("login successful with peerId " + welcomeMsg.peer_id);
|
|
2189
|
-
this.connection.peerId = welcomeMsg.peer_id;
|
|
2190
|
-
this.connection.resolvedIdentity = welcomeMsg.resolved_identity;
|
|
2191
|
-
this.connection.availableDomains = welcomeMsg.available_domains;
|
|
2192
|
-
if (welcomeMsg.options) {
|
|
2193
|
-
this.connection.token = welcomeMsg.options.access_token;
|
|
2194
|
-
this.connection.info = welcomeMsg.options.info;
|
|
2195
|
-
}
|
|
2196
|
-
this.setLoggedIn(true);
|
|
2197
|
-
return [2, welcomeMsg.resolved_identity];
|
|
2198
|
-
case 19:
|
|
2199
|
-
err_1 = _c.sent();
|
|
2200
|
-
this.logger.error("error sending hello message - " + (err_1.message || err_1.msg || err_1.reason || err_1), err_1);
|
|
2201
|
-
throw err_1;
|
|
2202
|
-
case 20:
|
|
2203
|
-
if (config && config.flowCallback && config.sessionId) {
|
|
2204
|
-
config.flowCallback(config.sessionId, null);
|
|
2205
|
-
}
|
|
2206
|
-
return [7];
|
|
2207
|
-
case 21: return [2];
|
|
2208
|
-
}
|
|
2209
|
-
});
|
|
2210
|
-
});
|
|
2211
|
-
};
|
|
2212
|
-
GW3ProtocolImpl.prototype.logout = function () {
|
|
2213
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
2214
|
-
var promises;
|
|
2215
|
-
return __generator(this, function (_a) {
|
|
2216
|
-
switch (_a.label) {
|
|
2217
|
-
case 0:
|
|
2218
|
-
this.logger.debug("logging out...");
|
|
2219
|
-
this.shouldTryLogin = false;
|
|
2220
|
-
if (this.pingTimer) {
|
|
2221
|
-
clearTimeout(this.pingTimer);
|
|
2222
|
-
}
|
|
2223
|
-
promises = this.sessions.map(function (session) {
|
|
2224
|
-
session.leave();
|
|
2225
|
-
});
|
|
2226
|
-
return [4, Promise.all(promises)];
|
|
2227
|
-
case 1:
|
|
2228
|
-
_a.sent();
|
|
2229
|
-
return [2];
|
|
2230
|
-
}
|
|
2231
|
-
});
|
|
2232
|
-
});
|
|
2233
|
-
};
|
|
2234
|
-
GW3ProtocolImpl.prototype.loggedIn = function (callback) {
|
|
2235
|
-
if (this._isLoggedIn) {
|
|
2236
|
-
callback();
|
|
2237
|
-
}
|
|
2238
|
-
return this.registry.add("onLoggedIn", callback);
|
|
2239
|
-
};
|
|
2240
|
-
GW3ProtocolImpl.prototype.domain = function (domainName, domainLogger, successMessages, errorMessages) {
|
|
2241
|
-
var session = this.sessions.filter(function (s) { return s.domain === domainName; })[0];
|
|
2242
|
-
if (!session) {
|
|
2243
|
-
session = domainSession(domainName, this.connection, domainLogger, successMessages, errorMessages);
|
|
2244
|
-
this.sessions.push(session);
|
|
2245
|
-
}
|
|
2246
|
-
return session;
|
|
2247
|
-
};
|
|
2248
|
-
GW3ProtocolImpl.prototype.handleDisconnected = function () {
|
|
2249
|
-
var _this = this;
|
|
2250
|
-
this.setLoggedIn(false);
|
|
2251
|
-
var tryToLogin = this.shouldTryLogin;
|
|
2252
|
-
if (tryToLogin && this.initialLogin) {
|
|
2253
|
-
if (this.initialLoginAttempts <= 0) {
|
|
2254
|
-
return;
|
|
2255
|
-
}
|
|
2256
|
-
this.initialLoginAttempts--;
|
|
2257
|
-
}
|
|
2258
|
-
this.logger.debug("disconnected - will try new login?" + this.shouldTryLogin);
|
|
2259
|
-
if (this.shouldTryLogin) {
|
|
2260
|
-
if (!this.loginConfig) {
|
|
2261
|
-
throw new Error("no login info");
|
|
2262
|
-
}
|
|
2263
|
-
this.connection.login(this.loginConfig, true)
|
|
2264
|
-
.catch(function () {
|
|
2265
|
-
setTimeout(_this.handleDisconnected.bind(_this), _this.settings.reconnectInterval || 1000);
|
|
2266
|
-
});
|
|
2267
|
-
}
|
|
2268
|
-
};
|
|
2269
|
-
GW3ProtocolImpl.prototype.setLoggedIn = function (value) {
|
|
2270
|
-
this._isLoggedIn = value;
|
|
2271
|
-
if (this._isLoggedIn) {
|
|
2272
|
-
this.registry.execute("onLoggedIn");
|
|
2273
|
-
}
|
|
2274
|
-
};
|
|
2275
|
-
GW3ProtocolImpl.prototype.ping = function () {
|
|
2276
|
-
var _this = this;
|
|
2277
|
-
if (!this.shouldTryLogin) {
|
|
2278
|
-
return;
|
|
2279
|
-
}
|
|
2280
|
-
if (this._isLoggedIn) {
|
|
2281
|
-
this.connection.send({ type: "ping" });
|
|
2282
|
-
}
|
|
2283
|
-
this.pingTimer = setTimeout(function () {
|
|
2284
|
-
_this.ping();
|
|
2285
|
-
}, 30 * 1000);
|
|
2286
|
-
};
|
|
2287
|
-
GW3ProtocolImpl.prototype.authToken = function () {
|
|
2288
|
-
var createTokenReq = {
|
|
2289
|
-
type: "create-token"
|
|
2290
|
-
};
|
|
2291
|
-
if (!this.globalDomain) {
|
|
2292
|
-
return Promise.reject(new Error("no global domain session"));
|
|
2293
|
-
}
|
|
2294
|
-
return this.globalDomain.send(createTokenReq)
|
|
2295
|
-
.then(function (res) {
|
|
2296
|
-
return res.token;
|
|
2297
|
-
});
|
|
2298
|
-
};
|
|
2299
|
-
GW3ProtocolImpl.prototype.getNewGWToken = function () {
|
|
2300
|
-
if (typeof window !== undefined) {
|
|
2301
|
-
var glue42gd = window.glue42gd;
|
|
2302
|
-
if (glue42gd) {
|
|
2303
|
-
return glue42gd.getGWToken();
|
|
2304
|
-
}
|
|
2305
|
-
}
|
|
2306
|
-
return Promise.reject(new Error("not running in GD"));
|
|
2307
|
-
};
|
|
2308
|
-
return GW3ProtocolImpl;
|
|
2309
|
-
}());
|
|
2310
|
-
|
|
2311
|
-
var MessageReplayerImpl = (function () {
|
|
2312
|
-
function MessageReplayerImpl(specs) {
|
|
2313
|
-
this.specsNames = [];
|
|
2314
|
-
this.messages = {};
|
|
2315
|
-
this.subs = {};
|
|
2316
|
-
this.subsRefCount = {};
|
|
2317
|
-
this.specs = {};
|
|
2318
|
-
for (var _i = 0, specs_1 = specs; _i < specs_1.length; _i++) {
|
|
2319
|
-
var spec = specs_1[_i];
|
|
2320
|
-
this.specs[spec.name] = spec;
|
|
2321
|
-
this.specsNames.push(spec.name);
|
|
2322
|
-
}
|
|
2323
|
-
}
|
|
2324
|
-
MessageReplayerImpl.prototype.init = function (connection) {
|
|
2325
|
-
var _this = this;
|
|
2326
|
-
this.connection = connection;
|
|
2327
|
-
for (var _i = 0, _a = this.specsNames; _i < _a.length; _i++) {
|
|
2328
|
-
var name_1 = _a[_i];
|
|
2329
|
-
var _loop_1 = function (type) {
|
|
2330
|
-
var refCount = this_1.subsRefCount[type];
|
|
2331
|
-
if (!refCount) {
|
|
2332
|
-
refCount = 0;
|
|
2333
|
-
}
|
|
2334
|
-
refCount += 1;
|
|
2335
|
-
this_1.subsRefCount[type] = refCount;
|
|
2336
|
-
if (refCount > 1) {
|
|
2337
|
-
return "continue";
|
|
2338
|
-
}
|
|
2339
|
-
var sub = connection.on(type, function (msg) { return _this.processMessage(type, msg); });
|
|
2340
|
-
this_1.subs[type] = sub;
|
|
2341
|
-
};
|
|
2342
|
-
var this_1 = this;
|
|
2343
|
-
for (var _b = 0, _c = this.specs[name_1].types; _b < _c.length; _b++) {
|
|
2344
|
-
var type = _c[_b];
|
|
2345
|
-
_loop_1(type);
|
|
2346
|
-
}
|
|
2347
|
-
}
|
|
2348
|
-
};
|
|
2349
|
-
MessageReplayerImpl.prototype.processMessage = function (type, msg) {
|
|
2350
|
-
if (this.isDone || !msg) {
|
|
2351
|
-
return;
|
|
2352
|
-
}
|
|
2353
|
-
for (var _i = 0, _a = this.specsNames; _i < _a.length; _i++) {
|
|
2354
|
-
var name_2 = _a[_i];
|
|
2355
|
-
if (this.specs[name_2].types.indexOf(type) !== -1) {
|
|
2356
|
-
var messages = this.messages[name_2] || [];
|
|
2357
|
-
this.messages[name_2] = messages;
|
|
2358
|
-
messages.push(msg);
|
|
2359
|
-
}
|
|
2360
|
-
}
|
|
2361
|
-
};
|
|
2362
|
-
MessageReplayerImpl.prototype.drain = function (name, callback) {
|
|
2363
|
-
var _a;
|
|
2364
|
-
if (callback) {
|
|
2365
|
-
(this.messages[name] || []).forEach(callback);
|
|
2366
|
-
}
|
|
2367
|
-
delete this.messages[name];
|
|
2368
|
-
for (var _i = 0, _b = this.specs[name].types; _i < _b.length; _i++) {
|
|
2369
|
-
var type = _b[_i];
|
|
2370
|
-
this.subsRefCount[type] -= 1;
|
|
2371
|
-
if (this.subsRefCount[type] <= 0) {
|
|
2372
|
-
(_a = this.connection) === null || _a === void 0 ? void 0 : _a.off(this.subs[type]);
|
|
2373
|
-
delete this.subs[type];
|
|
2374
|
-
delete this.subsRefCount[type];
|
|
2375
|
-
}
|
|
2376
|
-
}
|
|
2377
|
-
delete this.specs[name];
|
|
2378
|
-
if (!this.specs.length) {
|
|
2379
|
-
this.isDone = true;
|
|
2380
|
-
}
|
|
2381
|
-
};
|
|
2382
|
-
return MessageReplayerImpl;
|
|
2383
|
-
}());
|
|
2384
|
-
|
|
2385
|
-
var PromisePlus$1 = function (executor, timeoutMilliseconds, timeoutMessage) {
|
|
2386
|
-
return new Promise(function (resolve, reject) {
|
|
2387
|
-
var timeout = setTimeout(function () {
|
|
2388
|
-
var message = timeoutMessage || "Promise timeout hit: ".concat(timeoutMilliseconds);
|
|
2389
|
-
reject(message);
|
|
2390
|
-
}, timeoutMilliseconds);
|
|
2391
|
-
var providedPromise = new Promise(executor);
|
|
2392
|
-
providedPromise
|
|
2393
|
-
.then(function (result) {
|
|
2394
|
-
clearTimeout(timeout);
|
|
2395
|
-
resolve(result);
|
|
2396
|
-
})
|
|
2397
|
-
.catch(function (error) {
|
|
2398
|
-
clearTimeout(timeout);
|
|
2399
|
-
reject(error);
|
|
2400
|
-
});
|
|
2401
|
-
});
|
|
2402
|
-
};
|
|
2403
|
-
|
|
2404
|
-
var WebPlatformTransport = (function () {
|
|
2405
|
-
function WebPlatformTransport(settings, logger, identity) {
|
|
2406
|
-
this.settings = settings;
|
|
2407
|
-
this.logger = logger;
|
|
2408
|
-
this.identity = identity;
|
|
2409
|
-
this.iAmConnected = false;
|
|
2410
|
-
this.parentReady = false;
|
|
2411
|
-
this.rejected = false;
|
|
2412
|
-
this.children = [];
|
|
2413
|
-
this.extContentAvailable = false;
|
|
2414
|
-
this.extContentConnecting = false;
|
|
2415
|
-
this.extContentConnected = false;
|
|
2416
|
-
this.parentInExtMode = false;
|
|
2417
|
-
this.webNamespace = "g42_core_web";
|
|
2418
|
-
this.parentPingTimeout = 5000;
|
|
2419
|
-
this.connectionRequestTimeout = 7000;
|
|
2420
|
-
this.defaultTargetString = "*";
|
|
2421
|
-
this.registry = lib$1();
|
|
2422
|
-
this.messages = {
|
|
2423
|
-
connectionAccepted: { name: "connectionAccepted", handle: this.handleConnectionAccepted.bind(this) },
|
|
2424
|
-
connectionRejected: { name: "connectionRejected", handle: this.handleConnectionRejected.bind(this) },
|
|
2425
|
-
connectionRequest: { name: "connectionRequest", handle: this.handleConnectionRequest.bind(this) },
|
|
2426
|
-
parentReady: {
|
|
2427
|
-
name: "parentReady", handle: function () {
|
|
2428
|
-
}
|
|
2429
|
-
},
|
|
2430
|
-
parentPing: { name: "parentPing", handle: this.handleParentPing.bind(this) },
|
|
2431
|
-
platformPing: { name: "platformPing", handle: this.handlePlatformPing.bind(this) },
|
|
2432
|
-
platformReady: { name: "platformReady", handle: this.handlePlatformReady.bind(this) },
|
|
2433
|
-
clientUnload: { name: "clientUnload", handle: this.handleClientUnload.bind(this) },
|
|
2434
|
-
manualUnload: { name: "manualUnload", handle: this.handleManualUnload.bind(this) },
|
|
2435
|
-
extConnectionResponse: { name: "extConnectionResponse", handle: this.handleExtConnectionResponse.bind(this) },
|
|
2436
|
-
extSetupRequest: { name: "extSetupRequest", handle: this.handleExtSetupRequest.bind(this) },
|
|
2437
|
-
gatewayDisconnect: { name: "gatewayDisconnect", handle: this.handleGatewayDisconnect.bind(this) },
|
|
2438
|
-
gatewayInternalConnect: { name: "gatewayInternalConnect", handle: this.handleGatewayInternalConnect.bind(this) }
|
|
2439
|
-
};
|
|
2440
|
-
this.extContentAvailable = !!window.glue42ext;
|
|
2441
|
-
this.setUpMessageListener();
|
|
2442
|
-
this.setUpUnload();
|
|
2443
|
-
this.setupPlatformUnloadListener();
|
|
2444
|
-
this.parentType = window.name.includes("#wsp") ? "workspace" : undefined;
|
|
2445
|
-
}
|
|
2446
|
-
WebPlatformTransport.prototype.manualSetReadyState = function () {
|
|
2447
|
-
this.iAmConnected = true;
|
|
2448
|
-
this.parentReady = true;
|
|
2449
|
-
};
|
|
2450
|
-
Object.defineProperty(WebPlatformTransport.prototype, "transportWindowId", {
|
|
2451
|
-
get: function () {
|
|
2452
|
-
return this.publicWindowId;
|
|
2453
|
-
},
|
|
2454
|
-
enumerable: false,
|
|
2455
|
-
configurable: true
|
|
2456
|
-
});
|
|
2457
|
-
Object.defineProperty(WebPlatformTransport.prototype, "communicationId", {
|
|
2458
|
-
get: function () {
|
|
2459
|
-
return this._communicationId;
|
|
2460
|
-
},
|
|
2461
|
-
enumerable: false,
|
|
2462
|
-
configurable: true
|
|
2463
|
-
});
|
|
2464
|
-
WebPlatformTransport.prototype.sendObject = function (msg) {
|
|
2465
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
2466
|
-
return __generator(this, function (_a) {
|
|
2467
|
-
if (this.extContentConnected) {
|
|
2468
|
-
return [2, window.postMessage({ glue42ExtOut: msg }, this.defaultTargetString)];
|
|
2469
|
-
}
|
|
2470
|
-
if (!this.port) {
|
|
2471
|
-
throw new Error("Cannot send message, because the port was not opened yet");
|
|
2472
|
-
}
|
|
2473
|
-
this.port.postMessage(msg);
|
|
2474
|
-
return [2];
|
|
2475
|
-
});
|
|
2476
|
-
});
|
|
2477
|
-
};
|
|
2478
|
-
Object.defineProperty(WebPlatformTransport.prototype, "isObjectBasedTransport", {
|
|
2479
|
-
get: function () {
|
|
2480
|
-
return true;
|
|
2481
|
-
},
|
|
2482
|
-
enumerable: false,
|
|
2483
|
-
configurable: true
|
|
2484
|
-
});
|
|
2485
|
-
WebPlatformTransport.prototype.onMessage = function (callback) {
|
|
2486
|
-
return this.registry.add("onMessage", callback);
|
|
2487
|
-
};
|
|
2488
|
-
WebPlatformTransport.prototype.send = function () {
|
|
2489
|
-
return Promise.reject("not supported");
|
|
2490
|
-
};
|
|
2491
|
-
WebPlatformTransport.prototype.onConnectedChanged = function (callback) {
|
|
2492
|
-
return this.registry.add("onConnectedChanged", callback);
|
|
2493
|
-
};
|
|
2494
|
-
WebPlatformTransport.prototype.open = function () {
|
|
2495
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
2496
|
-
return __generator(this, function (_a) {
|
|
2497
|
-
switch (_a.label) {
|
|
2498
|
-
case 0:
|
|
2499
|
-
this.logger.debug("opening a connection to the web platform gateway.");
|
|
2500
|
-
return [4, this.connect()];
|
|
2501
|
-
case 1:
|
|
2502
|
-
_a.sent();
|
|
2503
|
-
this.notifyStatusChanged(true);
|
|
2504
|
-
return [2];
|
|
2505
|
-
}
|
|
1938
|
+
};
|
|
1939
|
+
Object.defineProperty(WebPlatformTransport.prototype, "isObjectBasedTransport", {
|
|
1940
|
+
get: function () {
|
|
1941
|
+
return true;
|
|
1942
|
+
},
|
|
1943
|
+
enumerable: false,
|
|
1944
|
+
configurable: true
|
|
1945
|
+
});
|
|
1946
|
+
WebPlatformTransport.prototype.onMessage = function (callback) {
|
|
1947
|
+
return this.registry.add("onMessage", callback);
|
|
1948
|
+
};
|
|
1949
|
+
WebPlatformTransport.prototype.send = function () {
|
|
1950
|
+
return Promise.reject("not supported");
|
|
1951
|
+
};
|
|
1952
|
+
WebPlatformTransport.prototype.onConnectedChanged = function (callback) {
|
|
1953
|
+
return this.registry.add("onConnectedChanged", callback);
|
|
1954
|
+
};
|
|
1955
|
+
WebPlatformTransport.prototype.open = function () {
|
|
1956
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1957
|
+
return __generator(this, function (_a) {
|
|
1958
|
+
switch (_a.label) {
|
|
1959
|
+
case 0:
|
|
1960
|
+
this.logger.debug("opening a connection to the web platform gateway.");
|
|
1961
|
+
return [4, this.connect()];
|
|
1962
|
+
case 1:
|
|
1963
|
+
_a.sent();
|
|
1964
|
+
this.notifyStatusChanged(true);
|
|
1965
|
+
return [2];
|
|
1966
|
+
}
|
|
2506
1967
|
});
|
|
2507
1968
|
});
|
|
2508
1969
|
};
|
|
@@ -2635,6 +2096,11 @@
|
|
|
2635
2096
|
if (!data || _this.rejected) {
|
|
2636
2097
|
return;
|
|
2637
2098
|
}
|
|
2099
|
+
var allowedOrigins = _this.settings.allowedOrigins || [];
|
|
2100
|
+
if (allowedOrigins.length && !allowedOrigins.includes(event.origin)) {
|
|
2101
|
+
_this.logger.warn("received a message from an origin which is not in the allowed list: ".concat(event.origin));
|
|
2102
|
+
return;
|
|
2103
|
+
}
|
|
2638
2104
|
if (!_this.checkMessageTypeValid(data.type)) {
|
|
2639
2105
|
_this.logger.error("cannot handle the incoming glue42 core message, because the type is invalid: ".concat(data.type));
|
|
2640
2106
|
return;
|
|
@@ -2742,6 +2208,11 @@
|
|
|
2742
2208
|
if (!extData) {
|
|
2743
2209
|
return;
|
|
2744
2210
|
}
|
|
2211
|
+
var allowedOrigins = _this.settings.allowedOrigins || [];
|
|
2212
|
+
if (allowedOrigins.length && !allowedOrigins.includes(event.origin)) {
|
|
2213
|
+
_this.logger.warn("received a message from an origin which is not in the allowed list: ".concat(event.origin));
|
|
2214
|
+
return;
|
|
2215
|
+
}
|
|
2745
2216
|
_this.registry.execute("onMessage", extData);
|
|
2746
2217
|
});
|
|
2747
2218
|
if (this.connectionResolve) {
|
|
@@ -3106,13 +2577,250 @@
|
|
|
3106
2577
|
var _this = this;
|
|
3107
2578
|
return new Promise(function (res) { return setTimeout(res, _this.minSequenceInterval); });
|
|
3108
2579
|
};
|
|
3109
|
-
return AsyncSequelizer;
|
|
3110
|
-
}());
|
|
2580
|
+
return AsyncSequelizer;
|
|
2581
|
+
}());
|
|
2582
|
+
|
|
2583
|
+
function domainSession (domain, connection, logger, successMessages, errorMessages) {
|
|
2584
|
+
if (domain == null) {
|
|
2585
|
+
domain = "global";
|
|
2586
|
+
}
|
|
2587
|
+
successMessages = successMessages !== null && successMessages !== void 0 ? successMessages : ["success"];
|
|
2588
|
+
errorMessages = errorMessages !== null && errorMessages !== void 0 ? errorMessages : ["error"];
|
|
2589
|
+
var isJoined = domain === "global";
|
|
2590
|
+
var tryReconnecting = false;
|
|
2591
|
+
var _latestOptions;
|
|
2592
|
+
var _connectionOn = false;
|
|
2593
|
+
var callbacks = lib$1();
|
|
2594
|
+
connection.disconnected(handleConnectionDisconnected);
|
|
2595
|
+
connection.loggedIn(handleConnectionLoggedIn);
|
|
2596
|
+
connection.on("success", function (msg) { return handleSuccessMessage(msg); });
|
|
2597
|
+
connection.on("error", function (msg) { return handleErrorMessage(msg); });
|
|
2598
|
+
connection.on("result", function (msg) { return handleSuccessMessage(msg); });
|
|
2599
|
+
if (successMessages) {
|
|
2600
|
+
successMessages.forEach(function (sm) {
|
|
2601
|
+
connection.on(sm, function (msg) { return handleSuccessMessage(msg); });
|
|
2602
|
+
});
|
|
2603
|
+
}
|
|
2604
|
+
if (errorMessages) {
|
|
2605
|
+
errorMessages.forEach(function (sm) {
|
|
2606
|
+
connection.on(sm, function (msg) { return handleErrorMessage(msg); });
|
|
2607
|
+
});
|
|
2608
|
+
}
|
|
2609
|
+
var requestsMap = {};
|
|
2610
|
+
function join(options) {
|
|
2611
|
+
_latestOptions = options;
|
|
2612
|
+
return new Promise(function (resolve, reject) {
|
|
2613
|
+
if (isJoined) {
|
|
2614
|
+
resolve({});
|
|
2615
|
+
return;
|
|
2616
|
+
}
|
|
2617
|
+
var joinPromise;
|
|
2618
|
+
if (domain === "global") {
|
|
2619
|
+
joinPromise = _connectionOn ? Promise.resolve({}) : Promise.reject("not connected to gateway");
|
|
2620
|
+
}
|
|
2621
|
+
else {
|
|
2622
|
+
logger.debug("joining domain ".concat(domain));
|
|
2623
|
+
var joinMsg = {
|
|
2624
|
+
type: "join",
|
|
2625
|
+
destination: domain,
|
|
2626
|
+
domain: "global",
|
|
2627
|
+
options: options,
|
|
2628
|
+
};
|
|
2629
|
+
joinPromise = send(joinMsg);
|
|
2630
|
+
}
|
|
2631
|
+
joinPromise
|
|
2632
|
+
.then(function () {
|
|
2633
|
+
handleJoined();
|
|
2634
|
+
resolve({});
|
|
2635
|
+
})
|
|
2636
|
+
.catch(function (err) {
|
|
2637
|
+
logger.debug("error joining " + domain + " domain: " + JSON.stringify(err));
|
|
2638
|
+
reject(err);
|
|
2639
|
+
});
|
|
2640
|
+
});
|
|
2641
|
+
}
|
|
2642
|
+
function leave() {
|
|
2643
|
+
if (domain === "global") {
|
|
2644
|
+
return Promise.resolve();
|
|
2645
|
+
}
|
|
2646
|
+
logger.debug("stopping session " + domain + "...");
|
|
2647
|
+
var leaveMsg = {
|
|
2648
|
+
type: "leave",
|
|
2649
|
+
destination: domain,
|
|
2650
|
+
domain: "global",
|
|
2651
|
+
};
|
|
2652
|
+
tryReconnecting = false;
|
|
2653
|
+
return send(leaveMsg)
|
|
2654
|
+
.then(function () {
|
|
2655
|
+
isJoined = false;
|
|
2656
|
+
callbacks.execute("onLeft");
|
|
2657
|
+
})
|
|
2658
|
+
.catch(function () {
|
|
2659
|
+
isJoined = false;
|
|
2660
|
+
callbacks.execute("onLeft");
|
|
2661
|
+
});
|
|
2662
|
+
}
|
|
2663
|
+
function handleJoined() {
|
|
2664
|
+
logger.debug("did join " + domain);
|
|
2665
|
+
isJoined = true;
|
|
2666
|
+
var wasReconnect = tryReconnecting;
|
|
2667
|
+
tryReconnecting = false;
|
|
2668
|
+
callbacks.execute("onJoined", wasReconnect);
|
|
2669
|
+
}
|
|
2670
|
+
function handleConnectionDisconnected() {
|
|
2671
|
+
_connectionOn = false;
|
|
2672
|
+
logger.debug("connection is down");
|
|
2673
|
+
isJoined = false;
|
|
2674
|
+
tryReconnecting = true;
|
|
2675
|
+
callbacks.execute("onLeft", { disconnected: true });
|
|
2676
|
+
}
|
|
2677
|
+
function handleConnectionLoggedIn() {
|
|
2678
|
+
_connectionOn = true;
|
|
2679
|
+
if (tryReconnecting) {
|
|
2680
|
+
logger.debug("connection is now up - trying to reconnect...");
|
|
2681
|
+
join(_latestOptions);
|
|
2682
|
+
}
|
|
2683
|
+
}
|
|
2684
|
+
function onJoined(callback) {
|
|
2685
|
+
if (isJoined) {
|
|
2686
|
+
callback(false);
|
|
2687
|
+
}
|
|
2688
|
+
return callbacks.add("onJoined", callback);
|
|
2689
|
+
}
|
|
2690
|
+
function onLeft(callback) {
|
|
2691
|
+
if (!isJoined) {
|
|
2692
|
+
callback();
|
|
2693
|
+
}
|
|
2694
|
+
return callbacks.add("onLeft", callback);
|
|
2695
|
+
}
|
|
2696
|
+
function handleErrorMessage(msg) {
|
|
2697
|
+
if (domain !== msg.domain) {
|
|
2698
|
+
return;
|
|
2699
|
+
}
|
|
2700
|
+
var requestId = msg.request_id;
|
|
2701
|
+
if (!requestId) {
|
|
2702
|
+
return;
|
|
2703
|
+
}
|
|
2704
|
+
var entry = requestsMap[requestId];
|
|
2705
|
+
if (!entry) {
|
|
2706
|
+
return;
|
|
2707
|
+
}
|
|
2708
|
+
entry.error(msg);
|
|
2709
|
+
}
|
|
2710
|
+
function handleSuccessMessage(msg) {
|
|
2711
|
+
if (msg.domain !== domain) {
|
|
2712
|
+
return;
|
|
2713
|
+
}
|
|
2714
|
+
var requestId = msg.request_id;
|
|
2715
|
+
if (!requestId) {
|
|
2716
|
+
return;
|
|
2717
|
+
}
|
|
2718
|
+
var entry = requestsMap[requestId];
|
|
2719
|
+
if (!entry) {
|
|
2720
|
+
return;
|
|
2721
|
+
}
|
|
2722
|
+
entry.success(msg);
|
|
2723
|
+
}
|
|
2724
|
+
function getNextRequestId() {
|
|
2725
|
+
return shortid();
|
|
2726
|
+
}
|
|
2727
|
+
var queuedCalls = [];
|
|
2728
|
+
function send(msg, tag, options) {
|
|
2729
|
+
var _a, _b;
|
|
2730
|
+
var ignore = ["hello", "join"];
|
|
2731
|
+
if (msg.type && ignore.indexOf(msg.type) === -1) {
|
|
2732
|
+
if (!isJoined) {
|
|
2733
|
+
logger.warn("trying to send a message (".concat(msg.domain, " ").concat(msg.type, ") but not connected, will queue"));
|
|
2734
|
+
var pw = new PromiseWrapper();
|
|
2735
|
+
queuedCalls.push({ msg: msg, tag: tag, options: options, pw: pw });
|
|
2736
|
+
if (queuedCalls.length === 1) {
|
|
2737
|
+
var unsubscribe_1 = onJoined(function () {
|
|
2738
|
+
logger.info("joined - will now send queued messages (".concat(queuedCalls.length, " -> [").concat(queuedCalls.map(function (m) { return m.msg.type; }), "])"));
|
|
2739
|
+
queuedCalls.forEach(function (qm) {
|
|
2740
|
+
send(qm.msg, qm.tag, qm.options)
|
|
2741
|
+
.then(function (t) { return qm.pw.resolve(t); })
|
|
2742
|
+
.catch(function (e) { return qm.pw.reject(e); });
|
|
2743
|
+
});
|
|
2744
|
+
queuedCalls = [];
|
|
2745
|
+
unsubscribe_1();
|
|
2746
|
+
});
|
|
2747
|
+
}
|
|
2748
|
+
return pw.promise;
|
|
2749
|
+
}
|
|
2750
|
+
}
|
|
2751
|
+
options = options !== null && options !== void 0 ? options : {};
|
|
2752
|
+
msg.request_id = (_a = msg.request_id) !== null && _a !== void 0 ? _a : getNextRequestId();
|
|
2753
|
+
msg.domain = (_b = msg.domain) !== null && _b !== void 0 ? _b : domain;
|
|
2754
|
+
if (!options.skipPeerId) {
|
|
2755
|
+
msg.peer_id = connection.peerId;
|
|
2756
|
+
}
|
|
2757
|
+
var requestId = msg.request_id;
|
|
2758
|
+
return new Promise(function (resolve, reject) {
|
|
2759
|
+
requestsMap[requestId] = {
|
|
2760
|
+
success: function (successMsg) {
|
|
2761
|
+
delete requestsMap[requestId];
|
|
2762
|
+
successMsg._tag = tag;
|
|
2763
|
+
resolve(successMsg);
|
|
2764
|
+
},
|
|
2765
|
+
error: function (errorMsg) {
|
|
2766
|
+
logger.warn("GW error - ".concat(JSON.stringify(errorMsg), " for request ").concat(JSON.stringify(msg)));
|
|
2767
|
+
delete requestsMap[requestId];
|
|
2768
|
+
errorMsg._tag = tag;
|
|
2769
|
+
reject(errorMsg);
|
|
2770
|
+
},
|
|
2771
|
+
};
|
|
2772
|
+
connection
|
|
2773
|
+
.send(msg, options)
|
|
2774
|
+
.catch(function (err) {
|
|
2775
|
+
requestsMap[requestId].error({ err: err });
|
|
2776
|
+
});
|
|
2777
|
+
});
|
|
2778
|
+
}
|
|
2779
|
+
function sendFireAndForget(msg) {
|
|
2780
|
+
var _a;
|
|
2781
|
+
msg.request_id = msg.request_id ? msg.request_id : getNextRequestId();
|
|
2782
|
+
msg.domain = (_a = msg.domain) !== null && _a !== void 0 ? _a : domain;
|
|
2783
|
+
msg.peer_id = connection.peerId;
|
|
2784
|
+
return connection.send(msg);
|
|
2785
|
+
}
|
|
2786
|
+
return {
|
|
2787
|
+
join: join,
|
|
2788
|
+
leave: leave,
|
|
2789
|
+
onJoined: onJoined,
|
|
2790
|
+
onLeft: onLeft,
|
|
2791
|
+
send: send,
|
|
2792
|
+
sendFireAndForget: sendFireAndForget,
|
|
2793
|
+
on: function (type, callback) {
|
|
2794
|
+
connection.on(type, function (msg) {
|
|
2795
|
+
if (msg.domain !== domain) {
|
|
2796
|
+
return;
|
|
2797
|
+
}
|
|
2798
|
+
try {
|
|
2799
|
+
callback(msg);
|
|
2800
|
+
}
|
|
2801
|
+
catch (e) {
|
|
2802
|
+
logger.error("Callback failed: ".concat(e, " \n ").concat(e.stack, " \n msg was: ").concat(JSON.stringify(msg)), e);
|
|
2803
|
+
}
|
|
2804
|
+
});
|
|
2805
|
+
},
|
|
2806
|
+
loggedIn: function (callback) { return connection.loggedIn(callback); },
|
|
2807
|
+
connected: function (callback) { return connection.connected(callback); },
|
|
2808
|
+
disconnected: function (callback) { return connection.disconnected(callback); },
|
|
2809
|
+
get peerId() {
|
|
2810
|
+
return connection.peerId;
|
|
2811
|
+
},
|
|
2812
|
+
get domain() {
|
|
2813
|
+
return domain;
|
|
2814
|
+
},
|
|
2815
|
+
};
|
|
2816
|
+
}
|
|
3111
2817
|
|
|
3112
2818
|
var Connection = (function () {
|
|
3113
2819
|
function Connection(settings, logger) {
|
|
2820
|
+
var _a, _b;
|
|
3114
2821
|
this.settings = settings;
|
|
3115
2822
|
this.logger = logger;
|
|
2823
|
+
this.protocolVersion = 3;
|
|
3116
2824
|
this.messageHandlers = {};
|
|
3117
2825
|
this.ids = 1;
|
|
3118
2826
|
this.registry = lib$1();
|
|
@@ -3121,10 +2829,19 @@
|
|
|
3121
2829
|
this._swapTransport = false;
|
|
3122
2830
|
this._switchInProgress = false;
|
|
3123
2831
|
this._transportSubscriptions = [];
|
|
2832
|
+
this.datePrefix = "#T42_DATE#";
|
|
2833
|
+
this.datePrefixLen = this.datePrefix.length;
|
|
2834
|
+
this.dateMinLen = this.datePrefixLen + 1;
|
|
2835
|
+
this.datePrefixFirstChar = this.datePrefix[0];
|
|
3124
2836
|
this._sequelizer = new AsyncSequelizer();
|
|
2837
|
+
this._isLoggedIn = false;
|
|
2838
|
+
this.shouldTryLogin = true;
|
|
2839
|
+
this.sessions = [];
|
|
2840
|
+
this.initialLogin = true;
|
|
2841
|
+
this.initialLoginAttempts = 3;
|
|
3125
2842
|
settings = settings || {};
|
|
3126
|
-
settings.reconnectAttempts = settings.reconnectAttempts
|
|
3127
|
-
settings.reconnectInterval = settings.reconnectInterval
|
|
2843
|
+
settings.reconnectAttempts = (_a = settings.reconnectAttempts) !== null && _a !== void 0 ? _a : 10;
|
|
2844
|
+
settings.reconnectInterval = (_b = settings.reconnectInterval) !== null && _b !== void 0 ? _b : 1000;
|
|
3128
2845
|
if (settings.inproc) {
|
|
3129
2846
|
this.transport = new InProcTransport(settings.inproc, logger.subLogger("inMemory"));
|
|
3130
2847
|
}
|
|
@@ -3142,21 +2859,13 @@
|
|
|
3142
2859
|
}
|
|
3143
2860
|
this.isTrace = logger.canPublish("trace");
|
|
3144
2861
|
logger.debug("starting with ".concat(this.transport.name(), " transport"));
|
|
3145
|
-
this.protocol = new GW3ProtocolImpl(this, settings, logger.subLogger("protocol"));
|
|
3146
2862
|
var unsubConnectionChanged = this.transport.onConnectedChanged(this.handleConnectionChanged.bind(this));
|
|
3147
2863
|
var unsubOnMessage = this.transport.onMessage(this.handleTransportMessage.bind(this));
|
|
3148
2864
|
this._transportSubscriptions.push(unsubConnectionChanged);
|
|
3149
2865
|
this._transportSubscriptions.push(unsubOnMessage);
|
|
3150
2866
|
this._defaultTransport = this.transport;
|
|
2867
|
+
this.ping();
|
|
3151
2868
|
}
|
|
3152
|
-
Object.defineProperty(Connection.prototype, "protocolVersion", {
|
|
3153
|
-
get: function () {
|
|
3154
|
-
var _a;
|
|
3155
|
-
return (_a = this.protocol) === null || _a === void 0 ? void 0 : _a.protocolVersion;
|
|
3156
|
-
},
|
|
3157
|
-
enumerable: false,
|
|
3158
|
-
configurable: true
|
|
3159
|
-
});
|
|
3160
2869
|
Connection.prototype.switchTransport = function (settings) {
|
|
3161
2870
|
return __awaiter(this, void 0, void 0, function () {
|
|
3162
2871
|
var _this = this;
|
|
@@ -3204,239 +2913,555 @@
|
|
|
3204
2913
|
});
|
|
3205
2914
|
}); })];
|
|
3206
2915
|
});
|
|
3207
|
-
});
|
|
2916
|
+
});
|
|
2917
|
+
};
|
|
2918
|
+
Connection.prototype.onLibReAnnounced = function (callback) {
|
|
2919
|
+
return this.registry.add("libReAnnounced", callback);
|
|
2920
|
+
};
|
|
2921
|
+
Connection.prototype.setLibReAnnounced = function (lib) {
|
|
2922
|
+
this.registry.execute("libReAnnounced", lib);
|
|
2923
|
+
};
|
|
2924
|
+
Connection.prototype.send = function (message, options) {
|
|
2925
|
+
if (this.transport.sendObject &&
|
|
2926
|
+
this.transport.isObjectBasedTransport) {
|
|
2927
|
+
var msg = this.createObjectMessage(message);
|
|
2928
|
+
if (this.isTrace) {
|
|
2929
|
+
this.logger.trace(">> ".concat(JSON.stringify(msg)));
|
|
2930
|
+
}
|
|
2931
|
+
return this.transport.sendObject(msg, options);
|
|
2932
|
+
}
|
|
2933
|
+
else {
|
|
2934
|
+
var strMessage = this.createStringMessage(message);
|
|
2935
|
+
if (this.isTrace) {
|
|
2936
|
+
this.logger.trace(">> ".concat(strMessage));
|
|
2937
|
+
}
|
|
2938
|
+
return this.transport.send(strMessage, options);
|
|
2939
|
+
}
|
|
2940
|
+
};
|
|
2941
|
+
Connection.prototype.on = function (type, messageHandler) {
|
|
2942
|
+
type = type.toLowerCase();
|
|
2943
|
+
if (this.messageHandlers[type] === undefined) {
|
|
2944
|
+
this.messageHandlers[type] = {};
|
|
2945
|
+
}
|
|
2946
|
+
var id = this.ids++;
|
|
2947
|
+
this.messageHandlers[type][id] = messageHandler;
|
|
2948
|
+
return {
|
|
2949
|
+
type: type,
|
|
2950
|
+
id: id,
|
|
2951
|
+
};
|
|
2952
|
+
};
|
|
2953
|
+
Connection.prototype.off = function (info) {
|
|
2954
|
+
delete this.messageHandlers[info.type.toLowerCase()][info.id];
|
|
2955
|
+
};
|
|
2956
|
+
Object.defineProperty(Connection.prototype, "isConnected", {
|
|
2957
|
+
get: function () {
|
|
2958
|
+
return this._isLoggedIn;
|
|
2959
|
+
},
|
|
2960
|
+
enumerable: false,
|
|
2961
|
+
configurable: true
|
|
2962
|
+
});
|
|
2963
|
+
Connection.prototype.connected = function (callback) {
|
|
2964
|
+
var _this = this;
|
|
2965
|
+
return this.loggedIn(function () {
|
|
2966
|
+
var currentServer = _this.transport.name();
|
|
2967
|
+
callback(currentServer);
|
|
2968
|
+
});
|
|
2969
|
+
};
|
|
2970
|
+
Connection.prototype.disconnected = function (callback) {
|
|
2971
|
+
return this.registry.add("disconnected", callback);
|
|
2972
|
+
};
|
|
2973
|
+
Connection.prototype.login = function (authRequest, reconnect) {
|
|
2974
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2975
|
+
var newAuth, identity, error_2;
|
|
2976
|
+
return __generator(this, function (_a) {
|
|
2977
|
+
switch (_a.label) {
|
|
2978
|
+
case 0:
|
|
2979
|
+
if (!this._defaultAuth) {
|
|
2980
|
+
this._defaultAuth = authRequest;
|
|
2981
|
+
}
|
|
2982
|
+
if (this._swapTransport) {
|
|
2983
|
+
this.logger.trace("Detected a transport swap, swapping transports");
|
|
2984
|
+
newAuth = this.transportSwap();
|
|
2985
|
+
authRequest = newAuth !== null && newAuth !== void 0 ? newAuth : authRequest;
|
|
2986
|
+
}
|
|
2987
|
+
this.logger.trace("Starting login for transport: ".concat(this.transport.name(), " and auth ").concat(JSON.stringify(authRequest)));
|
|
2988
|
+
_a.label = 1;
|
|
2989
|
+
case 1:
|
|
2990
|
+
_a.trys.push([1, 4, , 5]);
|
|
2991
|
+
return [4, this.transport.open()];
|
|
2992
|
+
case 2:
|
|
2993
|
+
_a.sent();
|
|
2994
|
+
this.logger.trace("Transport: ".concat(this.transport.name(), " opened, logging in"));
|
|
2995
|
+
timer("connection").mark("transport-opened");
|
|
2996
|
+
return [4, this.loginCore(authRequest, reconnect)];
|
|
2997
|
+
case 3:
|
|
2998
|
+
identity = _a.sent();
|
|
2999
|
+
this.logger.trace("Logged in with identity: ".concat(JSON.stringify(identity)));
|
|
3000
|
+
timer("connection").mark("protocol-logged-in");
|
|
3001
|
+
return [2, identity];
|
|
3002
|
+
case 4:
|
|
3003
|
+
error_2 = _a.sent();
|
|
3004
|
+
if (this._switchInProgress) {
|
|
3005
|
+
this.logger.trace("An error while logging in after a transport swap, preparing a default swap.");
|
|
3006
|
+
this.prepareDefaultSwap();
|
|
3007
|
+
}
|
|
3008
|
+
throw new Error(error_2);
|
|
3009
|
+
case 5: return [2];
|
|
3010
|
+
}
|
|
3011
|
+
});
|
|
3012
|
+
});
|
|
3013
|
+
};
|
|
3014
|
+
Connection.prototype.logout = function () {
|
|
3015
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
3016
|
+
return __generator(this, function (_a) {
|
|
3017
|
+
switch (_a.label) {
|
|
3018
|
+
case 0: return [4, this.logoutCore()];
|
|
3019
|
+
case 1:
|
|
3020
|
+
_a.sent();
|
|
3021
|
+
return [4, this.transport.close()];
|
|
3022
|
+
case 2:
|
|
3023
|
+
_a.sent();
|
|
3024
|
+
return [2];
|
|
3025
|
+
}
|
|
3026
|
+
});
|
|
3027
|
+
});
|
|
3028
|
+
};
|
|
3029
|
+
Connection.prototype.loggedIn = function (callback) {
|
|
3030
|
+
if (this._isLoggedIn) {
|
|
3031
|
+
callback();
|
|
3032
|
+
}
|
|
3033
|
+
return this.registry.add("onLoggedIn", callback);
|
|
3034
|
+
};
|
|
3035
|
+
Connection.prototype.domain = function (domain, successMessages, errorMessages) {
|
|
3036
|
+
var session = this.sessions.find(function (s) { return s.domain === domain; });
|
|
3037
|
+
if (!session) {
|
|
3038
|
+
session = domainSession(domain, this, this.logger.subLogger("domain=".concat(domain)), successMessages, errorMessages);
|
|
3039
|
+
this.sessions.push(session);
|
|
3040
|
+
}
|
|
3041
|
+
return session;
|
|
3042
|
+
};
|
|
3043
|
+
Connection.prototype.authToken = function () {
|
|
3044
|
+
var createTokenReq = {
|
|
3045
|
+
domain: "global",
|
|
3046
|
+
type: "create-token"
|
|
3047
|
+
};
|
|
3048
|
+
if (!this.globalDomain) {
|
|
3049
|
+
return Promise.reject(new Error("no global domain session"));
|
|
3050
|
+
}
|
|
3051
|
+
return this.globalDomain.send(createTokenReq)
|
|
3052
|
+
.then(function (res) {
|
|
3053
|
+
return res.token;
|
|
3054
|
+
});
|
|
3055
|
+
};
|
|
3056
|
+
Connection.prototype.reconnect = function () {
|
|
3057
|
+
return this.transport.reconnect();
|
|
3058
|
+
};
|
|
3059
|
+
Connection.prototype.setLoggedIn = function (value) {
|
|
3060
|
+
this._isLoggedIn = value;
|
|
3061
|
+
if (this._isLoggedIn) {
|
|
3062
|
+
this.registry.execute("onLoggedIn");
|
|
3063
|
+
}
|
|
3064
|
+
};
|
|
3065
|
+
Connection.prototype.distributeMessage = function (message, type) {
|
|
3066
|
+
var _this = this;
|
|
3067
|
+
var handlers = this.messageHandlers[type.toLowerCase()];
|
|
3068
|
+
if (handlers !== undefined) {
|
|
3069
|
+
Object.keys(handlers).forEach(function (handlerId) {
|
|
3070
|
+
var handler = handlers[handlerId];
|
|
3071
|
+
if (handler !== undefined) {
|
|
3072
|
+
try {
|
|
3073
|
+
handler(message);
|
|
3074
|
+
}
|
|
3075
|
+
catch (error) {
|
|
3076
|
+
try {
|
|
3077
|
+
_this.logger.error("Message handler failed with ".concat(error.stack), error);
|
|
3078
|
+
}
|
|
3079
|
+
catch (loggerError) {
|
|
3080
|
+
console.log("Message handler failed", error);
|
|
3081
|
+
}
|
|
3082
|
+
}
|
|
3083
|
+
}
|
|
3084
|
+
});
|
|
3085
|
+
}
|
|
3086
|
+
};
|
|
3087
|
+
Connection.prototype.handleConnectionChanged = function (connected) {
|
|
3088
|
+
var _a, _b;
|
|
3089
|
+
if (this._connected === connected) {
|
|
3090
|
+
return;
|
|
3091
|
+
}
|
|
3092
|
+
this._connected = connected;
|
|
3093
|
+
if (connected) {
|
|
3094
|
+
if ((_b = (_a = this.settings) === null || _a === void 0 ? void 0 : _a.replaySpecs) === null || _b === void 0 ? void 0 : _b.length) {
|
|
3095
|
+
this.replayer = new MessageReplayerImpl(this.settings.replaySpecs);
|
|
3096
|
+
this.replayer.init(this);
|
|
3097
|
+
}
|
|
3098
|
+
this.registry.execute("connected");
|
|
3099
|
+
}
|
|
3100
|
+
else {
|
|
3101
|
+
this.handleDisconnected();
|
|
3102
|
+
this.registry.execute("disconnected");
|
|
3103
|
+
}
|
|
3104
|
+
};
|
|
3105
|
+
Connection.prototype.handleDisconnected = function () {
|
|
3106
|
+
var _this = this;
|
|
3107
|
+
this.setLoggedIn(false);
|
|
3108
|
+
var tryToLogin = this.shouldTryLogin;
|
|
3109
|
+
if (tryToLogin && this.initialLogin) {
|
|
3110
|
+
if (this.initialLoginAttempts <= 0) {
|
|
3111
|
+
return;
|
|
3112
|
+
}
|
|
3113
|
+
this.initialLoginAttempts--;
|
|
3114
|
+
}
|
|
3115
|
+
this.logger.debug("disconnected - will try new login?" + this.shouldTryLogin);
|
|
3116
|
+
if (this.shouldTryLogin) {
|
|
3117
|
+
if (!this.loginConfig) {
|
|
3118
|
+
throw new Error("no login info");
|
|
3119
|
+
}
|
|
3120
|
+
this.login(this.loginConfig, true)
|
|
3121
|
+
.catch(function () {
|
|
3122
|
+
setTimeout(_this.handleDisconnected.bind(_this), _this.settings.reconnectInterval || 1000);
|
|
3123
|
+
});
|
|
3124
|
+
}
|
|
3125
|
+
};
|
|
3126
|
+
Connection.prototype.handleTransportMessage = function (msg) {
|
|
3127
|
+
var msgObj;
|
|
3128
|
+
if (typeof msg === "string") {
|
|
3129
|
+
msgObj = this.processStringMessage(msg);
|
|
3130
|
+
}
|
|
3131
|
+
else {
|
|
3132
|
+
msgObj = this.processObjectMessage(msg);
|
|
3133
|
+
}
|
|
3134
|
+
if (this.isTrace) {
|
|
3135
|
+
this.logger.trace("<< ".concat(JSON.stringify(msgObj)));
|
|
3136
|
+
}
|
|
3137
|
+
this.distributeMessage(msgObj.msg, msgObj.msgType);
|
|
3138
|
+
};
|
|
3139
|
+
Connection.prototype.verifyConnection = function () {
|
|
3140
|
+
var _this = this;
|
|
3141
|
+
return PromisePlus$1(function (resolve) {
|
|
3142
|
+
var unsub;
|
|
3143
|
+
var ready = waitForInvocations(2, function () {
|
|
3144
|
+
if (unsub) {
|
|
3145
|
+
unsub();
|
|
3146
|
+
}
|
|
3147
|
+
resolve();
|
|
3148
|
+
});
|
|
3149
|
+
unsub = _this.onLibReAnnounced(function (lib) {
|
|
3150
|
+
if (lib.name === "interop") {
|
|
3151
|
+
return ready();
|
|
3152
|
+
}
|
|
3153
|
+
if (lib.name === "contexts") {
|
|
3154
|
+
return ready();
|
|
3155
|
+
}
|
|
3156
|
+
});
|
|
3157
|
+
}, 10000, "Transport switch timed out waiting for all libraries to be re-announced");
|
|
3208
3158
|
};
|
|
3209
|
-
Connection.prototype.
|
|
3210
|
-
|
|
3159
|
+
Connection.prototype.getNewSecondaryTransport = function (settings) {
|
|
3160
|
+
var _a;
|
|
3161
|
+
if (!((_a = settings.transportConfig) === null || _a === void 0 ? void 0 : _a.url)) {
|
|
3162
|
+
throw new Error("Missing secondary transport URL.");
|
|
3163
|
+
}
|
|
3164
|
+
return new WS(Object.assign({}, this.settings, { ws: settings.transportConfig.url, reconnectAttempts: 1 }), this.logger.subLogger("ws-secondary"));
|
|
3211
3165
|
};
|
|
3212
|
-
Connection.prototype.
|
|
3213
|
-
|
|
3166
|
+
Connection.prototype.getNewSecondaryAuth = function (settings) {
|
|
3167
|
+
var _a;
|
|
3168
|
+
if (!((_a = settings.transportConfig) === null || _a === void 0 ? void 0 : _a.auth)) {
|
|
3169
|
+
throw new Error("Missing secondary transport auth information.");
|
|
3170
|
+
}
|
|
3171
|
+
return settings.transportConfig.auth;
|
|
3214
3172
|
};
|
|
3215
|
-
Connection.prototype.
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
this.logger.trace(">> ".concat(JSON.stringify(msg)));
|
|
3221
|
-
}
|
|
3222
|
-
return this.transport.sendObject(msg, options);
|
|
3173
|
+
Connection.prototype.transportSwap = function () {
|
|
3174
|
+
this._swapTransport = false;
|
|
3175
|
+
if (!this._targetTransport || !this._targetAuth) {
|
|
3176
|
+
this.logger.warn("Error while switching transports - either the target transport or auth is not defined: transport defined -> ".concat(!!this._defaultTransport, ", auth defined -> ").concat(!!this._targetAuth, ". Staying on the current one."));
|
|
3177
|
+
return;
|
|
3223
3178
|
}
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
3179
|
+
this._transportSubscriptions.forEach(function (unsub) { return unsub(); });
|
|
3180
|
+
this._transportSubscriptions = [];
|
|
3181
|
+
this.transport = this._targetTransport;
|
|
3182
|
+
var unsubConnectionChanged = this.transport.onConnectedChanged(this.handleConnectionChanged.bind(this));
|
|
3183
|
+
var unsubOnMessage = this.transport.onMessage(this.handleTransportMessage.bind(this));
|
|
3184
|
+
this._transportSubscriptions.push(unsubConnectionChanged);
|
|
3185
|
+
this._transportSubscriptions.push(unsubOnMessage);
|
|
3186
|
+
return this._targetAuth;
|
|
3187
|
+
};
|
|
3188
|
+
Connection.prototype.prepareDefaultSwap = function () {
|
|
3189
|
+
var _this = this;
|
|
3190
|
+
this._transportSubscriptions.forEach(function (unsub) { return unsub(); });
|
|
3191
|
+
this._transportSubscriptions = [];
|
|
3192
|
+
this.transport.close().catch(function (error) { return _this.logger.warn("Error closing the ".concat(_this.transport.name(), " transport after a failed connection attempt: ").concat(JSON.stringify(error))); });
|
|
3193
|
+
this._targetTransport = this._defaultTransport;
|
|
3194
|
+
this._targetAuth = this._defaultAuth;
|
|
3195
|
+
this._swapTransport = true;
|
|
3196
|
+
};
|
|
3197
|
+
Connection.prototype.processStringMessage = function (message) {
|
|
3198
|
+
var _this = this;
|
|
3199
|
+
var msg = JSON.parse(message, function (key, value) {
|
|
3200
|
+
if (typeof value !== "string") {
|
|
3201
|
+
return value;
|
|
3228
3202
|
}
|
|
3229
|
-
|
|
3203
|
+
if (value.length < _this.dateMinLen) {
|
|
3204
|
+
return value;
|
|
3205
|
+
}
|
|
3206
|
+
if (!value.startsWith(_this.datePrefixFirstChar)) {
|
|
3207
|
+
return value;
|
|
3208
|
+
}
|
|
3209
|
+
if (value.substring(0, _this.datePrefixLen) !== _this.datePrefix) {
|
|
3210
|
+
return value;
|
|
3211
|
+
}
|
|
3212
|
+
try {
|
|
3213
|
+
var milliseconds = parseInt(value.substring(_this.datePrefixLen, value.length), 10);
|
|
3214
|
+
if (isNaN(milliseconds)) {
|
|
3215
|
+
return value;
|
|
3216
|
+
}
|
|
3217
|
+
return new Date(milliseconds);
|
|
3218
|
+
}
|
|
3219
|
+
catch (ex) {
|
|
3220
|
+
return value;
|
|
3221
|
+
}
|
|
3222
|
+
});
|
|
3223
|
+
return {
|
|
3224
|
+
msg: msg,
|
|
3225
|
+
msgType: msg.type,
|
|
3226
|
+
};
|
|
3227
|
+
};
|
|
3228
|
+
Connection.prototype.createStringMessage = function (message) {
|
|
3229
|
+
var oldToJson = Date.prototype.toJSON;
|
|
3230
|
+
try {
|
|
3231
|
+
var datePrefix_1 = this.datePrefix;
|
|
3232
|
+
Date.prototype.toJSON = function () {
|
|
3233
|
+
return datePrefix_1 + this.getTime();
|
|
3234
|
+
};
|
|
3235
|
+
var result = JSON.stringify(message);
|
|
3236
|
+
return result;
|
|
3237
|
+
}
|
|
3238
|
+
finally {
|
|
3239
|
+
Date.prototype.toJSON = oldToJson;
|
|
3230
3240
|
}
|
|
3231
3241
|
};
|
|
3232
|
-
Connection.prototype.
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
this.messageHandlers[type] = {};
|
|
3242
|
+
Connection.prototype.processObjectMessage = function (message) {
|
|
3243
|
+
if (!message.type) {
|
|
3244
|
+
throw new Error("Object should have type property");
|
|
3236
3245
|
}
|
|
3237
|
-
var id = this.ids++;
|
|
3238
|
-
this.messageHandlers[type][id] = messageHandler;
|
|
3239
3246
|
return {
|
|
3240
|
-
|
|
3241
|
-
|
|
3247
|
+
msg: message,
|
|
3248
|
+
msgType: message.type,
|
|
3242
3249
|
};
|
|
3243
3250
|
};
|
|
3244
|
-
Connection.prototype.
|
|
3245
|
-
|
|
3246
|
-
};
|
|
3247
|
-
Object.defineProperty(Connection.prototype, "isConnected", {
|
|
3248
|
-
get: function () {
|
|
3249
|
-
return this.protocol.isLoggedIn;
|
|
3250
|
-
},
|
|
3251
|
-
enumerable: false,
|
|
3252
|
-
configurable: true
|
|
3253
|
-
});
|
|
3254
|
-
Connection.prototype.connected = function (callback) {
|
|
3255
|
-
var _this = this;
|
|
3256
|
-
return this.protocol.loggedIn(function () {
|
|
3257
|
-
var currentServer = _this.transport.name();
|
|
3258
|
-
callback(currentServer);
|
|
3259
|
-
});
|
|
3260
|
-
};
|
|
3261
|
-
Connection.prototype.disconnected = function (callback) {
|
|
3262
|
-
return this.registry.add("disconnected", callback);
|
|
3251
|
+
Connection.prototype.createObjectMessage = function (message) {
|
|
3252
|
+
return message;
|
|
3263
3253
|
};
|
|
3264
|
-
Connection.prototype.
|
|
3254
|
+
Connection.prototype.loginCore = function (config, reconnect) {
|
|
3265
3255
|
return __awaiter(this, void 0, void 0, function () {
|
|
3266
|
-
var
|
|
3256
|
+
var authentication, helloMsg, sendOptions, welcomeMsg, err_1;
|
|
3267
3257
|
return __generator(this, function (_a) {
|
|
3268
3258
|
switch (_a.label) {
|
|
3269
3259
|
case 0:
|
|
3270
|
-
|
|
3271
|
-
|
|
3260
|
+
this.logger.info("logging in...");
|
|
3261
|
+
this.loginConfig = config;
|
|
3262
|
+
if (!this.loginConfig) {
|
|
3263
|
+
this.loginConfig = { username: "", password: "" };
|
|
3272
3264
|
}
|
|
3273
|
-
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
|
|
3265
|
+
this.shouldTryLogin = true;
|
|
3266
|
+
return [4, this.setupAuthConfig(config, reconnect)];
|
|
3267
|
+
case 1:
|
|
3268
|
+
authentication = _a.sent();
|
|
3269
|
+
helloMsg = {
|
|
3270
|
+
type: "hello",
|
|
3271
|
+
identity: this.settings.identity,
|
|
3272
|
+
authentication: authentication
|
|
3273
|
+
};
|
|
3274
|
+
if (config.sessionId) {
|
|
3275
|
+
helloMsg.request_id = config.sessionId;
|
|
3277
3276
|
}
|
|
3278
|
-
this.
|
|
3279
|
-
|
|
3277
|
+
this.globalDomain = domainSession("global", this, this.logger.subLogger("global-domain"), [
|
|
3278
|
+
"welcome",
|
|
3279
|
+
"token",
|
|
3280
|
+
"authentication-request"
|
|
3281
|
+
]);
|
|
3282
|
+
sendOptions = { skipPeerId: true };
|
|
3283
|
+
if (this.initialLogin) {
|
|
3284
|
+
sendOptions.retryInterval = this.settings.reconnectInterval;
|
|
3285
|
+
sendOptions.maxRetries = this.settings.reconnectAttempts;
|
|
3286
|
+
}
|
|
3287
|
+
_a.label = 2;
|
|
3288
|
+
case 2:
|
|
3289
|
+
_a.trys.push([2, 4, 5, 6]);
|
|
3290
|
+
return [4, this.tryAuthenticate(this.globalDomain, helloMsg, sendOptions, config)];
|
|
3291
|
+
case 3:
|
|
3292
|
+
welcomeMsg = _a.sent();
|
|
3293
|
+
this.initialLogin = false;
|
|
3294
|
+
this.logger.info("login successful with peerId " + welcomeMsg.peer_id);
|
|
3295
|
+
this.peerId = welcomeMsg.peer_id;
|
|
3296
|
+
this.resolvedIdentity = welcomeMsg.resolved_identity;
|
|
3297
|
+
this.availableDomains = welcomeMsg.available_domains;
|
|
3298
|
+
if (welcomeMsg.options) {
|
|
3299
|
+
this.token = welcomeMsg.options.access_token;
|
|
3300
|
+
this.info = welcomeMsg.options.info;
|
|
3301
|
+
}
|
|
3302
|
+
this.setLoggedIn(true);
|
|
3303
|
+
return [2, welcomeMsg.resolved_identity];
|
|
3304
|
+
case 4:
|
|
3305
|
+
err_1 = _a.sent();
|
|
3306
|
+
this.logger.error("error sending hello message - " + (err_1.message || err_1.msg || err_1.reason || err_1), err_1);
|
|
3307
|
+
throw err_1;
|
|
3308
|
+
case 5:
|
|
3309
|
+
if ((config === null || config === void 0 ? void 0 : config.flowCallback) && config.sessionId) {
|
|
3310
|
+
config.flowCallback(config.sessionId, null);
|
|
3311
|
+
}
|
|
3312
|
+
return [7];
|
|
3313
|
+
case 6: return [2];
|
|
3314
|
+
}
|
|
3315
|
+
});
|
|
3316
|
+
});
|
|
3317
|
+
};
|
|
3318
|
+
Connection.prototype.tryAuthenticate = function (globalDomain, helloMsg, sendOptions, config) {
|
|
3319
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
3320
|
+
var welcomeMsg, msg, token, _a;
|
|
3321
|
+
return __generator(this, function (_b) {
|
|
3322
|
+
switch (_b.label) {
|
|
3323
|
+
case 0:
|
|
3324
|
+
return [4, globalDomain.send(helloMsg, undefined, sendOptions)];
|
|
3280
3325
|
case 1:
|
|
3281
|
-
|
|
3282
|
-
return [
|
|
3326
|
+
msg = _b.sent();
|
|
3327
|
+
if (!(msg.type === "authentication-request")) return [3, 4];
|
|
3328
|
+
token = Buffer.from(msg.authentication.token, "base64");
|
|
3329
|
+
if (!(config.flowCallback && config.sessionId)) return [3, 3];
|
|
3330
|
+
_a = helloMsg.authentication;
|
|
3331
|
+
return [4, config.flowCallback(config.sessionId, token)];
|
|
3283
3332
|
case 2:
|
|
3284
|
-
_a.
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
|
|
3333
|
+
_a.token =
|
|
3334
|
+
(_b.sent())
|
|
3335
|
+
.data
|
|
3336
|
+
.toString("base64");
|
|
3337
|
+
_b.label = 3;
|
|
3288
3338
|
case 3:
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
timer("connection").mark("protocol-logged-in");
|
|
3292
|
-
return [2, identity];
|
|
3339
|
+
helloMsg.request_id = config.sessionId;
|
|
3340
|
+
return [3, 5];
|
|
3293
3341
|
case 4:
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
|
|
3342
|
+
if (msg.type === "welcome") {
|
|
3343
|
+
welcomeMsg = msg;
|
|
3344
|
+
return [3, 6];
|
|
3345
|
+
}
|
|
3346
|
+
else if (msg.type === "error") {
|
|
3347
|
+
throw new Error("Authentication failed: " + msg.reason);
|
|
3348
|
+
}
|
|
3349
|
+
else {
|
|
3350
|
+
throw new Error("Unexpected message type during authentication: " + msg.type);
|
|
3351
|
+
}
|
|
3352
|
+
case 5: return [3, 0];
|
|
3353
|
+
case 6: return [2, welcomeMsg];
|
|
3354
|
+
}
|
|
3355
|
+
});
|
|
3356
|
+
});
|
|
3357
|
+
};
|
|
3358
|
+
Connection.prototype.setupAuthConfig = function (config, reconnect) {
|
|
3359
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
3360
|
+
var authentication, _a, e_1, _b;
|
|
3361
|
+
return __generator(this, function (_c) {
|
|
3362
|
+
switch (_c.label) {
|
|
3363
|
+
case 0:
|
|
3364
|
+
authentication = {};
|
|
3365
|
+
this.gatewayToken = config.gatewayToken;
|
|
3366
|
+
if (!config.gatewayToken) return [3, 5];
|
|
3367
|
+
if (!reconnect) return [3, 4];
|
|
3368
|
+
_c.label = 1;
|
|
3369
|
+
case 1:
|
|
3370
|
+
_c.trys.push([1, 3, , 4]);
|
|
3371
|
+
_a = config;
|
|
3372
|
+
return [4, this.getNewGWToken()];
|
|
3373
|
+
case 2:
|
|
3374
|
+
_a.gatewayToken = _c.sent();
|
|
3375
|
+
return [3, 4];
|
|
3376
|
+
case 3:
|
|
3377
|
+
e_1 = _c.sent();
|
|
3378
|
+
this.logger.warn("failed to get GW token when reconnecting ".concat((e_1 === null || e_1 === void 0 ? void 0 : e_1.message) || e_1));
|
|
3379
|
+
return [3, 4];
|
|
3380
|
+
case 4:
|
|
3381
|
+
authentication.method = "gateway-token";
|
|
3382
|
+
authentication.token = config.gatewayToken;
|
|
3383
|
+
this.gatewayToken = config.gatewayToken;
|
|
3384
|
+
return [3, 10];
|
|
3385
|
+
case 5:
|
|
3386
|
+
if (!(config.flowName === "sspi")) return [3, 9];
|
|
3387
|
+
authentication.provider = "win";
|
|
3388
|
+
authentication.method = "access-token";
|
|
3389
|
+
if (!(config.flowCallback && config.sessionId)) return [3, 7];
|
|
3390
|
+
_b = authentication;
|
|
3391
|
+
return [4, config.flowCallback(config.sessionId, null)];
|
|
3392
|
+
case 6:
|
|
3393
|
+
_b.token =
|
|
3394
|
+
(_c.sent())
|
|
3395
|
+
.data
|
|
3396
|
+
.toString("base64");
|
|
3397
|
+
return [3, 8];
|
|
3398
|
+
case 7: throw new Error("Invalid SSPI config");
|
|
3399
|
+
case 8: return [3, 10];
|
|
3400
|
+
case 9:
|
|
3401
|
+
if (config.token) {
|
|
3402
|
+
authentication.method = "access-token";
|
|
3403
|
+
authentication.token = config.token;
|
|
3404
|
+
}
|
|
3405
|
+
else if (config.username) {
|
|
3406
|
+
authentication.method = "secret";
|
|
3407
|
+
authentication.login = config.username;
|
|
3408
|
+
authentication.secret = config.password;
|
|
3298
3409
|
}
|
|
3299
|
-
|
|
3300
|
-
|
|
3410
|
+
else if (config.provider) {
|
|
3411
|
+
authentication.provider = config.provider;
|
|
3412
|
+
authentication.providerContext = config.providerContext;
|
|
3413
|
+
}
|
|
3414
|
+
else {
|
|
3415
|
+
throw new Error("invalid auth message" + JSON.stringify(config));
|
|
3416
|
+
}
|
|
3417
|
+
_c.label = 10;
|
|
3418
|
+
case 10: return [2, authentication];
|
|
3301
3419
|
}
|
|
3302
3420
|
});
|
|
3303
3421
|
});
|
|
3304
3422
|
};
|
|
3305
|
-
Connection.prototype.
|
|
3423
|
+
Connection.prototype.logoutCore = function () {
|
|
3306
3424
|
return __awaiter(this, void 0, void 0, function () {
|
|
3425
|
+
var promises;
|
|
3307
3426
|
return __generator(this, function (_a) {
|
|
3308
3427
|
switch (_a.label) {
|
|
3309
|
-
case 0:
|
|
3428
|
+
case 0:
|
|
3429
|
+
this.logger.debug("logging out...");
|
|
3430
|
+
this.shouldTryLogin = false;
|
|
3431
|
+
if (this.pingTimer) {
|
|
3432
|
+
clearTimeout(this.pingTimer);
|
|
3433
|
+
}
|
|
3434
|
+
promises = this.sessions.map(function (session) {
|
|
3435
|
+
session.leave();
|
|
3436
|
+
});
|
|
3437
|
+
return [4, Promise.all(promises)];
|
|
3310
3438
|
case 1:
|
|
3311
|
-
_a.sent();
|
|
3312
|
-
return [4, this.transport.close()];
|
|
3313
|
-
case 2:
|
|
3314
3439
|
_a.sent();
|
|
3315
3440
|
return [2];
|
|
3316
3441
|
}
|
|
3317
3442
|
});
|
|
3318
3443
|
});
|
|
3319
3444
|
};
|
|
3320
|
-
Connection.prototype.
|
|
3321
|
-
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
};
|
|
3326
|
-
Connection.prototype.authToken = function () {
|
|
3327
|
-
return this.protocol.authToken();
|
|
3328
|
-
};
|
|
3329
|
-
Connection.prototype.reconnect = function () {
|
|
3330
|
-
return this.transport.reconnect();
|
|
3331
|
-
};
|
|
3332
|
-
Connection.prototype.distributeMessage = function (message, type) {
|
|
3333
|
-
var _this = this;
|
|
3334
|
-
var handlers = this.messageHandlers[type.toLowerCase()];
|
|
3335
|
-
if (handlers !== undefined) {
|
|
3336
|
-
Object.keys(handlers).forEach(function (handlerId) {
|
|
3337
|
-
var handler = handlers[handlerId];
|
|
3338
|
-
if (handler !== undefined) {
|
|
3339
|
-
try {
|
|
3340
|
-
handler(message);
|
|
3341
|
-
}
|
|
3342
|
-
catch (error) {
|
|
3343
|
-
try {
|
|
3344
|
-
_this.logger.error("Message handler failed with ".concat(error.stack), error);
|
|
3345
|
-
}
|
|
3346
|
-
catch (loggerError) {
|
|
3347
|
-
console.log("Message handler failed", error);
|
|
3348
|
-
}
|
|
3349
|
-
}
|
|
3350
|
-
}
|
|
3351
|
-
});
|
|
3352
|
-
}
|
|
3353
|
-
};
|
|
3354
|
-
Connection.prototype.handleConnectionChanged = function (connected) {
|
|
3355
|
-
if (this._connected === connected) {
|
|
3356
|
-
return;
|
|
3357
|
-
}
|
|
3358
|
-
this._connected = connected;
|
|
3359
|
-
if (connected) {
|
|
3360
|
-
if (this.settings.replaySpecs && this.settings.replaySpecs.length) {
|
|
3361
|
-
this.replayer = new MessageReplayerImpl(this.settings.replaySpecs);
|
|
3362
|
-
this.replayer.init(this);
|
|
3445
|
+
Connection.prototype.getNewGWToken = function () {
|
|
3446
|
+
if (typeof window !== "undefined") {
|
|
3447
|
+
var glue42gd = window.glue42gd;
|
|
3448
|
+
if (glue42gd) {
|
|
3449
|
+
return glue42gd.getGWToken();
|
|
3363
3450
|
}
|
|
3364
|
-
this.registry.execute("connected");
|
|
3365
|
-
}
|
|
3366
|
-
else {
|
|
3367
|
-
this.registry.execute("disconnected");
|
|
3368
|
-
}
|
|
3369
|
-
};
|
|
3370
|
-
Connection.prototype.handleTransportMessage = function (msg) {
|
|
3371
|
-
var msgObj;
|
|
3372
|
-
if (typeof msg === "string") {
|
|
3373
|
-
msgObj = this.protocol.processStringMessage(msg);
|
|
3374
|
-
}
|
|
3375
|
-
else {
|
|
3376
|
-
msgObj = this.protocol.processObjectMessage(msg);
|
|
3377
3451
|
}
|
|
3378
|
-
|
|
3379
|
-
this.logger.trace("<< ".concat(JSON.stringify(msgObj)));
|
|
3380
|
-
}
|
|
3381
|
-
this.distributeMessage(msgObj.msg, msgObj.msgType);
|
|
3452
|
+
return Promise.reject(new Error("not running in GD"));
|
|
3382
3453
|
};
|
|
3383
|
-
Connection.prototype.
|
|
3454
|
+
Connection.prototype.ping = function () {
|
|
3384
3455
|
var _this = this;
|
|
3385
|
-
|
|
3386
|
-
var unsub;
|
|
3387
|
-
var ready = waitForInvocations(2, function () {
|
|
3388
|
-
if (unsub) {
|
|
3389
|
-
unsub();
|
|
3390
|
-
}
|
|
3391
|
-
resolve();
|
|
3392
|
-
});
|
|
3393
|
-
unsub = _this.onLibReAnnounced(function (lib) {
|
|
3394
|
-
if (lib.name === "interop") {
|
|
3395
|
-
return ready();
|
|
3396
|
-
}
|
|
3397
|
-
if (lib.name === "contexts") {
|
|
3398
|
-
return ready();
|
|
3399
|
-
}
|
|
3400
|
-
});
|
|
3401
|
-
}, 10000, "Transport switch timed out waiting for all libraries to be re-announced");
|
|
3402
|
-
};
|
|
3403
|
-
Connection.prototype.getNewSecondaryTransport = function (settings) {
|
|
3404
|
-
var _a;
|
|
3405
|
-
if (!((_a = settings.transportConfig) === null || _a === void 0 ? void 0 : _a.url)) {
|
|
3406
|
-
throw new Error("Missing secondary transport URL.");
|
|
3407
|
-
}
|
|
3408
|
-
return new WS(Object.assign({}, this.settings, { ws: settings.transportConfig.url, reconnectAttempts: 1 }), this.logger.subLogger("ws-secondary"));
|
|
3409
|
-
};
|
|
3410
|
-
Connection.prototype.getNewSecondaryAuth = function (settings) {
|
|
3411
|
-
var _a;
|
|
3412
|
-
if (!((_a = settings.transportConfig) === null || _a === void 0 ? void 0 : _a.auth)) {
|
|
3413
|
-
throw new Error("Missing secondary transport auth information.");
|
|
3414
|
-
}
|
|
3415
|
-
return settings.transportConfig.auth;
|
|
3416
|
-
};
|
|
3417
|
-
Connection.prototype.transportSwap = function () {
|
|
3418
|
-
this._swapTransport = false;
|
|
3419
|
-
if (!this._targetTransport || !this._targetAuth) {
|
|
3420
|
-
this.logger.warn("Error while switching transports - either the target transport or auth is not defined: transport defined -> ".concat(!!this._defaultTransport, ", auth defined -> ").concat(!!this._targetAuth, ". Staying on the current one."));
|
|
3456
|
+
if (!this.shouldTryLogin) {
|
|
3421
3457
|
return;
|
|
3422
3458
|
}
|
|
3423
|
-
this.
|
|
3424
|
-
|
|
3425
|
-
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
|
|
3429
|
-
this._transportSubscriptions.push(unsubOnMessage);
|
|
3430
|
-
return this._targetAuth;
|
|
3431
|
-
};
|
|
3432
|
-
Connection.prototype.prepareDefaultSwap = function () {
|
|
3433
|
-
var _this = this;
|
|
3434
|
-
this._transportSubscriptions.forEach(function (unsub) { return unsub(); });
|
|
3435
|
-
this._transportSubscriptions = [];
|
|
3436
|
-
this.transport.close().catch(function (error) { return _this.logger.warn("Error closing the ".concat(_this.transport.name(), " transport after a failed connection attempt: ").concat(JSON.stringify(error))); });
|
|
3437
|
-
this._targetTransport = this._defaultTransport;
|
|
3438
|
-
this._targetAuth = this._defaultAuth;
|
|
3439
|
-
this._swapTransport = true;
|
|
3459
|
+
if (this._isLoggedIn) {
|
|
3460
|
+
this.send({ type: "ping" });
|
|
3461
|
+
}
|
|
3462
|
+
this.pingTimer = setTimeout(function () {
|
|
3463
|
+
_this.ping();
|
|
3464
|
+
}, 30 * 1000);
|
|
3440
3465
|
};
|
|
3441
3466
|
return Connection;
|
|
3442
3467
|
}());
|
|
@@ -3619,7 +3644,7 @@
|
|
|
3619
3644
|
}
|
|
3620
3645
|
};
|
|
3621
3646
|
|
|
3622
|
-
var version$2 = "6.1
|
|
3647
|
+
var version$2 = "6.2.1";
|
|
3623
3648
|
|
|
3624
3649
|
function prepareConfig$1 (configuration, ext, glue42gd) {
|
|
3625
3650
|
var _a, _b, _c, _d;
|
|
@@ -5895,7 +5920,7 @@
|
|
|
5895
5920
|
currentContext = _b.sent();
|
|
5896
5921
|
_b.label = 4;
|
|
5897
5922
|
case 4:
|
|
5898
|
-
calculatedDelta = this.
|
|
5923
|
+
calculatedDelta = this.setPathSupported ?
|
|
5899
5924
|
this.calculateContextDeltaV2(currentContext, delta) :
|
|
5900
5925
|
this.calculateContextDeltaV1(currentContext, delta);
|
|
5901
5926
|
if (!Object.keys(calculatedDelta.added).length
|
|
@@ -7400,41 +7425,46 @@
|
|
|
7400
7425
|
return this.registerCore(methodDefinition, wrappedCallbackFunction);
|
|
7401
7426
|
};
|
|
7402
7427
|
Server.prototype.registerAsync = function (methodDefinition, callback) {
|
|
7428
|
+
var _this = this;
|
|
7403
7429
|
if (!methodDefinition) {
|
|
7404
7430
|
return Promise.reject("Method definition is required. Please, provide either a unique string for a method name or a “methodDefinition” object with a required “name” property.");
|
|
7405
7431
|
}
|
|
7406
7432
|
if (typeof callback !== "function") {
|
|
7407
7433
|
return Promise.reject("The second parameter must be a callback function. Method: ".concat(typeof methodDefinition === "string" ? methodDefinition : methodDefinition.name));
|
|
7408
7434
|
}
|
|
7409
|
-
var wrappedCallback = function (context, resultCallback) {
|
|
7410
|
-
|
|
7411
|
-
|
|
7412
|
-
|
|
7413
|
-
|
|
7414
|
-
|
|
7415
|
-
|
|
7416
|
-
|
|
7417
|
-
};
|
|
7418
|
-
var error = function (e) {
|
|
7419
|
-
if (!resultCalled_1) {
|
|
7420
|
-
if (!e) {
|
|
7421
|
-
e = "";
|
|
7435
|
+
var wrappedCallback = function (context, resultCallback) { return __awaiter(_this, void 0, void 0, function () {
|
|
7436
|
+
var resultCalled_1, success, error, methodResult;
|
|
7437
|
+
return __generator(this, function (_a) {
|
|
7438
|
+
try {
|
|
7439
|
+
resultCalled_1 = false;
|
|
7440
|
+
success = function (result) {
|
|
7441
|
+
if (!resultCalled_1) {
|
|
7442
|
+
resultCallback(undefined, result);
|
|
7422
7443
|
}
|
|
7423
|
-
|
|
7444
|
+
resultCalled_1 = true;
|
|
7445
|
+
};
|
|
7446
|
+
error = function (e) {
|
|
7447
|
+
if (!resultCalled_1) {
|
|
7448
|
+
if (!e) {
|
|
7449
|
+
e = "";
|
|
7450
|
+
}
|
|
7451
|
+
resultCallback(e, e);
|
|
7452
|
+
}
|
|
7453
|
+
resultCalled_1 = true;
|
|
7454
|
+
};
|
|
7455
|
+
methodResult = callback(context.args, context.instance, success, error);
|
|
7456
|
+
if (methodResult && typeof methodResult.then === "function") {
|
|
7457
|
+
methodResult
|
|
7458
|
+
.then(success)
|
|
7459
|
+
.catch(error);
|
|
7424
7460
|
}
|
|
7425
|
-
resultCalled_1 = true;
|
|
7426
|
-
};
|
|
7427
|
-
var methodResult = callback(context.args, context.instance, success, error);
|
|
7428
|
-
if (methodResult && typeof methodResult.then === "function") {
|
|
7429
|
-
methodResult
|
|
7430
|
-
.then(success)
|
|
7431
|
-
.catch(error);
|
|
7432
7461
|
}
|
|
7433
|
-
|
|
7434
|
-
|
|
7435
|
-
|
|
7436
|
-
|
|
7437
|
-
|
|
7462
|
+
catch (e) {
|
|
7463
|
+
resultCallback(e, undefined);
|
|
7464
|
+
}
|
|
7465
|
+
return [2];
|
|
7466
|
+
});
|
|
7467
|
+
}); };
|
|
7438
7468
|
wrappedCallback.userCallbackAsync = callback;
|
|
7439
7469
|
return this.registerCore(methodDefinition, wrappedCallback);
|
|
7440
7470
|
};
|
|
@@ -7545,7 +7575,7 @@
|
|
|
7545
7575
|
return [2, Promise.reject("Please, provide a (unique) string value for the \u201Cname\u201D property in the \u201CmethodDefinition\u201D object: ".concat(JSON.stringify(method)))];
|
|
7546
7576
|
}
|
|
7547
7577
|
unregisterInProgress = this.currentlyUnregistering[methodDefinition.name];
|
|
7548
|
-
if (!unregisterInProgress) return [3, 2];
|
|
7578
|
+
if (!(typeof unregisterInProgress !== "undefined")) return [3, 2];
|
|
7549
7579
|
return [4, unregisterInProgress];
|
|
7550
7580
|
case 1:
|
|
7551
7581
|
_a.sent();
|
|
@@ -8875,10 +8905,11 @@
|
|
|
8875
8905
|
var server = new ServerProtocol(session, clientRepository, serverRepository, logger.subLogger("server"));
|
|
8876
8906
|
var client = new ClientProtocol(session, clientRepository, logger.subLogger("client"));
|
|
8877
8907
|
function handleReconnect() {
|
|
8908
|
+
var _a, _b;
|
|
8878
8909
|
return __awaiter(this, void 0, void 0, function () {
|
|
8879
|
-
var reconnectionPromises, existingSubscriptions, _loop_1, _i, existingSubscriptions_1, sub, registeredMethods, _loop_2,
|
|
8880
|
-
return __generator(this, function (
|
|
8881
|
-
switch (
|
|
8910
|
+
var reconnectionPromises, existingSubscriptions, _loop_1, _i, existingSubscriptions_1, sub, registeredMethods, _loop_2, _c, registeredMethods_1, method;
|
|
8911
|
+
return __generator(this, function (_d) {
|
|
8912
|
+
switch (_d.label) {
|
|
8882
8913
|
case 0:
|
|
8883
8914
|
logger.info("reconnected - will replay registered methods and subscriptions");
|
|
8884
8915
|
client.drainSubscriptionsCache().forEach(function (sub) {
|
|
@@ -8903,25 +8934,29 @@
|
|
|
8903
8934
|
serverRepository.reset();
|
|
8904
8935
|
_loop_2 = function (method) {
|
|
8905
8936
|
var def = method.definition;
|
|
8906
|
-
logger.info("re-publishing method ".concat(def.name));
|
|
8907
8937
|
if (method.stream) {
|
|
8908
|
-
reconnectionPromises.push(interop.server.createStream(def, method.streamCallbacks, undefined, undefined, method.stream)
|
|
8938
|
+
reconnectionPromises.push(interop.server.createStream(def, method.streamCallbacks, undefined, undefined, method.stream)
|
|
8939
|
+
.then(function () { return logger.info("subscribing to method ".concat(def.name, " DONE")); })
|
|
8940
|
+
.catch(function () { return logger.warn("subscribing to method ".concat(def.name, " FAILED")); }));
|
|
8909
8941
|
}
|
|
8910
|
-
else if (method
|
|
8911
|
-
reconnectionPromises.push(interop.register(def, method.theFunction.userCallback)
|
|
8942
|
+
else if ((_a = method === null || method === void 0 ? void 0 : method.theFunction) === null || _a === void 0 ? void 0 : _a.userCallback) {
|
|
8943
|
+
reconnectionPromises.push(interop.register(def, method.theFunction.userCallback)
|
|
8944
|
+
.then(function () { return logger.info("registering method ".concat(def.name, " DONE")); })
|
|
8945
|
+
.catch(function () { return logger.warn("registering method ".concat(def.name, " FAILED")); }));
|
|
8912
8946
|
}
|
|
8913
|
-
else if (method
|
|
8914
|
-
reconnectionPromises.push(interop.registerAsync(def, method.theFunction.userCallbackAsync)
|
|
8947
|
+
else if ((_b = method === null || method === void 0 ? void 0 : method.theFunction) === null || _b === void 0 ? void 0 : _b.userCallbackAsync) {
|
|
8948
|
+
reconnectionPromises.push(interop.registerAsync(def, method.theFunction.userCallbackAsync)
|
|
8949
|
+
.then(function () { return logger.info("registering method ".concat(def.name, " DONE")); })
|
|
8950
|
+
.catch(function () { return logger.warn("registering method ".concat(def.name, " FAILED")); }));
|
|
8915
8951
|
}
|
|
8916
|
-
logger.info("re-publishing method ".concat(def.name, " DONE"));
|
|
8917
8952
|
};
|
|
8918
|
-
for (
|
|
8919
|
-
method = registeredMethods_1[
|
|
8953
|
+
for (_c = 0, registeredMethods_1 = registeredMethods; _c < registeredMethods_1.length; _c++) {
|
|
8954
|
+
method = registeredMethods_1[_c];
|
|
8920
8955
|
_loop_2(method);
|
|
8921
8956
|
}
|
|
8922
8957
|
return [4, Promise.all(reconnectionPromises)];
|
|
8923
8958
|
case 1:
|
|
8924
|
-
|
|
8959
|
+
_d.sent();
|
|
8925
8960
|
logger.info("Interop is re-announced");
|
|
8926
8961
|
return [2];
|
|
8927
8962
|
}
|
|
@@ -12381,6 +12416,7 @@
|
|
|
12381
12416
|
const StartApplicationMethodName = "T42.ACS.StartApplication";
|
|
12382
12417
|
const StopApplicationMethodName = "T42.ACS.StopApplication";
|
|
12383
12418
|
const ActivateApplicationMethodName = "T42.ACS.ActivateApplication";
|
|
12419
|
+
const ACSExecute = "T42.ACS.Execute";
|
|
12384
12420
|
const OnEventMethodName = "T42.ACS.OnEvent";
|
|
12385
12421
|
const GetApplicationsMethodName = "T42.ACS.GetApplications";
|
|
12386
12422
|
|
|
@@ -12966,6 +13002,10 @@
|
|
|
12966
13002
|
getContext() {
|
|
12967
13003
|
return Promise.resolve(this.context);
|
|
12968
13004
|
}
|
|
13005
|
+
async startedBy() {
|
|
13006
|
+
const result = await this._agm.invoke(ACSExecute, { command: "getStartedBy", Name: this._appName, Id: this._id });
|
|
13007
|
+
return result.returned;
|
|
13008
|
+
}
|
|
12969
13009
|
}
|
|
12970
13010
|
|
|
12971
13011
|
class AppManagerImpl {
|
|
@@ -13022,8 +13062,9 @@
|
|
|
13022
13062
|
return undefined;
|
|
13023
13063
|
};
|
|
13024
13064
|
this.getMyApplication = () => {
|
|
13065
|
+
var _a;
|
|
13025
13066
|
if (this._agm.instance) {
|
|
13026
|
-
return this.application(this._agm.instance.applicationName);
|
|
13067
|
+
return (_a = this.application(this._agm.instance.applicationName)) !== null && _a !== void 0 ? _a : this.application(this._agm.instance.application);
|
|
13027
13068
|
}
|
|
13028
13069
|
};
|
|
13029
13070
|
this.handleSnapshotAppsAdded = (newApps) => {
|
|
@@ -15892,20 +15933,15 @@
|
|
|
15892
15933
|
}, "TabHeaderVisibilityChanged");
|
|
15893
15934
|
return w;
|
|
15894
15935
|
}
|
|
15936
|
+
async showGroupPopup(id, options) {
|
|
15937
|
+
const reformatedOptions = this.showPopupCore(id, options);
|
|
15938
|
+
await this.executeGroup("showGroupPopup", {
|
|
15939
|
+
groupId: id,
|
|
15940
|
+
options: reformatedOptions
|
|
15941
|
+
});
|
|
15942
|
+
}
|
|
15895
15943
|
async showPopup(targetWindow, options) {
|
|
15896
|
-
|
|
15897
|
-
throw new Error("The options object is not valid!");
|
|
15898
|
-
}
|
|
15899
|
-
const optionsCopy = { ...options };
|
|
15900
|
-
if (!optionsCopy.targetLocation) {
|
|
15901
|
-
optionsCopy.targetLocation = "bottom";
|
|
15902
|
-
}
|
|
15903
|
-
const reformatedOptions = {
|
|
15904
|
-
...optionsCopy,
|
|
15905
|
-
popupBounds: optionsCopy.size,
|
|
15906
|
-
targetId: targetWindow.id,
|
|
15907
|
-
popupId: optionsCopy.windowId
|
|
15908
|
-
};
|
|
15944
|
+
const reformatedOptions = this.showPopupCore(targetWindow.id, options);
|
|
15909
15945
|
await this.execute("showPopupWindow", {
|
|
15910
15946
|
windowId: targetWindow.id,
|
|
15911
15947
|
options: reformatedOptions
|
|
@@ -16402,16 +16438,33 @@
|
|
|
16402
16438
|
return context;
|
|
16403
16439
|
}
|
|
16404
16440
|
}
|
|
16441
|
+
showPopupCore(id, options) {
|
|
16442
|
+
if (!options) {
|
|
16443
|
+
throw new Error("The options object is not valid!");
|
|
16444
|
+
}
|
|
16445
|
+
const optionsCopy = { ...options };
|
|
16446
|
+
if (!optionsCopy.targetLocation) {
|
|
16447
|
+
optionsCopy.targetLocation = "bottom";
|
|
16448
|
+
}
|
|
16449
|
+
const reformatedOptions = {
|
|
16450
|
+
...optionsCopy,
|
|
16451
|
+
popupBounds: optionsCopy.size,
|
|
16452
|
+
targetId: id,
|
|
16453
|
+
popupId: optionsCopy.windowId
|
|
16454
|
+
};
|
|
16455
|
+
return reformatedOptions;
|
|
16456
|
+
}
|
|
16405
16457
|
}
|
|
16406
16458
|
var executor = new GDExecutor();
|
|
16407
16459
|
|
|
16408
16460
|
class GDEnvironment {
|
|
16409
|
-
constructor(agm, logger, appManagerGetter, displayAPIGetter, channelsAPIGetter, wndId) {
|
|
16461
|
+
constructor(agm, logger, appManagerGetter, displayAPIGetter, channelsAPIGetter, wndId, groupId) {
|
|
16410
16462
|
this._registry = lib();
|
|
16411
16463
|
this._waitTimeout = 10000;
|
|
16412
16464
|
this._agm = agm;
|
|
16413
16465
|
this._logger = logger.subLogger("gd-env");
|
|
16414
16466
|
this._windowId = wndId;
|
|
16467
|
+
this._groupId = groupId;
|
|
16415
16468
|
this._appManagerGetter = appManagerGetter;
|
|
16416
16469
|
this._displayAPIGetter = displayAPIGetter;
|
|
16417
16470
|
this._channelsAPIGetter = channelsAPIGetter;
|
|
@@ -16486,6 +16539,9 @@
|
|
|
16486
16539
|
my() {
|
|
16487
16540
|
return this._windowId;
|
|
16488
16541
|
}
|
|
16542
|
+
myGroup() {
|
|
16543
|
+
return this._groupId;
|
|
16544
|
+
}
|
|
16489
16545
|
execute(command, windowId, options) {
|
|
16490
16546
|
return this._agm.invoke("T42.Wnd.Execute", {
|
|
16491
16547
|
command,
|
|
@@ -16780,6 +16836,7 @@
|
|
|
16780
16836
|
}
|
|
16781
16837
|
|
|
16782
16838
|
var envDetector = (agm, logger, appManagerGetter, displayAPIGetter, channelsAPIGetter, gdMajorVersion) => {
|
|
16839
|
+
var _a;
|
|
16783
16840
|
const _logger = logger;
|
|
16784
16841
|
if (gdMajorVersion === 2) {
|
|
16785
16842
|
_logger.trace("running in HC");
|
|
@@ -16787,7 +16844,7 @@
|
|
|
16787
16844
|
}
|
|
16788
16845
|
else if (gdMajorVersion >= 3) {
|
|
16789
16846
|
_logger.trace("running in GD 3");
|
|
16790
|
-
return new GDEnvironment(agm, _logger, appManagerGetter, displayAPIGetter, channelsAPIGetter, window.glue42gd.windowId).init();
|
|
16847
|
+
return new GDEnvironment(agm, _logger, appManagerGetter, displayAPIGetter, channelsAPIGetter, window.glue42gd.windowId, (_a = window.webGroupsManager) === null || _a === void 0 ? void 0 : _a.id).init();
|
|
16791
16848
|
}
|
|
16792
16849
|
else {
|
|
16793
16850
|
return new GDEnvironment(agm, _logger, appManagerGetter, displayAPIGetter, channelsAPIGetter).init();
|
|
@@ -16979,6 +17036,14 @@
|
|
|
16979
17036
|
groupId: id
|
|
16980
17037
|
});
|
|
16981
17038
|
},
|
|
17039
|
+
close: () => {
|
|
17040
|
+
return executor.executeGroup("closeGroup", {
|
|
17041
|
+
groupId: id
|
|
17042
|
+
});
|
|
17043
|
+
},
|
|
17044
|
+
showPopup: (options) => {
|
|
17045
|
+
return executor.showGroupPopup(id, options);
|
|
17046
|
+
},
|
|
16982
17047
|
onHeaderVisibilityChanged,
|
|
16983
17048
|
onWindowAdded,
|
|
16984
17049
|
onWindowRemoved,
|
|
@@ -17045,20 +17110,55 @@
|
|
|
17045
17110
|
environment.onGroupStateChanged((data) => {
|
|
17046
17111
|
const groupWrapper = _groups[data.groupId];
|
|
17047
17112
|
if (data.state === "hibernated") {
|
|
17048
|
-
if (groupWrapper
|
|
17113
|
+
if (groupWrapper === null || groupWrapper === void 0 ? void 0 : groupWrapper.groupAPI) {
|
|
17049
17114
|
groupWrapper.groupInternal.handleGroupHibernateChanged(true);
|
|
17050
17115
|
}
|
|
17051
17116
|
_registry.execute("group-hibernated", data.groupId);
|
|
17052
17117
|
}
|
|
17053
17118
|
else if (data.state === "resumed") {
|
|
17054
|
-
if (groupWrapper
|
|
17119
|
+
if (groupWrapper === null || groupWrapper === void 0 ? void 0 : groupWrapper.groupAPI) {
|
|
17055
17120
|
groupWrapper.groupInternal.handleGroupHibernateChanged(false);
|
|
17056
17121
|
}
|
|
17057
17122
|
_registry.execute("group-resumed", groupWrapper.groupAPI);
|
|
17058
17123
|
}
|
|
17059
17124
|
});
|
|
17060
17125
|
function my() {
|
|
17061
|
-
|
|
17126
|
+
var _a;
|
|
17127
|
+
return findGroupByWindow((_a = environment.myGroup()) !== null && _a !== void 0 ? _a : environment.my());
|
|
17128
|
+
}
|
|
17129
|
+
async function create(options) {
|
|
17130
|
+
if (isUndefinedOrNull(options)) {
|
|
17131
|
+
throw new Error(`options must be defined`);
|
|
17132
|
+
}
|
|
17133
|
+
if (isUndefinedOrNull(options.groups) || !Array.isArray(options.groups) || options.groups.length === 0) {
|
|
17134
|
+
throw new Error(`options.groups must be defined`);
|
|
17135
|
+
}
|
|
17136
|
+
const { groupIds } = await executor.executeGroup("createGroups", {
|
|
17137
|
+
options
|
|
17138
|
+
});
|
|
17139
|
+
const groups = groupIds.map((groupId) => {
|
|
17140
|
+
return waitForGroup(groupId);
|
|
17141
|
+
});
|
|
17142
|
+
return Promise.all(groups);
|
|
17143
|
+
}
|
|
17144
|
+
async function close(idOrGroup, options) {
|
|
17145
|
+
if (isUndefinedOrNull(idOrGroup)) {
|
|
17146
|
+
throw new Error(`group must be defined`);
|
|
17147
|
+
}
|
|
17148
|
+
let groupId = "";
|
|
17149
|
+
if (typeof idOrGroup === "string") {
|
|
17150
|
+
groupId = idOrGroup;
|
|
17151
|
+
}
|
|
17152
|
+
else {
|
|
17153
|
+
groupId = idOrGroup.id;
|
|
17154
|
+
}
|
|
17155
|
+
if (isUndefinedOrNull(options)) {
|
|
17156
|
+
throw new Error(`options must be defined`);
|
|
17157
|
+
}
|
|
17158
|
+
await executor.executeGroup("closeGroup", {
|
|
17159
|
+
groupId,
|
|
17160
|
+
options
|
|
17161
|
+
});
|
|
17062
17162
|
}
|
|
17063
17163
|
function list(success) {
|
|
17064
17164
|
const result = Object.keys(_groups).map((groupId) => {
|
|
@@ -17090,15 +17190,13 @@
|
|
|
17090
17190
|
}
|
|
17091
17191
|
return result.groupAPI;
|
|
17092
17192
|
}
|
|
17093
|
-
else {
|
|
17094
|
-
|
|
17095
|
-
error(`Cannot find the group of the window.`);
|
|
17096
|
-
}
|
|
17193
|
+
else if (typeof error === "function") {
|
|
17194
|
+
error(`Cannot find the group of the window.`);
|
|
17097
17195
|
}
|
|
17098
17196
|
}
|
|
17099
17197
|
function waitForGroup(groupId) {
|
|
17100
17198
|
if (!groupId) {
|
|
17101
|
-
return Promise.reject(`groupId must be defined`);
|
|
17199
|
+
return Promise.reject(new Error(`groupId must be defined`));
|
|
17102
17200
|
}
|
|
17103
17201
|
return new Promise((res, rej) => {
|
|
17104
17202
|
const groupWrapper = _groups[groupId];
|
|
@@ -17115,6 +17213,10 @@
|
|
|
17115
17213
|
}
|
|
17116
17214
|
});
|
|
17117
17215
|
}
|
|
17216
|
+
function getMyGroup() {
|
|
17217
|
+
var _a;
|
|
17218
|
+
return waitForGroup((_a = environment.myGroup()) !== null && _a !== void 0 ? _a : environment.my());
|
|
17219
|
+
}
|
|
17118
17220
|
async function resume(groupId, activate) {
|
|
17119
17221
|
if (!isUndefinedOrNull(activate) && !isBoolean(activate)) {
|
|
17120
17222
|
throw new Error("Activate flag must be a boolean!");
|
|
@@ -17236,9 +17338,12 @@
|
|
|
17236
17338
|
get my() {
|
|
17237
17339
|
return my();
|
|
17238
17340
|
},
|
|
17341
|
+
create,
|
|
17342
|
+
close,
|
|
17239
17343
|
list,
|
|
17240
17344
|
findGroupByWindow,
|
|
17241
17345
|
waitForGroup,
|
|
17346
|
+
getMyGroup,
|
|
17242
17347
|
onGroupAdded,
|
|
17243
17348
|
onGroupRemoved,
|
|
17244
17349
|
hibernate,
|
|
@@ -18401,6 +18506,36 @@
|
|
|
18401
18506
|
data: { newChannel: channel }
|
|
18402
18507
|
});
|
|
18403
18508
|
}
|
|
18509
|
+
async function setRestrictions(restrictions) {
|
|
18510
|
+
var _a;
|
|
18511
|
+
await interop.invoke(T42_ANNOUNCE_METHOD_NAME, {
|
|
18512
|
+
swId: (_a = restrictions.windowId) !== null && _a !== void 0 ? _a : windowId,
|
|
18513
|
+
command: "restrict",
|
|
18514
|
+
data: restrictions
|
|
18515
|
+
});
|
|
18516
|
+
return;
|
|
18517
|
+
}
|
|
18518
|
+
async function getRestrictionsByWindow(id) {
|
|
18519
|
+
try {
|
|
18520
|
+
const result = await interop.invoke(T42_ANNOUNCE_METHOD_NAME, {
|
|
18521
|
+
swId: id !== null && id !== void 0 ? id : windowId,
|
|
18522
|
+
command: "getRestrictions"
|
|
18523
|
+
});
|
|
18524
|
+
return result.returned;
|
|
18525
|
+
}
|
|
18526
|
+
catch (e) {
|
|
18527
|
+
return;
|
|
18528
|
+
}
|
|
18529
|
+
}
|
|
18530
|
+
async function setRestrictionsForAllChannels(restrictions) {
|
|
18531
|
+
var _a;
|
|
18532
|
+
await interop.invoke(T42_ANNOUNCE_METHOD_NAME, {
|
|
18533
|
+
swId: (_a = restrictions.windowId) !== null && _a !== void 0 ? _a : windowId,
|
|
18534
|
+
command: "restrictAll",
|
|
18535
|
+
data: restrictions
|
|
18536
|
+
});
|
|
18537
|
+
return;
|
|
18538
|
+
}
|
|
18404
18539
|
async function getWindowsWithChannels(filter) {
|
|
18405
18540
|
const result = await interop.invoke(T42_ANNOUNCE_METHOD_NAME, { command: "getChannelsInfo", data: { filter } });
|
|
18406
18541
|
return result.returned;
|
|
@@ -18541,19 +18676,25 @@
|
|
|
18541
18676
|
}
|
|
18542
18677
|
const id = Utils.generateId();
|
|
18543
18678
|
this.pendingReplays[id] = true;
|
|
18679
|
+
const callbackWithPermissionCheck = async (data, context, updaterId) => {
|
|
18680
|
+
const canRead = await this.canReadFromChannel(context.name);
|
|
18681
|
+
if (canRead) {
|
|
18682
|
+
callback(data, context, updaterId);
|
|
18683
|
+
}
|
|
18684
|
+
};
|
|
18544
18685
|
if (this.lastUpdate) {
|
|
18545
18686
|
let lastUpdate = Object.assign({}, this.lastUpdate);
|
|
18546
|
-
setTimeout(() => {
|
|
18687
|
+
setTimeout(async () => {
|
|
18547
18688
|
if (this.pendingReplays[id]) {
|
|
18548
18689
|
if (this.lastUpdate) {
|
|
18549
18690
|
lastUpdate = this.lastUpdate;
|
|
18550
18691
|
}
|
|
18551
|
-
|
|
18692
|
+
callbackWithPermissionCheck(lastUpdate.context.data, lastUpdate.context, lastUpdate.updaterId);
|
|
18552
18693
|
}
|
|
18553
18694
|
delete this.pendingReplays[id];
|
|
18554
18695
|
}, 0);
|
|
18555
18696
|
}
|
|
18556
|
-
const unsub = this.registry.add(this.subsKey,
|
|
18697
|
+
const unsub = this.registry.add(this.subsKey, callbackWithPermissionCheck);
|
|
18557
18698
|
return () => {
|
|
18558
18699
|
this.pendingReplays[id] = false;
|
|
18559
18700
|
unsub();
|
|
@@ -18580,11 +18721,17 @@
|
|
|
18580
18721
|
if (!this.shared.isChannel(name)) {
|
|
18581
18722
|
return Promise.reject(new Error(`A channel with name: ${name} doesn't exist!`));
|
|
18582
18723
|
}
|
|
18724
|
+
if (!await this.canWriteToChannel(name)) {
|
|
18725
|
+
throw new Error(`Window does not have permission to write to channel ${name}`);
|
|
18726
|
+
}
|
|
18583
18727
|
return this.shared.updateData(name, data);
|
|
18584
18728
|
}
|
|
18585
18729
|
if (!this.currentContext) {
|
|
18586
18730
|
throw new Error("Not joined to any channel!");
|
|
18587
18731
|
}
|
|
18732
|
+
if (!await this.canWriteToChannel(this.currentContext)) {
|
|
18733
|
+
throw new Error(`Window does not have permission to write to channel ${this.currentContext}`);
|
|
18734
|
+
}
|
|
18588
18735
|
return this.shared.updateData(this.currentContext, data);
|
|
18589
18736
|
}
|
|
18590
18737
|
all() {
|
|
@@ -18712,6 +18859,15 @@
|
|
|
18712
18859
|
}
|
|
18713
18860
|
return [];
|
|
18714
18861
|
}
|
|
18862
|
+
async restrict(restriction) {
|
|
18863
|
+
return setRestrictions(restriction);
|
|
18864
|
+
}
|
|
18865
|
+
async getRestrictions(windowId) {
|
|
18866
|
+
return getRestrictionsByWindow(windowId);
|
|
18867
|
+
}
|
|
18868
|
+
async restrictAll(restriction) {
|
|
18869
|
+
return setRestrictionsForAllChannels(restriction);
|
|
18870
|
+
}
|
|
18715
18871
|
handler(data, context, updaterId) {
|
|
18716
18872
|
if (!context && !updaterId) {
|
|
18717
18873
|
this.lastUpdate = undefined;
|
|
@@ -18766,6 +18922,22 @@
|
|
|
18766
18922
|
}
|
|
18767
18923
|
return Promise.resolve();
|
|
18768
18924
|
}
|
|
18925
|
+
async canReadFromChannel(channelName) {
|
|
18926
|
+
const restrictions = await getRestrictionsByWindow();
|
|
18927
|
+
if (!restrictions || !Array.isArray(restrictions.channels) || !restrictions.channels.find(c => c.name === channelName)) {
|
|
18928
|
+
return true;
|
|
18929
|
+
}
|
|
18930
|
+
const byChannel = restrictions.channels.find(c => c.name === channelName);
|
|
18931
|
+
return byChannel.read;
|
|
18932
|
+
}
|
|
18933
|
+
async canWriteToChannel(channelName) {
|
|
18934
|
+
const restrictions = await getRestrictionsByWindow();
|
|
18935
|
+
if (!restrictions || !Array.isArray(restrictions.channels) || !restrictions.channels.find(c => c.name === channelName)) {
|
|
18936
|
+
return true;
|
|
18937
|
+
}
|
|
18938
|
+
const byChannel = restrictions.channels.find(c => c.name === channelName);
|
|
18939
|
+
return byChannel.write;
|
|
18940
|
+
}
|
|
18769
18941
|
}
|
|
18770
18942
|
|
|
18771
18943
|
function factory$4(contexts, agm, getWindows, logger) {
|
|
@@ -18781,6 +18953,9 @@
|
|
|
18781
18953
|
get: channels.get.bind(channels),
|
|
18782
18954
|
join: channels.join.bind(channels),
|
|
18783
18955
|
leave: channels.leave.bind(channels),
|
|
18956
|
+
restrict: channels.restrict.bind(channels),
|
|
18957
|
+
getRestrictions: channels.getRestrictions.bind(channels),
|
|
18958
|
+
restrictAll: channels.restrictAll.bind(channels),
|
|
18784
18959
|
current: channels.current.bind(channels),
|
|
18785
18960
|
my: channels.my.bind(channels),
|
|
18786
18961
|
changed: channels.changed.bind(channels),
|
|
@@ -18884,7 +19059,7 @@
|
|
|
18884
19059
|
};
|
|
18885
19060
|
}
|
|
18886
19061
|
|
|
18887
|
-
var version = "6.
|
|
19062
|
+
var version = "6.4.0";
|
|
18888
19063
|
|
|
18889
19064
|
var prepareConfig = (options) => {
|
|
18890
19065
|
function getLibConfig(value, defaultMode, trueMode) {
|
|
@@ -19034,13 +19209,14 @@
|
|
|
19034
19209
|
this.subscriptionsCountForCounter = 0;
|
|
19035
19210
|
this.logger = logger.subLogger("notifications");
|
|
19036
19211
|
this._panel = new PanelAPI(interop, this.onStreamEventCore.bind(this));
|
|
19212
|
+
this._panelAPI = this._panel.toAPI();
|
|
19037
19213
|
this.subscribeInternalEvents();
|
|
19038
19214
|
}
|
|
19039
19215
|
get maxActions() {
|
|
19040
19216
|
return 2;
|
|
19041
19217
|
}
|
|
19042
19218
|
get panel() {
|
|
19043
|
-
return this.
|
|
19219
|
+
return this._panelAPI;
|
|
19044
19220
|
}
|
|
19045
19221
|
async raise(options) {
|
|
19046
19222
|
var _a, _b, _c, _d;
|
|
@@ -19147,7 +19323,7 @@
|
|
|
19147
19323
|
return result.returned;
|
|
19148
19324
|
}
|
|
19149
19325
|
async list() {
|
|
19150
|
-
const interopResult = await this.interop.invoke(this.NotificationsExecuteMethod, { command: "list" });
|
|
19326
|
+
const interopResult = await this.interop.invoke(this.NotificationsExecuteMethod, { command: "list", data: { statesVersion2: true } });
|
|
19151
19327
|
return interopResult.returned.notifications;
|
|
19152
19328
|
}
|
|
19153
19329
|
async updateData(id, data) {
|
|
@@ -19207,7 +19383,7 @@
|
|
|
19207
19383
|
await this.interop.invoke(this.NotificationsExecuteMethod, { command: "clearAll" });
|
|
19208
19384
|
}
|
|
19209
19385
|
async clearOld() {
|
|
19210
|
-
await this.interop.invoke(this.NotificationsExecuteMethod, { command: "clearAllOld" });
|
|
19386
|
+
await this.interop.invoke(this.NotificationsExecuteMethod, { command: "clearAllOld", data: { statesVersion2: true } });
|
|
19211
19387
|
}
|
|
19212
19388
|
async clear(id) {
|
|
19213
19389
|
if (!id) {
|
|
@@ -19221,6 +19397,9 @@
|
|
|
19221
19397
|
async click(id, action, options) {
|
|
19222
19398
|
await this.interop.invoke(this.NotificationsExecuteMethod, { command: "click", data: { id, action, options } });
|
|
19223
19399
|
}
|
|
19400
|
+
async snooze(id, duration) {
|
|
19401
|
+
await this.interop.invoke(this.NotificationsExecuteMethod, { command: "snooze", data: { id, duration } });
|
|
19402
|
+
}
|
|
19224
19403
|
async setState(id, state) {
|
|
19225
19404
|
if (!id) {
|
|
19226
19405
|
throw new Error("The 'id' argument cannot be null or undefined");
|
|
@@ -19256,6 +19435,7 @@
|
|
|
19256
19435
|
click: this.click.bind(this),
|
|
19257
19436
|
setState: this.setState.bind(this),
|
|
19258
19437
|
updateData: this.updateData.bind(this),
|
|
19438
|
+
snooze: this.snooze.bind(this)
|
|
19259
19439
|
};
|
|
19260
19440
|
}
|
|
19261
19441
|
onStreamEventCore(key, callback) {
|
|
@@ -19366,7 +19546,8 @@
|
|
|
19366
19546
|
this.interop
|
|
19367
19547
|
.subscribe(this.NotificationsSubscribeStream, {
|
|
19368
19548
|
arguments: {
|
|
19369
|
-
sendDeltaOnly: true
|
|
19549
|
+
sendDeltaOnly: true,
|
|
19550
|
+
statesVersion2: true
|
|
19370
19551
|
}
|
|
19371
19552
|
})
|
|
19372
19553
|
.then((sub) => {
|
|
@@ -20390,7 +20571,7 @@
|
|
|
20390
20571
|
this.intentsResolverResponsePromises[instanceId] = { intent, resolve, reject, promise, methodName: responseMethodName };
|
|
20391
20572
|
}
|
|
20392
20573
|
async invokeStartApp(application, context, options) {
|
|
20393
|
-
const result = await this.interop.invoke("T42.ACS.StartApplication", { Name: application, options });
|
|
20574
|
+
const result = await this.interop.invoke("T42.ACS.StartApplication", { Name: application, options: { ...options, startedByIntentAPI: true } });
|
|
20394
20575
|
return result.returned.Id;
|
|
20395
20576
|
}
|
|
20396
20577
|
subscribeOnInstanceStopped(instance, method) {
|
|
@@ -20919,7 +21100,7 @@
|
|
|
20919
21100
|
}
|
|
20920
21101
|
function createPrefs(core) {
|
|
20921
21102
|
var _a, _b;
|
|
20922
|
-
const appName = (_b = (_a = options.application) !== null && _a !== void 0 ? _a : glue42gd === null || glue42gd === void 0 ? void 0 : glue42gd.
|
|
21103
|
+
const appName = (_b = (_a = options.application) !== null && _a !== void 0 ? _a : glue42gd === null || glue42gd === void 0 ? void 0 : glue42gd.applicationName) !== null && _b !== void 0 ? _b : core.interop.instance.application;
|
|
20923
21104
|
const prefs = new Prefs(appName, core.interop);
|
|
20924
21105
|
debugLog(prefs);
|
|
20925
21106
|
return prefs;
|