@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.es.js
CHANGED
|
@@ -1315,6 +1315,7 @@ var WS = (function () {
|
|
|
1315
1315
|
return __generator(this, function (_b) {
|
|
1316
1316
|
switch (_b.label) {
|
|
1317
1317
|
case 0:
|
|
1318
|
+
this.logger.info("opening ws to ".concat(this.settings.ws, ", retryInterval: ").concat(retryInterval, ", retriesLeft: ").concat(retriesLeft, "..."));
|
|
1318
1319
|
this.startupTimer.mark("opening-socket");
|
|
1319
1320
|
if (retryInterval === undefined) {
|
|
1320
1321
|
retryInterval = this.settings.reconnectInterval;
|
|
@@ -1352,9 +1353,10 @@ var WS = (function () {
|
|
|
1352
1353
|
};
|
|
1353
1354
|
WS.prototype.initiateSocket = function () {
|
|
1354
1355
|
var _this = this;
|
|
1356
|
+
var _a;
|
|
1355
1357
|
var pw = new PromiseWrapper();
|
|
1356
1358
|
this.logger.debug("initiating ws to ".concat(this.settings.ws, "..."));
|
|
1357
|
-
this.ws = new WebSocketConstructor(this.settings.ws
|
|
1359
|
+
this.ws = new WebSocketConstructor((_a = this.settings.ws) !== null && _a !== void 0 ? _a : "");
|
|
1358
1360
|
this.ws.onerror = function (err) {
|
|
1359
1361
|
var reason = "";
|
|
1360
1362
|
try {
|
|
@@ -1373,11 +1375,12 @@ var WS = (function () {
|
|
|
1373
1375
|
};
|
|
1374
1376
|
reason = JSON.stringify(err, replacer);
|
|
1375
1377
|
}
|
|
1378
|
+
_this.logger.info("ws error - reason: ".concat(reason));
|
|
1376
1379
|
pw.reject("error");
|
|
1377
1380
|
_this.notifyStatusChanged(false, reason);
|
|
1378
1381
|
};
|
|
1379
1382
|
this.ws.onclose = function (err) {
|
|
1380
|
-
_this.logger.info("ws closed ".concat(err));
|
|
1383
|
+
_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));
|
|
1381
1384
|
pw.reject("closed");
|
|
1382
1385
|
_this.notifyStatusChanged(false);
|
|
1383
1386
|
};
|
|
@@ -1412,6 +1415,80 @@ var WS = (function () {
|
|
|
1412
1415
|
return WS;
|
|
1413
1416
|
}());
|
|
1414
1417
|
|
|
1418
|
+
var MessageReplayerImpl = (function () {
|
|
1419
|
+
function MessageReplayerImpl(specs) {
|
|
1420
|
+
this.specsNames = [];
|
|
1421
|
+
this.messages = {};
|
|
1422
|
+
this.subs = {};
|
|
1423
|
+
this.subsRefCount = {};
|
|
1424
|
+
this.specs = {};
|
|
1425
|
+
for (var _i = 0, specs_1 = specs; _i < specs_1.length; _i++) {
|
|
1426
|
+
var spec = specs_1[_i];
|
|
1427
|
+
this.specs[spec.name] = spec;
|
|
1428
|
+
this.specsNames.push(spec.name);
|
|
1429
|
+
}
|
|
1430
|
+
}
|
|
1431
|
+
MessageReplayerImpl.prototype.init = function (connection) {
|
|
1432
|
+
var _this = this;
|
|
1433
|
+
this.connection = connection;
|
|
1434
|
+
for (var _i = 0, _a = this.specsNames; _i < _a.length; _i++) {
|
|
1435
|
+
var name_1 = _a[_i];
|
|
1436
|
+
var _loop_1 = function (type) {
|
|
1437
|
+
var refCount = this_1.subsRefCount[type];
|
|
1438
|
+
if (!refCount) {
|
|
1439
|
+
refCount = 0;
|
|
1440
|
+
}
|
|
1441
|
+
refCount += 1;
|
|
1442
|
+
this_1.subsRefCount[type] = refCount;
|
|
1443
|
+
if (refCount > 1) {
|
|
1444
|
+
return "continue";
|
|
1445
|
+
}
|
|
1446
|
+
var sub = connection.on(type, function (msg) { return _this.processMessage(type, msg); });
|
|
1447
|
+
this_1.subs[type] = sub;
|
|
1448
|
+
};
|
|
1449
|
+
var this_1 = this;
|
|
1450
|
+
for (var _b = 0, _c = this.specs[name_1].types; _b < _c.length; _b++) {
|
|
1451
|
+
var type = _c[_b];
|
|
1452
|
+
_loop_1(type);
|
|
1453
|
+
}
|
|
1454
|
+
}
|
|
1455
|
+
};
|
|
1456
|
+
MessageReplayerImpl.prototype.processMessage = function (type, msg) {
|
|
1457
|
+
if (this.isDone || !msg) {
|
|
1458
|
+
return;
|
|
1459
|
+
}
|
|
1460
|
+
for (var _i = 0, _a = this.specsNames; _i < _a.length; _i++) {
|
|
1461
|
+
var name_2 = _a[_i];
|
|
1462
|
+
if (this.specs[name_2].types.indexOf(type) !== -1) {
|
|
1463
|
+
var messages = this.messages[name_2] || [];
|
|
1464
|
+
this.messages[name_2] = messages;
|
|
1465
|
+
messages.push(msg);
|
|
1466
|
+
}
|
|
1467
|
+
}
|
|
1468
|
+
};
|
|
1469
|
+
MessageReplayerImpl.prototype.drain = function (name, callback) {
|
|
1470
|
+
var _a;
|
|
1471
|
+
if (callback) {
|
|
1472
|
+
(this.messages[name] || []).forEach(callback);
|
|
1473
|
+
}
|
|
1474
|
+
delete this.messages[name];
|
|
1475
|
+
for (var _i = 0, _b = this.specs[name].types; _i < _b.length; _i++) {
|
|
1476
|
+
var type = _b[_i];
|
|
1477
|
+
this.subsRefCount[type] -= 1;
|
|
1478
|
+
if (this.subsRefCount[type] <= 0) {
|
|
1479
|
+
(_a = this.connection) === null || _a === void 0 ? void 0 : _a.off(this.subs[type]);
|
|
1480
|
+
delete this.subs[type];
|
|
1481
|
+
delete this.subsRefCount[type];
|
|
1482
|
+
}
|
|
1483
|
+
}
|
|
1484
|
+
delete this.specs[name];
|
|
1485
|
+
if (!this.specs.length) {
|
|
1486
|
+
this.isDone = true;
|
|
1487
|
+
}
|
|
1488
|
+
};
|
|
1489
|
+
return MessageReplayerImpl;
|
|
1490
|
+
}());
|
|
1491
|
+
|
|
1415
1492
|
var shortidExports = {};
|
|
1416
1493
|
var shortid$1 = {
|
|
1417
1494
|
get exports(){ return shortidExports; },
|
|
@@ -1760,743 +1837,127 @@ var isValid = isShortId;
|
|
|
1760
1837
|
|
|
1761
1838
|
var shortid = /*@__PURE__*/getDefaultExportFromCjs(shortidExports);
|
|
1762
1839
|
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
connection.on("result", function (msg) { return handleSuccessMessage(msg); });
|
|
1779
|
-
if (successMessages) {
|
|
1780
|
-
successMessages.forEach(function (sm) {
|
|
1781
|
-
connection.on(sm, function (msg) { return handleSuccessMessage(msg); });
|
|
1840
|
+
var PromisePlus$1 = function (executor, timeoutMilliseconds, timeoutMessage) {
|
|
1841
|
+
return new Promise(function (resolve, reject) {
|
|
1842
|
+
var timeout = setTimeout(function () {
|
|
1843
|
+
var message = timeoutMessage || "Promise timeout hit: ".concat(timeoutMilliseconds);
|
|
1844
|
+
reject(message);
|
|
1845
|
+
}, timeoutMilliseconds);
|
|
1846
|
+
var providedPromise = new Promise(executor);
|
|
1847
|
+
providedPromise
|
|
1848
|
+
.then(function (result) {
|
|
1849
|
+
clearTimeout(timeout);
|
|
1850
|
+
resolve(result);
|
|
1851
|
+
})
|
|
1852
|
+
.catch(function (error) {
|
|
1853
|
+
clearTimeout(timeout);
|
|
1854
|
+
reject(error);
|
|
1782
1855
|
});
|
|
1856
|
+
});
|
|
1857
|
+
};
|
|
1858
|
+
|
|
1859
|
+
var WebPlatformTransport = (function () {
|
|
1860
|
+
function WebPlatformTransport(settings, logger, identity) {
|
|
1861
|
+
this.settings = settings;
|
|
1862
|
+
this.logger = logger;
|
|
1863
|
+
this.identity = identity;
|
|
1864
|
+
this.iAmConnected = false;
|
|
1865
|
+
this.parentReady = false;
|
|
1866
|
+
this.rejected = false;
|
|
1867
|
+
this.children = [];
|
|
1868
|
+
this.extContentAvailable = false;
|
|
1869
|
+
this.extContentConnecting = false;
|
|
1870
|
+
this.extContentConnected = false;
|
|
1871
|
+
this.parentInExtMode = false;
|
|
1872
|
+
this.webNamespace = "g42_core_web";
|
|
1873
|
+
this.parentPingTimeout = 5000;
|
|
1874
|
+
this.connectionRequestTimeout = 7000;
|
|
1875
|
+
this.defaultTargetString = "*";
|
|
1876
|
+
this.registry = lib$1();
|
|
1877
|
+
this.messages = {
|
|
1878
|
+
connectionAccepted: { name: "connectionAccepted", handle: this.handleConnectionAccepted.bind(this) },
|
|
1879
|
+
connectionRejected: { name: "connectionRejected", handle: this.handleConnectionRejected.bind(this) },
|
|
1880
|
+
connectionRequest: { name: "connectionRequest", handle: this.handleConnectionRequest.bind(this) },
|
|
1881
|
+
parentReady: {
|
|
1882
|
+
name: "parentReady", handle: function () {
|
|
1883
|
+
}
|
|
1884
|
+
},
|
|
1885
|
+
parentPing: { name: "parentPing", handle: this.handleParentPing.bind(this) },
|
|
1886
|
+
platformPing: { name: "platformPing", handle: this.handlePlatformPing.bind(this) },
|
|
1887
|
+
platformReady: { name: "platformReady", handle: this.handlePlatformReady.bind(this) },
|
|
1888
|
+
clientUnload: { name: "clientUnload", handle: this.handleClientUnload.bind(this) },
|
|
1889
|
+
manualUnload: { name: "manualUnload", handle: this.handleManualUnload.bind(this) },
|
|
1890
|
+
extConnectionResponse: { name: "extConnectionResponse", handle: this.handleExtConnectionResponse.bind(this) },
|
|
1891
|
+
extSetupRequest: { name: "extSetupRequest", handle: this.handleExtSetupRequest.bind(this) },
|
|
1892
|
+
gatewayDisconnect: { name: "gatewayDisconnect", handle: this.handleGatewayDisconnect.bind(this) },
|
|
1893
|
+
gatewayInternalConnect: { name: "gatewayInternalConnect", handle: this.handleGatewayInternalConnect.bind(this) }
|
|
1894
|
+
};
|
|
1895
|
+
this.extContentAvailable = !!window.glue42ext;
|
|
1896
|
+
this.setUpMessageListener();
|
|
1897
|
+
this.setUpUnload();
|
|
1898
|
+
this.setupPlatformUnloadListener();
|
|
1899
|
+
this.parentType = window.name.includes("#wsp") ? "workspace" : undefined;
|
|
1783
1900
|
}
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1901
|
+
WebPlatformTransport.prototype.manualSetReadyState = function () {
|
|
1902
|
+
this.iAmConnected = true;
|
|
1903
|
+
this.parentReady = true;
|
|
1904
|
+
};
|
|
1905
|
+
Object.defineProperty(WebPlatformTransport.prototype, "transportWindowId", {
|
|
1906
|
+
get: function () {
|
|
1907
|
+
return this.publicWindowId;
|
|
1908
|
+
},
|
|
1909
|
+
enumerable: false,
|
|
1910
|
+
configurable: true
|
|
1911
|
+
});
|
|
1912
|
+
Object.defineProperty(WebPlatformTransport.prototype, "communicationId", {
|
|
1913
|
+
get: function () {
|
|
1914
|
+
return this._communicationId;
|
|
1915
|
+
},
|
|
1916
|
+
enumerable: false,
|
|
1917
|
+
configurable: true
|
|
1918
|
+
});
|
|
1919
|
+
WebPlatformTransport.prototype.sendObject = function (msg) {
|
|
1920
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1921
|
+
return __generator(this, function (_a) {
|
|
1922
|
+
if (this.extContentConnected) {
|
|
1923
|
+
return [2, window.postMessage({ glue42ExtOut: msg }, this.defaultTargetString)];
|
|
1924
|
+
}
|
|
1925
|
+
if (!this.port) {
|
|
1926
|
+
throw new Error("Cannot send message, because the port was not opened yet");
|
|
1927
|
+
}
|
|
1928
|
+
this.port.postMessage(msg);
|
|
1929
|
+
return [2];
|
|
1930
|
+
});
|
|
1787
1931
|
});
|
|
1788
|
-
}
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
logger.debug("error joining " + domain + " domain: " + JSON.stringify(err));
|
|
1818
|
-
reject(err);
|
|
1819
|
-
});
|
|
1820
|
-
});
|
|
1821
|
-
}
|
|
1822
|
-
function leave() {
|
|
1823
|
-
if (domain === "global") {
|
|
1824
|
-
return Promise.resolve();
|
|
1825
|
-
}
|
|
1826
|
-
logger.debug("stopping session " + domain + "...");
|
|
1827
|
-
var leaveMsg = {
|
|
1828
|
-
type: "leave",
|
|
1829
|
-
destination: domain,
|
|
1830
|
-
domain: "global",
|
|
1831
|
-
};
|
|
1832
|
-
tryReconnecting = false;
|
|
1833
|
-
return send(leaveMsg)
|
|
1834
|
-
.then(function () {
|
|
1835
|
-
isJoined = false;
|
|
1836
|
-
callbacks.execute("onLeft");
|
|
1837
|
-
})
|
|
1838
|
-
.catch(function () {
|
|
1839
|
-
isJoined = false;
|
|
1840
|
-
callbacks.execute("onLeft");
|
|
1841
|
-
});
|
|
1842
|
-
}
|
|
1843
|
-
function handleJoined() {
|
|
1844
|
-
logger.debug("did join " + domain);
|
|
1845
|
-
isJoined = true;
|
|
1846
|
-
var wasReconnect = tryReconnecting;
|
|
1847
|
-
tryReconnecting = false;
|
|
1848
|
-
callbacks.execute("onJoined", wasReconnect);
|
|
1849
|
-
}
|
|
1850
|
-
function handleConnectionDisconnected() {
|
|
1851
|
-
_connectionOn = false;
|
|
1852
|
-
logger.debug("connection is down");
|
|
1853
|
-
isJoined = false;
|
|
1854
|
-
tryReconnecting = true;
|
|
1855
|
-
callbacks.execute("onLeft", { disconnected: true });
|
|
1856
|
-
}
|
|
1857
|
-
function handleConnectionLoggedIn() {
|
|
1858
|
-
_connectionOn = true;
|
|
1859
|
-
if (tryReconnecting) {
|
|
1860
|
-
logger.debug("connection is now up - trying to reconnect...");
|
|
1861
|
-
join(_latestOptions);
|
|
1862
|
-
}
|
|
1863
|
-
}
|
|
1864
|
-
function onJoined(callback) {
|
|
1865
|
-
if (isJoined) {
|
|
1866
|
-
callback(false);
|
|
1867
|
-
}
|
|
1868
|
-
return callbacks.add("onJoined", callback);
|
|
1869
|
-
}
|
|
1870
|
-
function onLeft(callback) {
|
|
1871
|
-
if (!isJoined) {
|
|
1872
|
-
callback();
|
|
1873
|
-
}
|
|
1874
|
-
return callbacks.add("onLeft", callback);
|
|
1875
|
-
}
|
|
1876
|
-
function handleErrorMessage(msg) {
|
|
1877
|
-
if (domain !== msg.domain) {
|
|
1878
|
-
return;
|
|
1879
|
-
}
|
|
1880
|
-
var requestId = msg.request_id;
|
|
1881
|
-
if (!requestId) {
|
|
1882
|
-
return;
|
|
1883
|
-
}
|
|
1884
|
-
var entry = requestsMap[requestId];
|
|
1885
|
-
if (!entry) {
|
|
1886
|
-
return;
|
|
1887
|
-
}
|
|
1888
|
-
entry.error(msg);
|
|
1889
|
-
}
|
|
1890
|
-
function handleSuccessMessage(msg) {
|
|
1891
|
-
if (msg.domain !== domain) {
|
|
1892
|
-
return;
|
|
1893
|
-
}
|
|
1894
|
-
var requestId = msg.request_id;
|
|
1895
|
-
if (!requestId) {
|
|
1896
|
-
return;
|
|
1897
|
-
}
|
|
1898
|
-
var entry = requestsMap[requestId];
|
|
1899
|
-
if (!entry) {
|
|
1900
|
-
return;
|
|
1901
|
-
}
|
|
1902
|
-
entry.success(msg);
|
|
1903
|
-
}
|
|
1904
|
-
function getNextRequestId() {
|
|
1905
|
-
return shortid();
|
|
1906
|
-
}
|
|
1907
|
-
function send(msg, tag, options) {
|
|
1908
|
-
options = options || {};
|
|
1909
|
-
msg.request_id = msg.request_id || getNextRequestId();
|
|
1910
|
-
msg.domain = msg.domain || domain;
|
|
1911
|
-
if (!options.skipPeerId) {
|
|
1912
|
-
msg.peer_id = connection.peerId;
|
|
1913
|
-
}
|
|
1914
|
-
var requestId = msg.request_id;
|
|
1915
|
-
return new Promise(function (resolve, reject) {
|
|
1916
|
-
requestsMap[requestId] = {
|
|
1917
|
-
success: function (successMsg) {
|
|
1918
|
-
delete requestsMap[requestId];
|
|
1919
|
-
successMsg._tag = tag;
|
|
1920
|
-
resolve(successMsg);
|
|
1921
|
-
},
|
|
1922
|
-
error: function (errorMsg) {
|
|
1923
|
-
logger.warn("GW error - ".concat(JSON.stringify(errorMsg), " for request ").concat(JSON.stringify(msg)));
|
|
1924
|
-
delete requestsMap[requestId];
|
|
1925
|
-
errorMsg._tag = tag;
|
|
1926
|
-
reject(errorMsg);
|
|
1927
|
-
},
|
|
1928
|
-
};
|
|
1929
|
-
connection
|
|
1930
|
-
.send(msg, options)
|
|
1931
|
-
.catch(function (err) {
|
|
1932
|
-
requestsMap[requestId].error({ err: err });
|
|
1933
|
-
});
|
|
1934
|
-
});
|
|
1935
|
-
}
|
|
1936
|
-
function sendFireAndForget(msg) {
|
|
1937
|
-
msg.request_id = msg.request_id ? msg.request_id : getNextRequestId();
|
|
1938
|
-
msg.domain = msg.domain || domain;
|
|
1939
|
-
msg.peer_id = connection.peerId;
|
|
1940
|
-
return connection.send(msg);
|
|
1941
|
-
}
|
|
1942
|
-
return {
|
|
1943
|
-
join: join,
|
|
1944
|
-
leave: leave,
|
|
1945
|
-
onJoined: onJoined,
|
|
1946
|
-
onLeft: onLeft,
|
|
1947
|
-
send: send,
|
|
1948
|
-
sendFireAndForget: sendFireAndForget,
|
|
1949
|
-
on: function (type, callback) {
|
|
1950
|
-
connection.on(type, function (msg) {
|
|
1951
|
-
if (msg.domain !== domain) {
|
|
1952
|
-
return;
|
|
1953
|
-
}
|
|
1954
|
-
try {
|
|
1955
|
-
callback(msg);
|
|
1956
|
-
}
|
|
1957
|
-
catch (e) {
|
|
1958
|
-
logger.error("Callback failed: ".concat(e, " \n ").concat(e.stack, " \n msg was: ").concat(JSON.stringify(msg)), e);
|
|
1959
|
-
}
|
|
1960
|
-
});
|
|
1961
|
-
},
|
|
1962
|
-
loggedIn: function (callback) { return connection.loggedIn(callback); },
|
|
1963
|
-
connected: function (callback) { return connection.connected(callback); },
|
|
1964
|
-
disconnected: function (callback) { return connection.disconnected(callback); },
|
|
1965
|
-
get peerId() {
|
|
1966
|
-
return connection.peerId;
|
|
1967
|
-
},
|
|
1968
|
-
get domain() {
|
|
1969
|
-
return domain;
|
|
1970
|
-
},
|
|
1971
|
-
};
|
|
1972
|
-
}
|
|
1973
|
-
|
|
1974
|
-
var GW3ProtocolImpl = (function () {
|
|
1975
|
-
function GW3ProtocolImpl(connection, settings, logger) {
|
|
1976
|
-
var _this = this;
|
|
1977
|
-
this.connection = connection;
|
|
1978
|
-
this.settings = settings;
|
|
1979
|
-
this.logger = logger;
|
|
1980
|
-
this.protocolVersion = 3;
|
|
1981
|
-
this.datePrefix = "#T42_DATE#";
|
|
1982
|
-
this.datePrefixLen = this.datePrefix.length;
|
|
1983
|
-
this.dateMinLen = this.datePrefixLen + 1;
|
|
1984
|
-
this.datePrefixFirstChar = this.datePrefix[0];
|
|
1985
|
-
this.registry = lib$1();
|
|
1986
|
-
this._isLoggedIn = false;
|
|
1987
|
-
this.shouldTryLogin = true;
|
|
1988
|
-
this.initialLogin = true;
|
|
1989
|
-
this.initialLoginAttempts = 3;
|
|
1990
|
-
this.sessions = [];
|
|
1991
|
-
connection.disconnected(function () {
|
|
1992
|
-
_this.handleDisconnected();
|
|
1993
|
-
});
|
|
1994
|
-
this.ping();
|
|
1995
|
-
}
|
|
1996
|
-
Object.defineProperty(GW3ProtocolImpl.prototype, "isLoggedIn", {
|
|
1997
|
-
get: function () {
|
|
1998
|
-
return this._isLoggedIn;
|
|
1999
|
-
},
|
|
2000
|
-
enumerable: false,
|
|
2001
|
-
configurable: true
|
|
2002
|
-
});
|
|
2003
|
-
GW3ProtocolImpl.prototype.processStringMessage = function (message) {
|
|
2004
|
-
var _this = this;
|
|
2005
|
-
var msg = JSON.parse(message, function (key, value) {
|
|
2006
|
-
if (typeof value !== "string") {
|
|
2007
|
-
return value;
|
|
2008
|
-
}
|
|
2009
|
-
if (value.length < _this.dateMinLen) {
|
|
2010
|
-
return value;
|
|
2011
|
-
}
|
|
2012
|
-
if (value[0] !== _this.datePrefixFirstChar) {
|
|
2013
|
-
return value;
|
|
2014
|
-
}
|
|
2015
|
-
if (value.substring(0, _this.datePrefixLen) !== _this.datePrefix) {
|
|
2016
|
-
return value;
|
|
2017
|
-
}
|
|
2018
|
-
try {
|
|
2019
|
-
var milliseconds = parseInt(value.substring(_this.datePrefixLen, value.length), 10);
|
|
2020
|
-
if (isNaN(milliseconds)) {
|
|
2021
|
-
return value;
|
|
2022
|
-
}
|
|
2023
|
-
return new Date(milliseconds);
|
|
2024
|
-
}
|
|
2025
|
-
catch (ex) {
|
|
2026
|
-
return value;
|
|
2027
|
-
}
|
|
2028
|
-
});
|
|
2029
|
-
return {
|
|
2030
|
-
msg: msg,
|
|
2031
|
-
msgType: msg.type,
|
|
2032
|
-
};
|
|
2033
|
-
};
|
|
2034
|
-
GW3ProtocolImpl.prototype.createStringMessage = function (message) {
|
|
2035
|
-
var oldToJson = Date.prototype.toJSON;
|
|
2036
|
-
try {
|
|
2037
|
-
var datePrefix_1 = this.datePrefix;
|
|
2038
|
-
Date.prototype.toJSON = function () {
|
|
2039
|
-
return datePrefix_1 + this.getTime();
|
|
2040
|
-
};
|
|
2041
|
-
var result = JSON.stringify(message);
|
|
2042
|
-
return result;
|
|
2043
|
-
}
|
|
2044
|
-
finally {
|
|
2045
|
-
Date.prototype.toJSON = oldToJson;
|
|
2046
|
-
}
|
|
2047
|
-
};
|
|
2048
|
-
GW3ProtocolImpl.prototype.processObjectMessage = function (message) {
|
|
2049
|
-
if (!message.type) {
|
|
2050
|
-
throw new Error("Object should have type property");
|
|
2051
|
-
}
|
|
2052
|
-
return {
|
|
2053
|
-
msg: message,
|
|
2054
|
-
msgType: message.type,
|
|
2055
|
-
};
|
|
2056
|
-
};
|
|
2057
|
-
GW3ProtocolImpl.prototype.createObjectMessage = function (message) {
|
|
2058
|
-
return message;
|
|
2059
|
-
};
|
|
2060
|
-
GW3ProtocolImpl.prototype.login = function (config, reconnect) {
|
|
2061
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
2062
|
-
var authentication, token, e_1, _a, helloMsg, sendOptions, welcomeMsg, msg, token, _b, err_1;
|
|
2063
|
-
return __generator(this, function (_c) {
|
|
2064
|
-
switch (_c.label) {
|
|
2065
|
-
case 0:
|
|
2066
|
-
this.logger.debug("logging in...");
|
|
2067
|
-
this.loginConfig = config;
|
|
2068
|
-
if (!this.loginConfig) {
|
|
2069
|
-
this.loginConfig = { username: "", password: "" };
|
|
2070
|
-
}
|
|
2071
|
-
this.shouldTryLogin = true;
|
|
2072
|
-
authentication = {};
|
|
2073
|
-
this.connection.gatewayToken = config.gatewayToken;
|
|
2074
|
-
if (!config.gatewayToken) return [3, 5];
|
|
2075
|
-
if (!reconnect) return [3, 4];
|
|
2076
|
-
_c.label = 1;
|
|
2077
|
-
case 1:
|
|
2078
|
-
_c.trys.push([1, 3, , 4]);
|
|
2079
|
-
return [4, this.getNewGWToken()];
|
|
2080
|
-
case 2:
|
|
2081
|
-
token = _c.sent();
|
|
2082
|
-
config.gatewayToken = token;
|
|
2083
|
-
return [3, 4];
|
|
2084
|
-
case 3:
|
|
2085
|
-
e_1 = _c.sent();
|
|
2086
|
-
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));
|
|
2087
|
-
return [3, 4];
|
|
2088
|
-
case 4:
|
|
2089
|
-
authentication.method = "gateway-token";
|
|
2090
|
-
authentication.token = config.gatewayToken;
|
|
2091
|
-
this.connection.gatewayToken = config.gatewayToken;
|
|
2092
|
-
return [3, 10];
|
|
2093
|
-
case 5:
|
|
2094
|
-
if (!(config.flowName === "sspi")) return [3, 9];
|
|
2095
|
-
authentication.provider = "win";
|
|
2096
|
-
authentication.method = "access-token";
|
|
2097
|
-
if (!(config.flowCallback && config.sessionId)) return [3, 7];
|
|
2098
|
-
_a = authentication;
|
|
2099
|
-
return [4, config.flowCallback(config.sessionId, null)];
|
|
2100
|
-
case 6:
|
|
2101
|
-
_a.token =
|
|
2102
|
-
(_c.sent())
|
|
2103
|
-
.data
|
|
2104
|
-
.toString("base64");
|
|
2105
|
-
return [3, 8];
|
|
2106
|
-
case 7: throw new Error("Invalid SSPI config");
|
|
2107
|
-
case 8: return [3, 10];
|
|
2108
|
-
case 9:
|
|
2109
|
-
if (config.token) {
|
|
2110
|
-
authentication.method = "access-token";
|
|
2111
|
-
authentication.token = config.token;
|
|
2112
|
-
}
|
|
2113
|
-
else if (config.username) {
|
|
2114
|
-
authentication.method = "secret";
|
|
2115
|
-
authentication.login = config.username;
|
|
2116
|
-
authentication.secret = config.password;
|
|
2117
|
-
}
|
|
2118
|
-
else if (config.provider) {
|
|
2119
|
-
authentication.provider = config.provider;
|
|
2120
|
-
authentication.providerContext = config.providerContext;
|
|
2121
|
-
}
|
|
2122
|
-
else {
|
|
2123
|
-
throw new Error("invalid auth message" + JSON.stringify(config));
|
|
2124
|
-
}
|
|
2125
|
-
_c.label = 10;
|
|
2126
|
-
case 10:
|
|
2127
|
-
helloMsg = {
|
|
2128
|
-
type: "hello",
|
|
2129
|
-
identity: this.settings.identity,
|
|
2130
|
-
authentication: authentication
|
|
2131
|
-
};
|
|
2132
|
-
if (config.sessionId) {
|
|
2133
|
-
helloMsg.request_id = config.sessionId;
|
|
2134
|
-
}
|
|
2135
|
-
this.globalDomain = domainSession("global", this.connection, this.logger.subLogger("global-domain"), [
|
|
2136
|
-
"welcome",
|
|
2137
|
-
"token",
|
|
2138
|
-
"authentication-request"
|
|
2139
|
-
]);
|
|
2140
|
-
sendOptions = { skipPeerId: true };
|
|
2141
|
-
if (this.initialLogin) {
|
|
2142
|
-
sendOptions.retryInterval = this.settings.reconnectInterval;
|
|
2143
|
-
sendOptions.maxRetries = this.settings.reconnectAttempts;
|
|
2144
|
-
}
|
|
2145
|
-
_c.label = 11;
|
|
2146
|
-
case 11:
|
|
2147
|
-
_c.trys.push([11, 19, 20, 21]);
|
|
2148
|
-
welcomeMsg = void 0;
|
|
2149
|
-
_c.label = 12;
|
|
2150
|
-
case 12:
|
|
2151
|
-
return [4, this.globalDomain.send(helloMsg, undefined, sendOptions)];
|
|
2152
|
-
case 13:
|
|
2153
|
-
msg = _c.sent();
|
|
2154
|
-
if (!(msg.type === "authentication-request")) return [3, 16];
|
|
2155
|
-
token = Buffer.from(msg.authentication.token, "base64");
|
|
2156
|
-
if (!(config.flowCallback && config.sessionId)) return [3, 15];
|
|
2157
|
-
_b = helloMsg.authentication;
|
|
2158
|
-
return [4, config.flowCallback(config.sessionId, token)];
|
|
2159
|
-
case 14:
|
|
2160
|
-
_b.token =
|
|
2161
|
-
(_c.sent())
|
|
2162
|
-
.data
|
|
2163
|
-
.toString("base64");
|
|
2164
|
-
_c.label = 15;
|
|
2165
|
-
case 15:
|
|
2166
|
-
helloMsg.request_id = config.sessionId;
|
|
2167
|
-
return [3, 12];
|
|
2168
|
-
case 16:
|
|
2169
|
-
if (msg.type === "welcome") {
|
|
2170
|
-
welcomeMsg = msg;
|
|
2171
|
-
return [3, 18];
|
|
2172
|
-
}
|
|
2173
|
-
else if (msg.type === "error") {
|
|
2174
|
-
throw new Error("Authentication failed: " + msg.reason);
|
|
2175
|
-
}
|
|
2176
|
-
else {
|
|
2177
|
-
throw new Error("Unexpected message type during authentication: " + msg.type);
|
|
2178
|
-
}
|
|
2179
|
-
case 17: return [3, 12];
|
|
2180
|
-
case 18:
|
|
2181
|
-
this.initialLogin = false;
|
|
2182
|
-
this.logger.debug("login successful with peerId " + welcomeMsg.peer_id);
|
|
2183
|
-
this.connection.peerId = welcomeMsg.peer_id;
|
|
2184
|
-
this.connection.resolvedIdentity = welcomeMsg.resolved_identity;
|
|
2185
|
-
this.connection.availableDomains = welcomeMsg.available_domains;
|
|
2186
|
-
if (welcomeMsg.options) {
|
|
2187
|
-
this.connection.token = welcomeMsg.options.access_token;
|
|
2188
|
-
this.connection.info = welcomeMsg.options.info;
|
|
2189
|
-
}
|
|
2190
|
-
this.setLoggedIn(true);
|
|
2191
|
-
return [2, welcomeMsg.resolved_identity];
|
|
2192
|
-
case 19:
|
|
2193
|
-
err_1 = _c.sent();
|
|
2194
|
-
this.logger.error("error sending hello message - " + (err_1.message || err_1.msg || err_1.reason || err_1), err_1);
|
|
2195
|
-
throw err_1;
|
|
2196
|
-
case 20:
|
|
2197
|
-
if (config && config.flowCallback && config.sessionId) {
|
|
2198
|
-
config.flowCallback(config.sessionId, null);
|
|
2199
|
-
}
|
|
2200
|
-
return [7];
|
|
2201
|
-
case 21: return [2];
|
|
2202
|
-
}
|
|
2203
|
-
});
|
|
2204
|
-
});
|
|
2205
|
-
};
|
|
2206
|
-
GW3ProtocolImpl.prototype.logout = function () {
|
|
2207
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
2208
|
-
var promises;
|
|
2209
|
-
return __generator(this, function (_a) {
|
|
2210
|
-
switch (_a.label) {
|
|
2211
|
-
case 0:
|
|
2212
|
-
this.logger.debug("logging out...");
|
|
2213
|
-
this.shouldTryLogin = false;
|
|
2214
|
-
if (this.pingTimer) {
|
|
2215
|
-
clearTimeout(this.pingTimer);
|
|
2216
|
-
}
|
|
2217
|
-
promises = this.sessions.map(function (session) {
|
|
2218
|
-
session.leave();
|
|
2219
|
-
});
|
|
2220
|
-
return [4, Promise.all(promises)];
|
|
2221
|
-
case 1:
|
|
2222
|
-
_a.sent();
|
|
2223
|
-
return [2];
|
|
2224
|
-
}
|
|
2225
|
-
});
|
|
2226
|
-
});
|
|
2227
|
-
};
|
|
2228
|
-
GW3ProtocolImpl.prototype.loggedIn = function (callback) {
|
|
2229
|
-
if (this._isLoggedIn) {
|
|
2230
|
-
callback();
|
|
2231
|
-
}
|
|
2232
|
-
return this.registry.add("onLoggedIn", callback);
|
|
2233
|
-
};
|
|
2234
|
-
GW3ProtocolImpl.prototype.domain = function (domainName, domainLogger, successMessages, errorMessages) {
|
|
2235
|
-
var session = this.sessions.filter(function (s) { return s.domain === domainName; })[0];
|
|
2236
|
-
if (!session) {
|
|
2237
|
-
session = domainSession(domainName, this.connection, domainLogger, successMessages, errorMessages);
|
|
2238
|
-
this.sessions.push(session);
|
|
2239
|
-
}
|
|
2240
|
-
return session;
|
|
2241
|
-
};
|
|
2242
|
-
GW3ProtocolImpl.prototype.handleDisconnected = function () {
|
|
2243
|
-
var _this = this;
|
|
2244
|
-
this.setLoggedIn(false);
|
|
2245
|
-
var tryToLogin = this.shouldTryLogin;
|
|
2246
|
-
if (tryToLogin && this.initialLogin) {
|
|
2247
|
-
if (this.initialLoginAttempts <= 0) {
|
|
2248
|
-
return;
|
|
2249
|
-
}
|
|
2250
|
-
this.initialLoginAttempts--;
|
|
2251
|
-
}
|
|
2252
|
-
this.logger.debug("disconnected - will try new login?" + this.shouldTryLogin);
|
|
2253
|
-
if (this.shouldTryLogin) {
|
|
2254
|
-
if (!this.loginConfig) {
|
|
2255
|
-
throw new Error("no login info");
|
|
2256
|
-
}
|
|
2257
|
-
this.connection.login(this.loginConfig, true)
|
|
2258
|
-
.catch(function () {
|
|
2259
|
-
setTimeout(_this.handleDisconnected.bind(_this), _this.settings.reconnectInterval || 1000);
|
|
2260
|
-
});
|
|
2261
|
-
}
|
|
2262
|
-
};
|
|
2263
|
-
GW3ProtocolImpl.prototype.setLoggedIn = function (value) {
|
|
2264
|
-
this._isLoggedIn = value;
|
|
2265
|
-
if (this._isLoggedIn) {
|
|
2266
|
-
this.registry.execute("onLoggedIn");
|
|
2267
|
-
}
|
|
2268
|
-
};
|
|
2269
|
-
GW3ProtocolImpl.prototype.ping = function () {
|
|
2270
|
-
var _this = this;
|
|
2271
|
-
if (!this.shouldTryLogin) {
|
|
2272
|
-
return;
|
|
2273
|
-
}
|
|
2274
|
-
if (this._isLoggedIn) {
|
|
2275
|
-
this.connection.send({ type: "ping" });
|
|
2276
|
-
}
|
|
2277
|
-
this.pingTimer = setTimeout(function () {
|
|
2278
|
-
_this.ping();
|
|
2279
|
-
}, 30 * 1000);
|
|
2280
|
-
};
|
|
2281
|
-
GW3ProtocolImpl.prototype.authToken = function () {
|
|
2282
|
-
var createTokenReq = {
|
|
2283
|
-
type: "create-token"
|
|
2284
|
-
};
|
|
2285
|
-
if (!this.globalDomain) {
|
|
2286
|
-
return Promise.reject(new Error("no global domain session"));
|
|
2287
|
-
}
|
|
2288
|
-
return this.globalDomain.send(createTokenReq)
|
|
2289
|
-
.then(function (res) {
|
|
2290
|
-
return res.token;
|
|
2291
|
-
});
|
|
2292
|
-
};
|
|
2293
|
-
GW3ProtocolImpl.prototype.getNewGWToken = function () {
|
|
2294
|
-
if (typeof window !== undefined) {
|
|
2295
|
-
var glue42gd = window.glue42gd;
|
|
2296
|
-
if (glue42gd) {
|
|
2297
|
-
return glue42gd.getGWToken();
|
|
2298
|
-
}
|
|
2299
|
-
}
|
|
2300
|
-
return Promise.reject(new Error("not running in GD"));
|
|
2301
|
-
};
|
|
2302
|
-
return GW3ProtocolImpl;
|
|
2303
|
-
}());
|
|
2304
|
-
|
|
2305
|
-
var MessageReplayerImpl = (function () {
|
|
2306
|
-
function MessageReplayerImpl(specs) {
|
|
2307
|
-
this.specsNames = [];
|
|
2308
|
-
this.messages = {};
|
|
2309
|
-
this.subs = {};
|
|
2310
|
-
this.subsRefCount = {};
|
|
2311
|
-
this.specs = {};
|
|
2312
|
-
for (var _i = 0, specs_1 = specs; _i < specs_1.length; _i++) {
|
|
2313
|
-
var spec = specs_1[_i];
|
|
2314
|
-
this.specs[spec.name] = spec;
|
|
2315
|
-
this.specsNames.push(spec.name);
|
|
2316
|
-
}
|
|
2317
|
-
}
|
|
2318
|
-
MessageReplayerImpl.prototype.init = function (connection) {
|
|
2319
|
-
var _this = this;
|
|
2320
|
-
this.connection = connection;
|
|
2321
|
-
for (var _i = 0, _a = this.specsNames; _i < _a.length; _i++) {
|
|
2322
|
-
var name_1 = _a[_i];
|
|
2323
|
-
var _loop_1 = function (type) {
|
|
2324
|
-
var refCount = this_1.subsRefCount[type];
|
|
2325
|
-
if (!refCount) {
|
|
2326
|
-
refCount = 0;
|
|
2327
|
-
}
|
|
2328
|
-
refCount += 1;
|
|
2329
|
-
this_1.subsRefCount[type] = refCount;
|
|
2330
|
-
if (refCount > 1) {
|
|
2331
|
-
return "continue";
|
|
2332
|
-
}
|
|
2333
|
-
var sub = connection.on(type, function (msg) { return _this.processMessage(type, msg); });
|
|
2334
|
-
this_1.subs[type] = sub;
|
|
2335
|
-
};
|
|
2336
|
-
var this_1 = this;
|
|
2337
|
-
for (var _b = 0, _c = this.specs[name_1].types; _b < _c.length; _b++) {
|
|
2338
|
-
var type = _c[_b];
|
|
2339
|
-
_loop_1(type);
|
|
2340
|
-
}
|
|
2341
|
-
}
|
|
2342
|
-
};
|
|
2343
|
-
MessageReplayerImpl.prototype.processMessage = function (type, msg) {
|
|
2344
|
-
if (this.isDone || !msg) {
|
|
2345
|
-
return;
|
|
2346
|
-
}
|
|
2347
|
-
for (var _i = 0, _a = this.specsNames; _i < _a.length; _i++) {
|
|
2348
|
-
var name_2 = _a[_i];
|
|
2349
|
-
if (this.specs[name_2].types.indexOf(type) !== -1) {
|
|
2350
|
-
var messages = this.messages[name_2] || [];
|
|
2351
|
-
this.messages[name_2] = messages;
|
|
2352
|
-
messages.push(msg);
|
|
2353
|
-
}
|
|
2354
|
-
}
|
|
2355
|
-
};
|
|
2356
|
-
MessageReplayerImpl.prototype.drain = function (name, callback) {
|
|
2357
|
-
var _a;
|
|
2358
|
-
if (callback) {
|
|
2359
|
-
(this.messages[name] || []).forEach(callback);
|
|
2360
|
-
}
|
|
2361
|
-
delete this.messages[name];
|
|
2362
|
-
for (var _i = 0, _b = this.specs[name].types; _i < _b.length; _i++) {
|
|
2363
|
-
var type = _b[_i];
|
|
2364
|
-
this.subsRefCount[type] -= 1;
|
|
2365
|
-
if (this.subsRefCount[type] <= 0) {
|
|
2366
|
-
(_a = this.connection) === null || _a === void 0 ? void 0 : _a.off(this.subs[type]);
|
|
2367
|
-
delete this.subs[type];
|
|
2368
|
-
delete this.subsRefCount[type];
|
|
2369
|
-
}
|
|
2370
|
-
}
|
|
2371
|
-
delete this.specs[name];
|
|
2372
|
-
if (!this.specs.length) {
|
|
2373
|
-
this.isDone = true;
|
|
2374
|
-
}
|
|
2375
|
-
};
|
|
2376
|
-
return MessageReplayerImpl;
|
|
2377
|
-
}());
|
|
2378
|
-
|
|
2379
|
-
var PromisePlus$1 = function (executor, timeoutMilliseconds, timeoutMessage) {
|
|
2380
|
-
return new Promise(function (resolve, reject) {
|
|
2381
|
-
var timeout = setTimeout(function () {
|
|
2382
|
-
var message = timeoutMessage || "Promise timeout hit: ".concat(timeoutMilliseconds);
|
|
2383
|
-
reject(message);
|
|
2384
|
-
}, timeoutMilliseconds);
|
|
2385
|
-
var providedPromise = new Promise(executor);
|
|
2386
|
-
providedPromise
|
|
2387
|
-
.then(function (result) {
|
|
2388
|
-
clearTimeout(timeout);
|
|
2389
|
-
resolve(result);
|
|
2390
|
-
})
|
|
2391
|
-
.catch(function (error) {
|
|
2392
|
-
clearTimeout(timeout);
|
|
2393
|
-
reject(error);
|
|
2394
|
-
});
|
|
2395
|
-
});
|
|
2396
|
-
};
|
|
2397
|
-
|
|
2398
|
-
var WebPlatformTransport = (function () {
|
|
2399
|
-
function WebPlatformTransport(settings, logger, identity) {
|
|
2400
|
-
this.settings = settings;
|
|
2401
|
-
this.logger = logger;
|
|
2402
|
-
this.identity = identity;
|
|
2403
|
-
this.iAmConnected = false;
|
|
2404
|
-
this.parentReady = false;
|
|
2405
|
-
this.rejected = false;
|
|
2406
|
-
this.children = [];
|
|
2407
|
-
this.extContentAvailable = false;
|
|
2408
|
-
this.extContentConnecting = false;
|
|
2409
|
-
this.extContentConnected = false;
|
|
2410
|
-
this.parentInExtMode = false;
|
|
2411
|
-
this.webNamespace = "g42_core_web";
|
|
2412
|
-
this.parentPingTimeout = 5000;
|
|
2413
|
-
this.connectionRequestTimeout = 7000;
|
|
2414
|
-
this.defaultTargetString = "*";
|
|
2415
|
-
this.registry = lib$1();
|
|
2416
|
-
this.messages = {
|
|
2417
|
-
connectionAccepted: { name: "connectionAccepted", handle: this.handleConnectionAccepted.bind(this) },
|
|
2418
|
-
connectionRejected: { name: "connectionRejected", handle: this.handleConnectionRejected.bind(this) },
|
|
2419
|
-
connectionRequest: { name: "connectionRequest", handle: this.handleConnectionRequest.bind(this) },
|
|
2420
|
-
parentReady: {
|
|
2421
|
-
name: "parentReady", handle: function () {
|
|
2422
|
-
}
|
|
2423
|
-
},
|
|
2424
|
-
parentPing: { name: "parentPing", handle: this.handleParentPing.bind(this) },
|
|
2425
|
-
platformPing: { name: "platformPing", handle: this.handlePlatformPing.bind(this) },
|
|
2426
|
-
platformReady: { name: "platformReady", handle: this.handlePlatformReady.bind(this) },
|
|
2427
|
-
clientUnload: { name: "clientUnload", handle: this.handleClientUnload.bind(this) },
|
|
2428
|
-
manualUnload: { name: "manualUnload", handle: this.handleManualUnload.bind(this) },
|
|
2429
|
-
extConnectionResponse: { name: "extConnectionResponse", handle: this.handleExtConnectionResponse.bind(this) },
|
|
2430
|
-
extSetupRequest: { name: "extSetupRequest", handle: this.handleExtSetupRequest.bind(this) },
|
|
2431
|
-
gatewayDisconnect: { name: "gatewayDisconnect", handle: this.handleGatewayDisconnect.bind(this) },
|
|
2432
|
-
gatewayInternalConnect: { name: "gatewayInternalConnect", handle: this.handleGatewayInternalConnect.bind(this) }
|
|
2433
|
-
};
|
|
2434
|
-
this.extContentAvailable = !!window.glue42ext;
|
|
2435
|
-
this.setUpMessageListener();
|
|
2436
|
-
this.setUpUnload();
|
|
2437
|
-
this.setupPlatformUnloadListener();
|
|
2438
|
-
this.parentType = window.name.includes("#wsp") ? "workspace" : undefined;
|
|
2439
|
-
}
|
|
2440
|
-
WebPlatformTransport.prototype.manualSetReadyState = function () {
|
|
2441
|
-
this.iAmConnected = true;
|
|
2442
|
-
this.parentReady = true;
|
|
2443
|
-
};
|
|
2444
|
-
Object.defineProperty(WebPlatformTransport.prototype, "transportWindowId", {
|
|
2445
|
-
get: function () {
|
|
2446
|
-
return this.publicWindowId;
|
|
2447
|
-
},
|
|
2448
|
-
enumerable: false,
|
|
2449
|
-
configurable: true
|
|
2450
|
-
});
|
|
2451
|
-
Object.defineProperty(WebPlatformTransport.prototype, "communicationId", {
|
|
2452
|
-
get: function () {
|
|
2453
|
-
return this._communicationId;
|
|
2454
|
-
},
|
|
2455
|
-
enumerable: false,
|
|
2456
|
-
configurable: true
|
|
2457
|
-
});
|
|
2458
|
-
WebPlatformTransport.prototype.sendObject = function (msg) {
|
|
2459
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
2460
|
-
return __generator(this, function (_a) {
|
|
2461
|
-
if (this.extContentConnected) {
|
|
2462
|
-
return [2, window.postMessage({ glue42ExtOut: msg }, this.defaultTargetString)];
|
|
2463
|
-
}
|
|
2464
|
-
if (!this.port) {
|
|
2465
|
-
throw new Error("Cannot send message, because the port was not opened yet");
|
|
2466
|
-
}
|
|
2467
|
-
this.port.postMessage(msg);
|
|
2468
|
-
return [2];
|
|
2469
|
-
});
|
|
2470
|
-
});
|
|
2471
|
-
};
|
|
2472
|
-
Object.defineProperty(WebPlatformTransport.prototype, "isObjectBasedTransport", {
|
|
2473
|
-
get: function () {
|
|
2474
|
-
return true;
|
|
2475
|
-
},
|
|
2476
|
-
enumerable: false,
|
|
2477
|
-
configurable: true
|
|
2478
|
-
});
|
|
2479
|
-
WebPlatformTransport.prototype.onMessage = function (callback) {
|
|
2480
|
-
return this.registry.add("onMessage", callback);
|
|
2481
|
-
};
|
|
2482
|
-
WebPlatformTransport.prototype.send = function () {
|
|
2483
|
-
return Promise.reject("not supported");
|
|
2484
|
-
};
|
|
2485
|
-
WebPlatformTransport.prototype.onConnectedChanged = function (callback) {
|
|
2486
|
-
return this.registry.add("onConnectedChanged", callback);
|
|
2487
|
-
};
|
|
2488
|
-
WebPlatformTransport.prototype.open = function () {
|
|
2489
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
2490
|
-
return __generator(this, function (_a) {
|
|
2491
|
-
switch (_a.label) {
|
|
2492
|
-
case 0:
|
|
2493
|
-
this.logger.debug("opening a connection to the web platform gateway.");
|
|
2494
|
-
return [4, this.connect()];
|
|
2495
|
-
case 1:
|
|
2496
|
-
_a.sent();
|
|
2497
|
-
this.notifyStatusChanged(true);
|
|
2498
|
-
return [2];
|
|
2499
|
-
}
|
|
1932
|
+
};
|
|
1933
|
+
Object.defineProperty(WebPlatformTransport.prototype, "isObjectBasedTransport", {
|
|
1934
|
+
get: function () {
|
|
1935
|
+
return true;
|
|
1936
|
+
},
|
|
1937
|
+
enumerable: false,
|
|
1938
|
+
configurable: true
|
|
1939
|
+
});
|
|
1940
|
+
WebPlatformTransport.prototype.onMessage = function (callback) {
|
|
1941
|
+
return this.registry.add("onMessage", callback);
|
|
1942
|
+
};
|
|
1943
|
+
WebPlatformTransport.prototype.send = function () {
|
|
1944
|
+
return Promise.reject("not supported");
|
|
1945
|
+
};
|
|
1946
|
+
WebPlatformTransport.prototype.onConnectedChanged = function (callback) {
|
|
1947
|
+
return this.registry.add("onConnectedChanged", callback);
|
|
1948
|
+
};
|
|
1949
|
+
WebPlatformTransport.prototype.open = function () {
|
|
1950
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1951
|
+
return __generator(this, function (_a) {
|
|
1952
|
+
switch (_a.label) {
|
|
1953
|
+
case 0:
|
|
1954
|
+
this.logger.debug("opening a connection to the web platform gateway.");
|
|
1955
|
+
return [4, this.connect()];
|
|
1956
|
+
case 1:
|
|
1957
|
+
_a.sent();
|
|
1958
|
+
this.notifyStatusChanged(true);
|
|
1959
|
+
return [2];
|
|
1960
|
+
}
|
|
2500
1961
|
});
|
|
2501
1962
|
});
|
|
2502
1963
|
};
|
|
@@ -2629,6 +2090,11 @@ var WebPlatformTransport = (function () {
|
|
|
2629
2090
|
if (!data || _this.rejected) {
|
|
2630
2091
|
return;
|
|
2631
2092
|
}
|
|
2093
|
+
var allowedOrigins = _this.settings.allowedOrigins || [];
|
|
2094
|
+
if (allowedOrigins.length && !allowedOrigins.includes(event.origin)) {
|
|
2095
|
+
_this.logger.warn("received a message from an origin which is not in the allowed list: ".concat(event.origin));
|
|
2096
|
+
return;
|
|
2097
|
+
}
|
|
2632
2098
|
if (!_this.checkMessageTypeValid(data.type)) {
|
|
2633
2099
|
_this.logger.error("cannot handle the incoming glue42 core message, because the type is invalid: ".concat(data.type));
|
|
2634
2100
|
return;
|
|
@@ -2736,6 +2202,11 @@ var WebPlatformTransport = (function () {
|
|
|
2736
2202
|
if (!extData) {
|
|
2737
2203
|
return;
|
|
2738
2204
|
}
|
|
2205
|
+
var allowedOrigins = _this.settings.allowedOrigins || [];
|
|
2206
|
+
if (allowedOrigins.length && !allowedOrigins.includes(event.origin)) {
|
|
2207
|
+
_this.logger.warn("received a message from an origin which is not in the allowed list: ".concat(event.origin));
|
|
2208
|
+
return;
|
|
2209
|
+
}
|
|
2739
2210
|
_this.registry.execute("onMessage", extData);
|
|
2740
2211
|
});
|
|
2741
2212
|
if (this.connectionResolve) {
|
|
@@ -3100,13 +2571,250 @@ var AsyncSequelizer = (function () {
|
|
|
3100
2571
|
var _this = this;
|
|
3101
2572
|
return new Promise(function (res) { return setTimeout(res, _this.minSequenceInterval); });
|
|
3102
2573
|
};
|
|
3103
|
-
return AsyncSequelizer;
|
|
3104
|
-
}());
|
|
2574
|
+
return AsyncSequelizer;
|
|
2575
|
+
}());
|
|
2576
|
+
|
|
2577
|
+
function domainSession (domain, connection, logger, successMessages, errorMessages) {
|
|
2578
|
+
if (domain == null) {
|
|
2579
|
+
domain = "global";
|
|
2580
|
+
}
|
|
2581
|
+
successMessages = successMessages !== null && successMessages !== void 0 ? successMessages : ["success"];
|
|
2582
|
+
errorMessages = errorMessages !== null && errorMessages !== void 0 ? errorMessages : ["error"];
|
|
2583
|
+
var isJoined = domain === "global";
|
|
2584
|
+
var tryReconnecting = false;
|
|
2585
|
+
var _latestOptions;
|
|
2586
|
+
var _connectionOn = false;
|
|
2587
|
+
var callbacks = lib$1();
|
|
2588
|
+
connection.disconnected(handleConnectionDisconnected);
|
|
2589
|
+
connection.loggedIn(handleConnectionLoggedIn);
|
|
2590
|
+
connection.on("success", function (msg) { return handleSuccessMessage(msg); });
|
|
2591
|
+
connection.on("error", function (msg) { return handleErrorMessage(msg); });
|
|
2592
|
+
connection.on("result", function (msg) { return handleSuccessMessage(msg); });
|
|
2593
|
+
if (successMessages) {
|
|
2594
|
+
successMessages.forEach(function (sm) {
|
|
2595
|
+
connection.on(sm, function (msg) { return handleSuccessMessage(msg); });
|
|
2596
|
+
});
|
|
2597
|
+
}
|
|
2598
|
+
if (errorMessages) {
|
|
2599
|
+
errorMessages.forEach(function (sm) {
|
|
2600
|
+
connection.on(sm, function (msg) { return handleErrorMessage(msg); });
|
|
2601
|
+
});
|
|
2602
|
+
}
|
|
2603
|
+
var requestsMap = {};
|
|
2604
|
+
function join(options) {
|
|
2605
|
+
_latestOptions = options;
|
|
2606
|
+
return new Promise(function (resolve, reject) {
|
|
2607
|
+
if (isJoined) {
|
|
2608
|
+
resolve({});
|
|
2609
|
+
return;
|
|
2610
|
+
}
|
|
2611
|
+
var joinPromise;
|
|
2612
|
+
if (domain === "global") {
|
|
2613
|
+
joinPromise = _connectionOn ? Promise.resolve({}) : Promise.reject("not connected to gateway");
|
|
2614
|
+
}
|
|
2615
|
+
else {
|
|
2616
|
+
logger.debug("joining domain ".concat(domain));
|
|
2617
|
+
var joinMsg = {
|
|
2618
|
+
type: "join",
|
|
2619
|
+
destination: domain,
|
|
2620
|
+
domain: "global",
|
|
2621
|
+
options: options,
|
|
2622
|
+
};
|
|
2623
|
+
joinPromise = send(joinMsg);
|
|
2624
|
+
}
|
|
2625
|
+
joinPromise
|
|
2626
|
+
.then(function () {
|
|
2627
|
+
handleJoined();
|
|
2628
|
+
resolve({});
|
|
2629
|
+
})
|
|
2630
|
+
.catch(function (err) {
|
|
2631
|
+
logger.debug("error joining " + domain + " domain: " + JSON.stringify(err));
|
|
2632
|
+
reject(err);
|
|
2633
|
+
});
|
|
2634
|
+
});
|
|
2635
|
+
}
|
|
2636
|
+
function leave() {
|
|
2637
|
+
if (domain === "global") {
|
|
2638
|
+
return Promise.resolve();
|
|
2639
|
+
}
|
|
2640
|
+
logger.debug("stopping session " + domain + "...");
|
|
2641
|
+
var leaveMsg = {
|
|
2642
|
+
type: "leave",
|
|
2643
|
+
destination: domain,
|
|
2644
|
+
domain: "global",
|
|
2645
|
+
};
|
|
2646
|
+
tryReconnecting = false;
|
|
2647
|
+
return send(leaveMsg)
|
|
2648
|
+
.then(function () {
|
|
2649
|
+
isJoined = false;
|
|
2650
|
+
callbacks.execute("onLeft");
|
|
2651
|
+
})
|
|
2652
|
+
.catch(function () {
|
|
2653
|
+
isJoined = false;
|
|
2654
|
+
callbacks.execute("onLeft");
|
|
2655
|
+
});
|
|
2656
|
+
}
|
|
2657
|
+
function handleJoined() {
|
|
2658
|
+
logger.debug("did join " + domain);
|
|
2659
|
+
isJoined = true;
|
|
2660
|
+
var wasReconnect = tryReconnecting;
|
|
2661
|
+
tryReconnecting = false;
|
|
2662
|
+
callbacks.execute("onJoined", wasReconnect);
|
|
2663
|
+
}
|
|
2664
|
+
function handleConnectionDisconnected() {
|
|
2665
|
+
_connectionOn = false;
|
|
2666
|
+
logger.debug("connection is down");
|
|
2667
|
+
isJoined = false;
|
|
2668
|
+
tryReconnecting = true;
|
|
2669
|
+
callbacks.execute("onLeft", { disconnected: true });
|
|
2670
|
+
}
|
|
2671
|
+
function handleConnectionLoggedIn() {
|
|
2672
|
+
_connectionOn = true;
|
|
2673
|
+
if (tryReconnecting) {
|
|
2674
|
+
logger.debug("connection is now up - trying to reconnect...");
|
|
2675
|
+
join(_latestOptions);
|
|
2676
|
+
}
|
|
2677
|
+
}
|
|
2678
|
+
function onJoined(callback) {
|
|
2679
|
+
if (isJoined) {
|
|
2680
|
+
callback(false);
|
|
2681
|
+
}
|
|
2682
|
+
return callbacks.add("onJoined", callback);
|
|
2683
|
+
}
|
|
2684
|
+
function onLeft(callback) {
|
|
2685
|
+
if (!isJoined) {
|
|
2686
|
+
callback();
|
|
2687
|
+
}
|
|
2688
|
+
return callbacks.add("onLeft", callback);
|
|
2689
|
+
}
|
|
2690
|
+
function handleErrorMessage(msg) {
|
|
2691
|
+
if (domain !== msg.domain) {
|
|
2692
|
+
return;
|
|
2693
|
+
}
|
|
2694
|
+
var requestId = msg.request_id;
|
|
2695
|
+
if (!requestId) {
|
|
2696
|
+
return;
|
|
2697
|
+
}
|
|
2698
|
+
var entry = requestsMap[requestId];
|
|
2699
|
+
if (!entry) {
|
|
2700
|
+
return;
|
|
2701
|
+
}
|
|
2702
|
+
entry.error(msg);
|
|
2703
|
+
}
|
|
2704
|
+
function handleSuccessMessage(msg) {
|
|
2705
|
+
if (msg.domain !== domain) {
|
|
2706
|
+
return;
|
|
2707
|
+
}
|
|
2708
|
+
var requestId = msg.request_id;
|
|
2709
|
+
if (!requestId) {
|
|
2710
|
+
return;
|
|
2711
|
+
}
|
|
2712
|
+
var entry = requestsMap[requestId];
|
|
2713
|
+
if (!entry) {
|
|
2714
|
+
return;
|
|
2715
|
+
}
|
|
2716
|
+
entry.success(msg);
|
|
2717
|
+
}
|
|
2718
|
+
function getNextRequestId() {
|
|
2719
|
+
return shortid();
|
|
2720
|
+
}
|
|
2721
|
+
var queuedCalls = [];
|
|
2722
|
+
function send(msg, tag, options) {
|
|
2723
|
+
var _a, _b;
|
|
2724
|
+
var ignore = ["hello", "join"];
|
|
2725
|
+
if (msg.type && ignore.indexOf(msg.type) === -1) {
|
|
2726
|
+
if (!isJoined) {
|
|
2727
|
+
logger.warn("trying to send a message (".concat(msg.domain, " ").concat(msg.type, ") but not connected, will queue"));
|
|
2728
|
+
var pw = new PromiseWrapper();
|
|
2729
|
+
queuedCalls.push({ msg: msg, tag: tag, options: options, pw: pw });
|
|
2730
|
+
if (queuedCalls.length === 1) {
|
|
2731
|
+
var unsubscribe_1 = onJoined(function () {
|
|
2732
|
+
logger.info("joined - will now send queued messages (".concat(queuedCalls.length, " -> [").concat(queuedCalls.map(function (m) { return m.msg.type; }), "])"));
|
|
2733
|
+
queuedCalls.forEach(function (qm) {
|
|
2734
|
+
send(qm.msg, qm.tag, qm.options)
|
|
2735
|
+
.then(function (t) { return qm.pw.resolve(t); })
|
|
2736
|
+
.catch(function (e) { return qm.pw.reject(e); });
|
|
2737
|
+
});
|
|
2738
|
+
queuedCalls = [];
|
|
2739
|
+
unsubscribe_1();
|
|
2740
|
+
});
|
|
2741
|
+
}
|
|
2742
|
+
return pw.promise;
|
|
2743
|
+
}
|
|
2744
|
+
}
|
|
2745
|
+
options = options !== null && options !== void 0 ? options : {};
|
|
2746
|
+
msg.request_id = (_a = msg.request_id) !== null && _a !== void 0 ? _a : getNextRequestId();
|
|
2747
|
+
msg.domain = (_b = msg.domain) !== null && _b !== void 0 ? _b : domain;
|
|
2748
|
+
if (!options.skipPeerId) {
|
|
2749
|
+
msg.peer_id = connection.peerId;
|
|
2750
|
+
}
|
|
2751
|
+
var requestId = msg.request_id;
|
|
2752
|
+
return new Promise(function (resolve, reject) {
|
|
2753
|
+
requestsMap[requestId] = {
|
|
2754
|
+
success: function (successMsg) {
|
|
2755
|
+
delete requestsMap[requestId];
|
|
2756
|
+
successMsg._tag = tag;
|
|
2757
|
+
resolve(successMsg);
|
|
2758
|
+
},
|
|
2759
|
+
error: function (errorMsg) {
|
|
2760
|
+
logger.warn("GW error - ".concat(JSON.stringify(errorMsg), " for request ").concat(JSON.stringify(msg)));
|
|
2761
|
+
delete requestsMap[requestId];
|
|
2762
|
+
errorMsg._tag = tag;
|
|
2763
|
+
reject(errorMsg);
|
|
2764
|
+
},
|
|
2765
|
+
};
|
|
2766
|
+
connection
|
|
2767
|
+
.send(msg, options)
|
|
2768
|
+
.catch(function (err) {
|
|
2769
|
+
requestsMap[requestId].error({ err: err });
|
|
2770
|
+
});
|
|
2771
|
+
});
|
|
2772
|
+
}
|
|
2773
|
+
function sendFireAndForget(msg) {
|
|
2774
|
+
var _a;
|
|
2775
|
+
msg.request_id = msg.request_id ? msg.request_id : getNextRequestId();
|
|
2776
|
+
msg.domain = (_a = msg.domain) !== null && _a !== void 0 ? _a : domain;
|
|
2777
|
+
msg.peer_id = connection.peerId;
|
|
2778
|
+
return connection.send(msg);
|
|
2779
|
+
}
|
|
2780
|
+
return {
|
|
2781
|
+
join: join,
|
|
2782
|
+
leave: leave,
|
|
2783
|
+
onJoined: onJoined,
|
|
2784
|
+
onLeft: onLeft,
|
|
2785
|
+
send: send,
|
|
2786
|
+
sendFireAndForget: sendFireAndForget,
|
|
2787
|
+
on: function (type, callback) {
|
|
2788
|
+
connection.on(type, function (msg) {
|
|
2789
|
+
if (msg.domain !== domain) {
|
|
2790
|
+
return;
|
|
2791
|
+
}
|
|
2792
|
+
try {
|
|
2793
|
+
callback(msg);
|
|
2794
|
+
}
|
|
2795
|
+
catch (e) {
|
|
2796
|
+
logger.error("Callback failed: ".concat(e, " \n ").concat(e.stack, " \n msg was: ").concat(JSON.stringify(msg)), e);
|
|
2797
|
+
}
|
|
2798
|
+
});
|
|
2799
|
+
},
|
|
2800
|
+
loggedIn: function (callback) { return connection.loggedIn(callback); },
|
|
2801
|
+
connected: function (callback) { return connection.connected(callback); },
|
|
2802
|
+
disconnected: function (callback) { return connection.disconnected(callback); },
|
|
2803
|
+
get peerId() {
|
|
2804
|
+
return connection.peerId;
|
|
2805
|
+
},
|
|
2806
|
+
get domain() {
|
|
2807
|
+
return domain;
|
|
2808
|
+
},
|
|
2809
|
+
};
|
|
2810
|
+
}
|
|
3105
2811
|
|
|
3106
2812
|
var Connection = (function () {
|
|
3107
2813
|
function Connection(settings, logger) {
|
|
2814
|
+
var _a, _b;
|
|
3108
2815
|
this.settings = settings;
|
|
3109
2816
|
this.logger = logger;
|
|
2817
|
+
this.protocolVersion = 3;
|
|
3110
2818
|
this.messageHandlers = {};
|
|
3111
2819
|
this.ids = 1;
|
|
3112
2820
|
this.registry = lib$1();
|
|
@@ -3115,10 +2823,19 @@ var Connection = (function () {
|
|
|
3115
2823
|
this._swapTransport = false;
|
|
3116
2824
|
this._switchInProgress = false;
|
|
3117
2825
|
this._transportSubscriptions = [];
|
|
2826
|
+
this.datePrefix = "#T42_DATE#";
|
|
2827
|
+
this.datePrefixLen = this.datePrefix.length;
|
|
2828
|
+
this.dateMinLen = this.datePrefixLen + 1;
|
|
2829
|
+
this.datePrefixFirstChar = this.datePrefix[0];
|
|
3118
2830
|
this._sequelizer = new AsyncSequelizer();
|
|
2831
|
+
this._isLoggedIn = false;
|
|
2832
|
+
this.shouldTryLogin = true;
|
|
2833
|
+
this.sessions = [];
|
|
2834
|
+
this.initialLogin = true;
|
|
2835
|
+
this.initialLoginAttempts = 3;
|
|
3119
2836
|
settings = settings || {};
|
|
3120
|
-
settings.reconnectAttempts = settings.reconnectAttempts
|
|
3121
|
-
settings.reconnectInterval = settings.reconnectInterval
|
|
2837
|
+
settings.reconnectAttempts = (_a = settings.reconnectAttempts) !== null && _a !== void 0 ? _a : 10;
|
|
2838
|
+
settings.reconnectInterval = (_b = settings.reconnectInterval) !== null && _b !== void 0 ? _b : 1000;
|
|
3122
2839
|
if (settings.inproc) {
|
|
3123
2840
|
this.transport = new InProcTransport(settings.inproc, logger.subLogger("inMemory"));
|
|
3124
2841
|
}
|
|
@@ -3136,21 +2853,13 @@ var Connection = (function () {
|
|
|
3136
2853
|
}
|
|
3137
2854
|
this.isTrace = logger.canPublish("trace");
|
|
3138
2855
|
logger.debug("starting with ".concat(this.transport.name(), " transport"));
|
|
3139
|
-
this.protocol = new GW3ProtocolImpl(this, settings, logger.subLogger("protocol"));
|
|
3140
2856
|
var unsubConnectionChanged = this.transport.onConnectedChanged(this.handleConnectionChanged.bind(this));
|
|
3141
2857
|
var unsubOnMessage = this.transport.onMessage(this.handleTransportMessage.bind(this));
|
|
3142
2858
|
this._transportSubscriptions.push(unsubConnectionChanged);
|
|
3143
2859
|
this._transportSubscriptions.push(unsubOnMessage);
|
|
3144
2860
|
this._defaultTransport = this.transport;
|
|
2861
|
+
this.ping();
|
|
3145
2862
|
}
|
|
3146
|
-
Object.defineProperty(Connection.prototype, "protocolVersion", {
|
|
3147
|
-
get: function () {
|
|
3148
|
-
var _a;
|
|
3149
|
-
return (_a = this.protocol) === null || _a === void 0 ? void 0 : _a.protocolVersion;
|
|
3150
|
-
},
|
|
3151
|
-
enumerable: false,
|
|
3152
|
-
configurable: true
|
|
3153
|
-
});
|
|
3154
2863
|
Connection.prototype.switchTransport = function (settings) {
|
|
3155
2864
|
return __awaiter(this, void 0, void 0, function () {
|
|
3156
2865
|
var _this = this;
|
|
@@ -3198,239 +2907,555 @@ var Connection = (function () {
|
|
|
3198
2907
|
});
|
|
3199
2908
|
}); })];
|
|
3200
2909
|
});
|
|
3201
|
-
});
|
|
2910
|
+
});
|
|
2911
|
+
};
|
|
2912
|
+
Connection.prototype.onLibReAnnounced = function (callback) {
|
|
2913
|
+
return this.registry.add("libReAnnounced", callback);
|
|
2914
|
+
};
|
|
2915
|
+
Connection.prototype.setLibReAnnounced = function (lib) {
|
|
2916
|
+
this.registry.execute("libReAnnounced", lib);
|
|
2917
|
+
};
|
|
2918
|
+
Connection.prototype.send = function (message, options) {
|
|
2919
|
+
if (this.transport.sendObject &&
|
|
2920
|
+
this.transport.isObjectBasedTransport) {
|
|
2921
|
+
var msg = this.createObjectMessage(message);
|
|
2922
|
+
if (this.isTrace) {
|
|
2923
|
+
this.logger.trace(">> ".concat(JSON.stringify(msg)));
|
|
2924
|
+
}
|
|
2925
|
+
return this.transport.sendObject(msg, options);
|
|
2926
|
+
}
|
|
2927
|
+
else {
|
|
2928
|
+
var strMessage = this.createStringMessage(message);
|
|
2929
|
+
if (this.isTrace) {
|
|
2930
|
+
this.logger.trace(">> ".concat(strMessage));
|
|
2931
|
+
}
|
|
2932
|
+
return this.transport.send(strMessage, options);
|
|
2933
|
+
}
|
|
2934
|
+
};
|
|
2935
|
+
Connection.prototype.on = function (type, messageHandler) {
|
|
2936
|
+
type = type.toLowerCase();
|
|
2937
|
+
if (this.messageHandlers[type] === undefined) {
|
|
2938
|
+
this.messageHandlers[type] = {};
|
|
2939
|
+
}
|
|
2940
|
+
var id = this.ids++;
|
|
2941
|
+
this.messageHandlers[type][id] = messageHandler;
|
|
2942
|
+
return {
|
|
2943
|
+
type: type,
|
|
2944
|
+
id: id,
|
|
2945
|
+
};
|
|
2946
|
+
};
|
|
2947
|
+
Connection.prototype.off = function (info) {
|
|
2948
|
+
delete this.messageHandlers[info.type.toLowerCase()][info.id];
|
|
2949
|
+
};
|
|
2950
|
+
Object.defineProperty(Connection.prototype, "isConnected", {
|
|
2951
|
+
get: function () {
|
|
2952
|
+
return this._isLoggedIn;
|
|
2953
|
+
},
|
|
2954
|
+
enumerable: false,
|
|
2955
|
+
configurable: true
|
|
2956
|
+
});
|
|
2957
|
+
Connection.prototype.connected = function (callback) {
|
|
2958
|
+
var _this = this;
|
|
2959
|
+
return this.loggedIn(function () {
|
|
2960
|
+
var currentServer = _this.transport.name();
|
|
2961
|
+
callback(currentServer);
|
|
2962
|
+
});
|
|
2963
|
+
};
|
|
2964
|
+
Connection.prototype.disconnected = function (callback) {
|
|
2965
|
+
return this.registry.add("disconnected", callback);
|
|
2966
|
+
};
|
|
2967
|
+
Connection.prototype.login = function (authRequest, reconnect) {
|
|
2968
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2969
|
+
var newAuth, identity, error_2;
|
|
2970
|
+
return __generator(this, function (_a) {
|
|
2971
|
+
switch (_a.label) {
|
|
2972
|
+
case 0:
|
|
2973
|
+
if (!this._defaultAuth) {
|
|
2974
|
+
this._defaultAuth = authRequest;
|
|
2975
|
+
}
|
|
2976
|
+
if (this._swapTransport) {
|
|
2977
|
+
this.logger.trace("Detected a transport swap, swapping transports");
|
|
2978
|
+
newAuth = this.transportSwap();
|
|
2979
|
+
authRequest = newAuth !== null && newAuth !== void 0 ? newAuth : authRequest;
|
|
2980
|
+
}
|
|
2981
|
+
this.logger.trace("Starting login for transport: ".concat(this.transport.name(), " and auth ").concat(JSON.stringify(authRequest)));
|
|
2982
|
+
_a.label = 1;
|
|
2983
|
+
case 1:
|
|
2984
|
+
_a.trys.push([1, 4, , 5]);
|
|
2985
|
+
return [4, this.transport.open()];
|
|
2986
|
+
case 2:
|
|
2987
|
+
_a.sent();
|
|
2988
|
+
this.logger.trace("Transport: ".concat(this.transport.name(), " opened, logging in"));
|
|
2989
|
+
timer("connection").mark("transport-opened");
|
|
2990
|
+
return [4, this.loginCore(authRequest, reconnect)];
|
|
2991
|
+
case 3:
|
|
2992
|
+
identity = _a.sent();
|
|
2993
|
+
this.logger.trace("Logged in with identity: ".concat(JSON.stringify(identity)));
|
|
2994
|
+
timer("connection").mark("protocol-logged-in");
|
|
2995
|
+
return [2, identity];
|
|
2996
|
+
case 4:
|
|
2997
|
+
error_2 = _a.sent();
|
|
2998
|
+
if (this._switchInProgress) {
|
|
2999
|
+
this.logger.trace("An error while logging in after a transport swap, preparing a default swap.");
|
|
3000
|
+
this.prepareDefaultSwap();
|
|
3001
|
+
}
|
|
3002
|
+
throw new Error(error_2);
|
|
3003
|
+
case 5: return [2];
|
|
3004
|
+
}
|
|
3005
|
+
});
|
|
3006
|
+
});
|
|
3007
|
+
};
|
|
3008
|
+
Connection.prototype.logout = function () {
|
|
3009
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
3010
|
+
return __generator(this, function (_a) {
|
|
3011
|
+
switch (_a.label) {
|
|
3012
|
+
case 0: return [4, this.logoutCore()];
|
|
3013
|
+
case 1:
|
|
3014
|
+
_a.sent();
|
|
3015
|
+
return [4, this.transport.close()];
|
|
3016
|
+
case 2:
|
|
3017
|
+
_a.sent();
|
|
3018
|
+
return [2];
|
|
3019
|
+
}
|
|
3020
|
+
});
|
|
3021
|
+
});
|
|
3022
|
+
};
|
|
3023
|
+
Connection.prototype.loggedIn = function (callback) {
|
|
3024
|
+
if (this._isLoggedIn) {
|
|
3025
|
+
callback();
|
|
3026
|
+
}
|
|
3027
|
+
return this.registry.add("onLoggedIn", callback);
|
|
3028
|
+
};
|
|
3029
|
+
Connection.prototype.domain = function (domain, successMessages, errorMessages) {
|
|
3030
|
+
var session = this.sessions.find(function (s) { return s.domain === domain; });
|
|
3031
|
+
if (!session) {
|
|
3032
|
+
session = domainSession(domain, this, this.logger.subLogger("domain=".concat(domain)), successMessages, errorMessages);
|
|
3033
|
+
this.sessions.push(session);
|
|
3034
|
+
}
|
|
3035
|
+
return session;
|
|
3036
|
+
};
|
|
3037
|
+
Connection.prototype.authToken = function () {
|
|
3038
|
+
var createTokenReq = {
|
|
3039
|
+
domain: "global",
|
|
3040
|
+
type: "create-token"
|
|
3041
|
+
};
|
|
3042
|
+
if (!this.globalDomain) {
|
|
3043
|
+
return Promise.reject(new Error("no global domain session"));
|
|
3044
|
+
}
|
|
3045
|
+
return this.globalDomain.send(createTokenReq)
|
|
3046
|
+
.then(function (res) {
|
|
3047
|
+
return res.token;
|
|
3048
|
+
});
|
|
3049
|
+
};
|
|
3050
|
+
Connection.prototype.reconnect = function () {
|
|
3051
|
+
return this.transport.reconnect();
|
|
3052
|
+
};
|
|
3053
|
+
Connection.prototype.setLoggedIn = function (value) {
|
|
3054
|
+
this._isLoggedIn = value;
|
|
3055
|
+
if (this._isLoggedIn) {
|
|
3056
|
+
this.registry.execute("onLoggedIn");
|
|
3057
|
+
}
|
|
3058
|
+
};
|
|
3059
|
+
Connection.prototype.distributeMessage = function (message, type) {
|
|
3060
|
+
var _this = this;
|
|
3061
|
+
var handlers = this.messageHandlers[type.toLowerCase()];
|
|
3062
|
+
if (handlers !== undefined) {
|
|
3063
|
+
Object.keys(handlers).forEach(function (handlerId) {
|
|
3064
|
+
var handler = handlers[handlerId];
|
|
3065
|
+
if (handler !== undefined) {
|
|
3066
|
+
try {
|
|
3067
|
+
handler(message);
|
|
3068
|
+
}
|
|
3069
|
+
catch (error) {
|
|
3070
|
+
try {
|
|
3071
|
+
_this.logger.error("Message handler failed with ".concat(error.stack), error);
|
|
3072
|
+
}
|
|
3073
|
+
catch (loggerError) {
|
|
3074
|
+
console.log("Message handler failed", error);
|
|
3075
|
+
}
|
|
3076
|
+
}
|
|
3077
|
+
}
|
|
3078
|
+
});
|
|
3079
|
+
}
|
|
3080
|
+
};
|
|
3081
|
+
Connection.prototype.handleConnectionChanged = function (connected) {
|
|
3082
|
+
var _a, _b;
|
|
3083
|
+
if (this._connected === connected) {
|
|
3084
|
+
return;
|
|
3085
|
+
}
|
|
3086
|
+
this._connected = connected;
|
|
3087
|
+
if (connected) {
|
|
3088
|
+
if ((_b = (_a = this.settings) === null || _a === void 0 ? void 0 : _a.replaySpecs) === null || _b === void 0 ? void 0 : _b.length) {
|
|
3089
|
+
this.replayer = new MessageReplayerImpl(this.settings.replaySpecs);
|
|
3090
|
+
this.replayer.init(this);
|
|
3091
|
+
}
|
|
3092
|
+
this.registry.execute("connected");
|
|
3093
|
+
}
|
|
3094
|
+
else {
|
|
3095
|
+
this.handleDisconnected();
|
|
3096
|
+
this.registry.execute("disconnected");
|
|
3097
|
+
}
|
|
3098
|
+
};
|
|
3099
|
+
Connection.prototype.handleDisconnected = function () {
|
|
3100
|
+
var _this = this;
|
|
3101
|
+
this.setLoggedIn(false);
|
|
3102
|
+
var tryToLogin = this.shouldTryLogin;
|
|
3103
|
+
if (tryToLogin && this.initialLogin) {
|
|
3104
|
+
if (this.initialLoginAttempts <= 0) {
|
|
3105
|
+
return;
|
|
3106
|
+
}
|
|
3107
|
+
this.initialLoginAttempts--;
|
|
3108
|
+
}
|
|
3109
|
+
this.logger.debug("disconnected - will try new login?" + this.shouldTryLogin);
|
|
3110
|
+
if (this.shouldTryLogin) {
|
|
3111
|
+
if (!this.loginConfig) {
|
|
3112
|
+
throw new Error("no login info");
|
|
3113
|
+
}
|
|
3114
|
+
this.login(this.loginConfig, true)
|
|
3115
|
+
.catch(function () {
|
|
3116
|
+
setTimeout(_this.handleDisconnected.bind(_this), _this.settings.reconnectInterval || 1000);
|
|
3117
|
+
});
|
|
3118
|
+
}
|
|
3119
|
+
};
|
|
3120
|
+
Connection.prototype.handleTransportMessage = function (msg) {
|
|
3121
|
+
var msgObj;
|
|
3122
|
+
if (typeof msg === "string") {
|
|
3123
|
+
msgObj = this.processStringMessage(msg);
|
|
3124
|
+
}
|
|
3125
|
+
else {
|
|
3126
|
+
msgObj = this.processObjectMessage(msg);
|
|
3127
|
+
}
|
|
3128
|
+
if (this.isTrace) {
|
|
3129
|
+
this.logger.trace("<< ".concat(JSON.stringify(msgObj)));
|
|
3130
|
+
}
|
|
3131
|
+
this.distributeMessage(msgObj.msg, msgObj.msgType);
|
|
3132
|
+
};
|
|
3133
|
+
Connection.prototype.verifyConnection = function () {
|
|
3134
|
+
var _this = this;
|
|
3135
|
+
return PromisePlus$1(function (resolve) {
|
|
3136
|
+
var unsub;
|
|
3137
|
+
var ready = waitForInvocations(2, function () {
|
|
3138
|
+
if (unsub) {
|
|
3139
|
+
unsub();
|
|
3140
|
+
}
|
|
3141
|
+
resolve();
|
|
3142
|
+
});
|
|
3143
|
+
unsub = _this.onLibReAnnounced(function (lib) {
|
|
3144
|
+
if (lib.name === "interop") {
|
|
3145
|
+
return ready();
|
|
3146
|
+
}
|
|
3147
|
+
if (lib.name === "contexts") {
|
|
3148
|
+
return ready();
|
|
3149
|
+
}
|
|
3150
|
+
});
|
|
3151
|
+
}, 10000, "Transport switch timed out waiting for all libraries to be re-announced");
|
|
3202
3152
|
};
|
|
3203
|
-
Connection.prototype.
|
|
3204
|
-
|
|
3153
|
+
Connection.prototype.getNewSecondaryTransport = function (settings) {
|
|
3154
|
+
var _a;
|
|
3155
|
+
if (!((_a = settings.transportConfig) === null || _a === void 0 ? void 0 : _a.url)) {
|
|
3156
|
+
throw new Error("Missing secondary transport URL.");
|
|
3157
|
+
}
|
|
3158
|
+
return new WS(Object.assign({}, this.settings, { ws: settings.transportConfig.url, reconnectAttempts: 1 }), this.logger.subLogger("ws-secondary"));
|
|
3205
3159
|
};
|
|
3206
|
-
Connection.prototype.
|
|
3207
|
-
|
|
3160
|
+
Connection.prototype.getNewSecondaryAuth = function (settings) {
|
|
3161
|
+
var _a;
|
|
3162
|
+
if (!((_a = settings.transportConfig) === null || _a === void 0 ? void 0 : _a.auth)) {
|
|
3163
|
+
throw new Error("Missing secondary transport auth information.");
|
|
3164
|
+
}
|
|
3165
|
+
return settings.transportConfig.auth;
|
|
3208
3166
|
};
|
|
3209
|
-
Connection.prototype.
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
this.logger.trace(">> ".concat(JSON.stringify(msg)));
|
|
3215
|
-
}
|
|
3216
|
-
return this.transport.sendObject(msg, options);
|
|
3167
|
+
Connection.prototype.transportSwap = function () {
|
|
3168
|
+
this._swapTransport = false;
|
|
3169
|
+
if (!this._targetTransport || !this._targetAuth) {
|
|
3170
|
+
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."));
|
|
3171
|
+
return;
|
|
3217
3172
|
}
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
|
|
3173
|
+
this._transportSubscriptions.forEach(function (unsub) { return unsub(); });
|
|
3174
|
+
this._transportSubscriptions = [];
|
|
3175
|
+
this.transport = this._targetTransport;
|
|
3176
|
+
var unsubConnectionChanged = this.transport.onConnectedChanged(this.handleConnectionChanged.bind(this));
|
|
3177
|
+
var unsubOnMessage = this.transport.onMessage(this.handleTransportMessage.bind(this));
|
|
3178
|
+
this._transportSubscriptions.push(unsubConnectionChanged);
|
|
3179
|
+
this._transportSubscriptions.push(unsubOnMessage);
|
|
3180
|
+
return this._targetAuth;
|
|
3181
|
+
};
|
|
3182
|
+
Connection.prototype.prepareDefaultSwap = function () {
|
|
3183
|
+
var _this = this;
|
|
3184
|
+
this._transportSubscriptions.forEach(function (unsub) { return unsub(); });
|
|
3185
|
+
this._transportSubscriptions = [];
|
|
3186
|
+
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))); });
|
|
3187
|
+
this._targetTransport = this._defaultTransport;
|
|
3188
|
+
this._targetAuth = this._defaultAuth;
|
|
3189
|
+
this._swapTransport = true;
|
|
3190
|
+
};
|
|
3191
|
+
Connection.prototype.processStringMessage = function (message) {
|
|
3192
|
+
var _this = this;
|
|
3193
|
+
var msg = JSON.parse(message, function (key, value) {
|
|
3194
|
+
if (typeof value !== "string") {
|
|
3195
|
+
return value;
|
|
3222
3196
|
}
|
|
3223
|
-
|
|
3197
|
+
if (value.length < _this.dateMinLen) {
|
|
3198
|
+
return value;
|
|
3199
|
+
}
|
|
3200
|
+
if (!value.startsWith(_this.datePrefixFirstChar)) {
|
|
3201
|
+
return value;
|
|
3202
|
+
}
|
|
3203
|
+
if (value.substring(0, _this.datePrefixLen) !== _this.datePrefix) {
|
|
3204
|
+
return value;
|
|
3205
|
+
}
|
|
3206
|
+
try {
|
|
3207
|
+
var milliseconds = parseInt(value.substring(_this.datePrefixLen, value.length), 10);
|
|
3208
|
+
if (isNaN(milliseconds)) {
|
|
3209
|
+
return value;
|
|
3210
|
+
}
|
|
3211
|
+
return new Date(milliseconds);
|
|
3212
|
+
}
|
|
3213
|
+
catch (ex) {
|
|
3214
|
+
return value;
|
|
3215
|
+
}
|
|
3216
|
+
});
|
|
3217
|
+
return {
|
|
3218
|
+
msg: msg,
|
|
3219
|
+
msgType: msg.type,
|
|
3220
|
+
};
|
|
3221
|
+
};
|
|
3222
|
+
Connection.prototype.createStringMessage = function (message) {
|
|
3223
|
+
var oldToJson = Date.prototype.toJSON;
|
|
3224
|
+
try {
|
|
3225
|
+
var datePrefix_1 = this.datePrefix;
|
|
3226
|
+
Date.prototype.toJSON = function () {
|
|
3227
|
+
return datePrefix_1 + this.getTime();
|
|
3228
|
+
};
|
|
3229
|
+
var result = JSON.stringify(message);
|
|
3230
|
+
return result;
|
|
3231
|
+
}
|
|
3232
|
+
finally {
|
|
3233
|
+
Date.prototype.toJSON = oldToJson;
|
|
3224
3234
|
}
|
|
3225
3235
|
};
|
|
3226
|
-
Connection.prototype.
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
this.messageHandlers[type] = {};
|
|
3236
|
+
Connection.prototype.processObjectMessage = function (message) {
|
|
3237
|
+
if (!message.type) {
|
|
3238
|
+
throw new Error("Object should have type property");
|
|
3230
3239
|
}
|
|
3231
|
-
var id = this.ids++;
|
|
3232
|
-
this.messageHandlers[type][id] = messageHandler;
|
|
3233
3240
|
return {
|
|
3234
|
-
|
|
3235
|
-
|
|
3241
|
+
msg: message,
|
|
3242
|
+
msgType: message.type,
|
|
3236
3243
|
};
|
|
3237
3244
|
};
|
|
3238
|
-
Connection.prototype.
|
|
3239
|
-
|
|
3240
|
-
};
|
|
3241
|
-
Object.defineProperty(Connection.prototype, "isConnected", {
|
|
3242
|
-
get: function () {
|
|
3243
|
-
return this.protocol.isLoggedIn;
|
|
3244
|
-
},
|
|
3245
|
-
enumerable: false,
|
|
3246
|
-
configurable: true
|
|
3247
|
-
});
|
|
3248
|
-
Connection.prototype.connected = function (callback) {
|
|
3249
|
-
var _this = this;
|
|
3250
|
-
return this.protocol.loggedIn(function () {
|
|
3251
|
-
var currentServer = _this.transport.name();
|
|
3252
|
-
callback(currentServer);
|
|
3253
|
-
});
|
|
3254
|
-
};
|
|
3255
|
-
Connection.prototype.disconnected = function (callback) {
|
|
3256
|
-
return this.registry.add("disconnected", callback);
|
|
3245
|
+
Connection.prototype.createObjectMessage = function (message) {
|
|
3246
|
+
return message;
|
|
3257
3247
|
};
|
|
3258
|
-
Connection.prototype.
|
|
3248
|
+
Connection.prototype.loginCore = function (config, reconnect) {
|
|
3259
3249
|
return __awaiter(this, void 0, void 0, function () {
|
|
3260
|
-
var
|
|
3250
|
+
var authentication, helloMsg, sendOptions, welcomeMsg, err_1;
|
|
3261
3251
|
return __generator(this, function (_a) {
|
|
3262
3252
|
switch (_a.label) {
|
|
3263
3253
|
case 0:
|
|
3264
|
-
|
|
3265
|
-
|
|
3254
|
+
this.logger.info("logging in...");
|
|
3255
|
+
this.loginConfig = config;
|
|
3256
|
+
if (!this.loginConfig) {
|
|
3257
|
+
this.loginConfig = { username: "", password: "" };
|
|
3266
3258
|
}
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
|
|
3259
|
+
this.shouldTryLogin = true;
|
|
3260
|
+
return [4, this.setupAuthConfig(config, reconnect)];
|
|
3261
|
+
case 1:
|
|
3262
|
+
authentication = _a.sent();
|
|
3263
|
+
helloMsg = {
|
|
3264
|
+
type: "hello",
|
|
3265
|
+
identity: this.settings.identity,
|
|
3266
|
+
authentication: authentication
|
|
3267
|
+
};
|
|
3268
|
+
if (config.sessionId) {
|
|
3269
|
+
helloMsg.request_id = config.sessionId;
|
|
3271
3270
|
}
|
|
3272
|
-
this.
|
|
3273
|
-
|
|
3271
|
+
this.globalDomain = domainSession("global", this, this.logger.subLogger("global-domain"), [
|
|
3272
|
+
"welcome",
|
|
3273
|
+
"token",
|
|
3274
|
+
"authentication-request"
|
|
3275
|
+
]);
|
|
3276
|
+
sendOptions = { skipPeerId: true };
|
|
3277
|
+
if (this.initialLogin) {
|
|
3278
|
+
sendOptions.retryInterval = this.settings.reconnectInterval;
|
|
3279
|
+
sendOptions.maxRetries = this.settings.reconnectAttempts;
|
|
3280
|
+
}
|
|
3281
|
+
_a.label = 2;
|
|
3282
|
+
case 2:
|
|
3283
|
+
_a.trys.push([2, 4, 5, 6]);
|
|
3284
|
+
return [4, this.tryAuthenticate(this.globalDomain, helloMsg, sendOptions, config)];
|
|
3285
|
+
case 3:
|
|
3286
|
+
welcomeMsg = _a.sent();
|
|
3287
|
+
this.initialLogin = false;
|
|
3288
|
+
this.logger.info("login successful with peerId " + welcomeMsg.peer_id);
|
|
3289
|
+
this.peerId = welcomeMsg.peer_id;
|
|
3290
|
+
this.resolvedIdentity = welcomeMsg.resolved_identity;
|
|
3291
|
+
this.availableDomains = welcomeMsg.available_domains;
|
|
3292
|
+
if (welcomeMsg.options) {
|
|
3293
|
+
this.token = welcomeMsg.options.access_token;
|
|
3294
|
+
this.info = welcomeMsg.options.info;
|
|
3295
|
+
}
|
|
3296
|
+
this.setLoggedIn(true);
|
|
3297
|
+
return [2, welcomeMsg.resolved_identity];
|
|
3298
|
+
case 4:
|
|
3299
|
+
err_1 = _a.sent();
|
|
3300
|
+
this.logger.error("error sending hello message - " + (err_1.message || err_1.msg || err_1.reason || err_1), err_1);
|
|
3301
|
+
throw err_1;
|
|
3302
|
+
case 5:
|
|
3303
|
+
if ((config === null || config === void 0 ? void 0 : config.flowCallback) && config.sessionId) {
|
|
3304
|
+
config.flowCallback(config.sessionId, null);
|
|
3305
|
+
}
|
|
3306
|
+
return [7];
|
|
3307
|
+
case 6: return [2];
|
|
3308
|
+
}
|
|
3309
|
+
});
|
|
3310
|
+
});
|
|
3311
|
+
};
|
|
3312
|
+
Connection.prototype.tryAuthenticate = function (globalDomain, helloMsg, sendOptions, config) {
|
|
3313
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
3314
|
+
var welcomeMsg, msg, token, _a;
|
|
3315
|
+
return __generator(this, function (_b) {
|
|
3316
|
+
switch (_b.label) {
|
|
3317
|
+
case 0:
|
|
3318
|
+
return [4, globalDomain.send(helloMsg, undefined, sendOptions)];
|
|
3274
3319
|
case 1:
|
|
3275
|
-
|
|
3276
|
-
return [
|
|
3320
|
+
msg = _b.sent();
|
|
3321
|
+
if (!(msg.type === "authentication-request")) return [3, 4];
|
|
3322
|
+
token = Buffer.from(msg.authentication.token, "base64");
|
|
3323
|
+
if (!(config.flowCallback && config.sessionId)) return [3, 3];
|
|
3324
|
+
_a = helloMsg.authentication;
|
|
3325
|
+
return [4, config.flowCallback(config.sessionId, token)];
|
|
3277
3326
|
case 2:
|
|
3278
|
-
_a.
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
|
|
3327
|
+
_a.token =
|
|
3328
|
+
(_b.sent())
|
|
3329
|
+
.data
|
|
3330
|
+
.toString("base64");
|
|
3331
|
+
_b.label = 3;
|
|
3282
3332
|
case 3:
|
|
3283
|
-
|
|
3284
|
-
|
|
3285
|
-
timer("connection").mark("protocol-logged-in");
|
|
3286
|
-
return [2, identity];
|
|
3333
|
+
helloMsg.request_id = config.sessionId;
|
|
3334
|
+
return [3, 5];
|
|
3287
3335
|
case 4:
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
|
|
3336
|
+
if (msg.type === "welcome") {
|
|
3337
|
+
welcomeMsg = msg;
|
|
3338
|
+
return [3, 6];
|
|
3339
|
+
}
|
|
3340
|
+
else if (msg.type === "error") {
|
|
3341
|
+
throw new Error("Authentication failed: " + msg.reason);
|
|
3342
|
+
}
|
|
3343
|
+
else {
|
|
3344
|
+
throw new Error("Unexpected message type during authentication: " + msg.type);
|
|
3345
|
+
}
|
|
3346
|
+
case 5: return [3, 0];
|
|
3347
|
+
case 6: return [2, welcomeMsg];
|
|
3348
|
+
}
|
|
3349
|
+
});
|
|
3350
|
+
});
|
|
3351
|
+
};
|
|
3352
|
+
Connection.prototype.setupAuthConfig = function (config, reconnect) {
|
|
3353
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
3354
|
+
var authentication, _a, e_1, _b;
|
|
3355
|
+
return __generator(this, function (_c) {
|
|
3356
|
+
switch (_c.label) {
|
|
3357
|
+
case 0:
|
|
3358
|
+
authentication = {};
|
|
3359
|
+
this.gatewayToken = config.gatewayToken;
|
|
3360
|
+
if (!config.gatewayToken) return [3, 5];
|
|
3361
|
+
if (!reconnect) return [3, 4];
|
|
3362
|
+
_c.label = 1;
|
|
3363
|
+
case 1:
|
|
3364
|
+
_c.trys.push([1, 3, , 4]);
|
|
3365
|
+
_a = config;
|
|
3366
|
+
return [4, this.getNewGWToken()];
|
|
3367
|
+
case 2:
|
|
3368
|
+
_a.gatewayToken = _c.sent();
|
|
3369
|
+
return [3, 4];
|
|
3370
|
+
case 3:
|
|
3371
|
+
e_1 = _c.sent();
|
|
3372
|
+
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));
|
|
3373
|
+
return [3, 4];
|
|
3374
|
+
case 4:
|
|
3375
|
+
authentication.method = "gateway-token";
|
|
3376
|
+
authentication.token = config.gatewayToken;
|
|
3377
|
+
this.gatewayToken = config.gatewayToken;
|
|
3378
|
+
return [3, 10];
|
|
3379
|
+
case 5:
|
|
3380
|
+
if (!(config.flowName === "sspi")) return [3, 9];
|
|
3381
|
+
authentication.provider = "win";
|
|
3382
|
+
authentication.method = "access-token";
|
|
3383
|
+
if (!(config.flowCallback && config.sessionId)) return [3, 7];
|
|
3384
|
+
_b = authentication;
|
|
3385
|
+
return [4, config.flowCallback(config.sessionId, null)];
|
|
3386
|
+
case 6:
|
|
3387
|
+
_b.token =
|
|
3388
|
+
(_c.sent())
|
|
3389
|
+
.data
|
|
3390
|
+
.toString("base64");
|
|
3391
|
+
return [3, 8];
|
|
3392
|
+
case 7: throw new Error("Invalid SSPI config");
|
|
3393
|
+
case 8: return [3, 10];
|
|
3394
|
+
case 9:
|
|
3395
|
+
if (config.token) {
|
|
3396
|
+
authentication.method = "access-token";
|
|
3397
|
+
authentication.token = config.token;
|
|
3398
|
+
}
|
|
3399
|
+
else if (config.username) {
|
|
3400
|
+
authentication.method = "secret";
|
|
3401
|
+
authentication.login = config.username;
|
|
3402
|
+
authentication.secret = config.password;
|
|
3292
3403
|
}
|
|
3293
|
-
|
|
3294
|
-
|
|
3404
|
+
else if (config.provider) {
|
|
3405
|
+
authentication.provider = config.provider;
|
|
3406
|
+
authentication.providerContext = config.providerContext;
|
|
3407
|
+
}
|
|
3408
|
+
else {
|
|
3409
|
+
throw new Error("invalid auth message" + JSON.stringify(config));
|
|
3410
|
+
}
|
|
3411
|
+
_c.label = 10;
|
|
3412
|
+
case 10: return [2, authentication];
|
|
3295
3413
|
}
|
|
3296
3414
|
});
|
|
3297
3415
|
});
|
|
3298
3416
|
};
|
|
3299
|
-
Connection.prototype.
|
|
3417
|
+
Connection.prototype.logoutCore = function () {
|
|
3300
3418
|
return __awaiter(this, void 0, void 0, function () {
|
|
3419
|
+
var promises;
|
|
3301
3420
|
return __generator(this, function (_a) {
|
|
3302
3421
|
switch (_a.label) {
|
|
3303
|
-
case 0:
|
|
3422
|
+
case 0:
|
|
3423
|
+
this.logger.debug("logging out...");
|
|
3424
|
+
this.shouldTryLogin = false;
|
|
3425
|
+
if (this.pingTimer) {
|
|
3426
|
+
clearTimeout(this.pingTimer);
|
|
3427
|
+
}
|
|
3428
|
+
promises = this.sessions.map(function (session) {
|
|
3429
|
+
session.leave();
|
|
3430
|
+
});
|
|
3431
|
+
return [4, Promise.all(promises)];
|
|
3304
3432
|
case 1:
|
|
3305
|
-
_a.sent();
|
|
3306
|
-
return [4, this.transport.close()];
|
|
3307
|
-
case 2:
|
|
3308
3433
|
_a.sent();
|
|
3309
3434
|
return [2];
|
|
3310
3435
|
}
|
|
3311
3436
|
});
|
|
3312
3437
|
});
|
|
3313
3438
|
};
|
|
3314
|
-
Connection.prototype.
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
};
|
|
3320
|
-
Connection.prototype.authToken = function () {
|
|
3321
|
-
return this.protocol.authToken();
|
|
3322
|
-
};
|
|
3323
|
-
Connection.prototype.reconnect = function () {
|
|
3324
|
-
return this.transport.reconnect();
|
|
3325
|
-
};
|
|
3326
|
-
Connection.prototype.distributeMessage = function (message, type) {
|
|
3327
|
-
var _this = this;
|
|
3328
|
-
var handlers = this.messageHandlers[type.toLowerCase()];
|
|
3329
|
-
if (handlers !== undefined) {
|
|
3330
|
-
Object.keys(handlers).forEach(function (handlerId) {
|
|
3331
|
-
var handler = handlers[handlerId];
|
|
3332
|
-
if (handler !== undefined) {
|
|
3333
|
-
try {
|
|
3334
|
-
handler(message);
|
|
3335
|
-
}
|
|
3336
|
-
catch (error) {
|
|
3337
|
-
try {
|
|
3338
|
-
_this.logger.error("Message handler failed with ".concat(error.stack), error);
|
|
3339
|
-
}
|
|
3340
|
-
catch (loggerError) {
|
|
3341
|
-
console.log("Message handler failed", error);
|
|
3342
|
-
}
|
|
3343
|
-
}
|
|
3344
|
-
}
|
|
3345
|
-
});
|
|
3346
|
-
}
|
|
3347
|
-
};
|
|
3348
|
-
Connection.prototype.handleConnectionChanged = function (connected) {
|
|
3349
|
-
if (this._connected === connected) {
|
|
3350
|
-
return;
|
|
3351
|
-
}
|
|
3352
|
-
this._connected = connected;
|
|
3353
|
-
if (connected) {
|
|
3354
|
-
if (this.settings.replaySpecs && this.settings.replaySpecs.length) {
|
|
3355
|
-
this.replayer = new MessageReplayerImpl(this.settings.replaySpecs);
|
|
3356
|
-
this.replayer.init(this);
|
|
3439
|
+
Connection.prototype.getNewGWToken = function () {
|
|
3440
|
+
if (typeof window !== "undefined") {
|
|
3441
|
+
var glue42gd = window.glue42gd;
|
|
3442
|
+
if (glue42gd) {
|
|
3443
|
+
return glue42gd.getGWToken();
|
|
3357
3444
|
}
|
|
3358
|
-
this.registry.execute("connected");
|
|
3359
|
-
}
|
|
3360
|
-
else {
|
|
3361
|
-
this.registry.execute("disconnected");
|
|
3362
|
-
}
|
|
3363
|
-
};
|
|
3364
|
-
Connection.prototype.handleTransportMessage = function (msg) {
|
|
3365
|
-
var msgObj;
|
|
3366
|
-
if (typeof msg === "string") {
|
|
3367
|
-
msgObj = this.protocol.processStringMessage(msg);
|
|
3368
|
-
}
|
|
3369
|
-
else {
|
|
3370
|
-
msgObj = this.protocol.processObjectMessage(msg);
|
|
3371
3445
|
}
|
|
3372
|
-
|
|
3373
|
-
this.logger.trace("<< ".concat(JSON.stringify(msgObj)));
|
|
3374
|
-
}
|
|
3375
|
-
this.distributeMessage(msgObj.msg, msgObj.msgType);
|
|
3446
|
+
return Promise.reject(new Error("not running in GD"));
|
|
3376
3447
|
};
|
|
3377
|
-
Connection.prototype.
|
|
3448
|
+
Connection.prototype.ping = function () {
|
|
3378
3449
|
var _this = this;
|
|
3379
|
-
|
|
3380
|
-
var unsub;
|
|
3381
|
-
var ready = waitForInvocations(2, function () {
|
|
3382
|
-
if (unsub) {
|
|
3383
|
-
unsub();
|
|
3384
|
-
}
|
|
3385
|
-
resolve();
|
|
3386
|
-
});
|
|
3387
|
-
unsub = _this.onLibReAnnounced(function (lib) {
|
|
3388
|
-
if (lib.name === "interop") {
|
|
3389
|
-
return ready();
|
|
3390
|
-
}
|
|
3391
|
-
if (lib.name === "contexts") {
|
|
3392
|
-
return ready();
|
|
3393
|
-
}
|
|
3394
|
-
});
|
|
3395
|
-
}, 10000, "Transport switch timed out waiting for all libraries to be re-announced");
|
|
3396
|
-
};
|
|
3397
|
-
Connection.prototype.getNewSecondaryTransport = function (settings) {
|
|
3398
|
-
var _a;
|
|
3399
|
-
if (!((_a = settings.transportConfig) === null || _a === void 0 ? void 0 : _a.url)) {
|
|
3400
|
-
throw new Error("Missing secondary transport URL.");
|
|
3401
|
-
}
|
|
3402
|
-
return new WS(Object.assign({}, this.settings, { ws: settings.transportConfig.url, reconnectAttempts: 1 }), this.logger.subLogger("ws-secondary"));
|
|
3403
|
-
};
|
|
3404
|
-
Connection.prototype.getNewSecondaryAuth = function (settings) {
|
|
3405
|
-
var _a;
|
|
3406
|
-
if (!((_a = settings.transportConfig) === null || _a === void 0 ? void 0 : _a.auth)) {
|
|
3407
|
-
throw new Error("Missing secondary transport auth information.");
|
|
3408
|
-
}
|
|
3409
|
-
return settings.transportConfig.auth;
|
|
3410
|
-
};
|
|
3411
|
-
Connection.prototype.transportSwap = function () {
|
|
3412
|
-
this._swapTransport = false;
|
|
3413
|
-
if (!this._targetTransport || !this._targetAuth) {
|
|
3414
|
-
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."));
|
|
3450
|
+
if (!this.shouldTryLogin) {
|
|
3415
3451
|
return;
|
|
3416
3452
|
}
|
|
3417
|
-
this.
|
|
3418
|
-
|
|
3419
|
-
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
|
|
3423
|
-
this._transportSubscriptions.push(unsubOnMessage);
|
|
3424
|
-
return this._targetAuth;
|
|
3425
|
-
};
|
|
3426
|
-
Connection.prototype.prepareDefaultSwap = function () {
|
|
3427
|
-
var _this = this;
|
|
3428
|
-
this._transportSubscriptions.forEach(function (unsub) { return unsub(); });
|
|
3429
|
-
this._transportSubscriptions = [];
|
|
3430
|
-
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))); });
|
|
3431
|
-
this._targetTransport = this._defaultTransport;
|
|
3432
|
-
this._targetAuth = this._defaultAuth;
|
|
3433
|
-
this._swapTransport = true;
|
|
3453
|
+
if (this._isLoggedIn) {
|
|
3454
|
+
this.send({ type: "ping" });
|
|
3455
|
+
}
|
|
3456
|
+
this.pingTimer = setTimeout(function () {
|
|
3457
|
+
_this.ping();
|
|
3458
|
+
}, 30 * 1000);
|
|
3434
3459
|
};
|
|
3435
3460
|
return Connection;
|
|
3436
3461
|
}());
|
|
@@ -3613,7 +3638,7 @@ var ContextMessageReplaySpec = {
|
|
|
3613
3638
|
}
|
|
3614
3639
|
};
|
|
3615
3640
|
|
|
3616
|
-
var version$2 = "6.1
|
|
3641
|
+
var version$2 = "6.2.1";
|
|
3617
3642
|
|
|
3618
3643
|
function prepareConfig$1 (configuration, ext, glue42gd) {
|
|
3619
3644
|
var _a, _b, _c, _d;
|
|
@@ -5889,7 +5914,7 @@ var GW3Bridge$1 = (function () {
|
|
|
5889
5914
|
currentContext = _b.sent();
|
|
5890
5915
|
_b.label = 4;
|
|
5891
5916
|
case 4:
|
|
5892
|
-
calculatedDelta = this.
|
|
5917
|
+
calculatedDelta = this.setPathSupported ?
|
|
5893
5918
|
this.calculateContextDeltaV2(currentContext, delta) :
|
|
5894
5919
|
this.calculateContextDeltaV1(currentContext, delta);
|
|
5895
5920
|
if (!Object.keys(calculatedDelta.added).length
|
|
@@ -7394,41 +7419,46 @@ var Server = (function () {
|
|
|
7394
7419
|
return this.registerCore(methodDefinition, wrappedCallbackFunction);
|
|
7395
7420
|
};
|
|
7396
7421
|
Server.prototype.registerAsync = function (methodDefinition, callback) {
|
|
7422
|
+
var _this = this;
|
|
7397
7423
|
if (!methodDefinition) {
|
|
7398
7424
|
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.");
|
|
7399
7425
|
}
|
|
7400
7426
|
if (typeof callback !== "function") {
|
|
7401
7427
|
return Promise.reject("The second parameter must be a callback function. Method: ".concat(typeof methodDefinition === "string" ? methodDefinition : methodDefinition.name));
|
|
7402
7428
|
}
|
|
7403
|
-
var wrappedCallback = function (context, resultCallback) {
|
|
7404
|
-
|
|
7405
|
-
|
|
7406
|
-
|
|
7407
|
-
|
|
7408
|
-
|
|
7409
|
-
|
|
7410
|
-
|
|
7411
|
-
};
|
|
7412
|
-
var error = function (e) {
|
|
7413
|
-
if (!resultCalled_1) {
|
|
7414
|
-
if (!e) {
|
|
7415
|
-
e = "";
|
|
7429
|
+
var wrappedCallback = function (context, resultCallback) { return __awaiter(_this, void 0, void 0, function () {
|
|
7430
|
+
var resultCalled_1, success, error, methodResult;
|
|
7431
|
+
return __generator(this, function (_a) {
|
|
7432
|
+
try {
|
|
7433
|
+
resultCalled_1 = false;
|
|
7434
|
+
success = function (result) {
|
|
7435
|
+
if (!resultCalled_1) {
|
|
7436
|
+
resultCallback(undefined, result);
|
|
7416
7437
|
}
|
|
7417
|
-
|
|
7438
|
+
resultCalled_1 = true;
|
|
7439
|
+
};
|
|
7440
|
+
error = function (e) {
|
|
7441
|
+
if (!resultCalled_1) {
|
|
7442
|
+
if (!e) {
|
|
7443
|
+
e = "";
|
|
7444
|
+
}
|
|
7445
|
+
resultCallback(e, e);
|
|
7446
|
+
}
|
|
7447
|
+
resultCalled_1 = true;
|
|
7448
|
+
};
|
|
7449
|
+
methodResult = callback(context.args, context.instance, success, error);
|
|
7450
|
+
if (methodResult && typeof methodResult.then === "function") {
|
|
7451
|
+
methodResult
|
|
7452
|
+
.then(success)
|
|
7453
|
+
.catch(error);
|
|
7418
7454
|
}
|
|
7419
|
-
resultCalled_1 = true;
|
|
7420
|
-
};
|
|
7421
|
-
var methodResult = callback(context.args, context.instance, success, error);
|
|
7422
|
-
if (methodResult && typeof methodResult.then === "function") {
|
|
7423
|
-
methodResult
|
|
7424
|
-
.then(success)
|
|
7425
|
-
.catch(error);
|
|
7426
7455
|
}
|
|
7427
|
-
|
|
7428
|
-
|
|
7429
|
-
|
|
7430
|
-
|
|
7431
|
-
|
|
7456
|
+
catch (e) {
|
|
7457
|
+
resultCallback(e, undefined);
|
|
7458
|
+
}
|
|
7459
|
+
return [2];
|
|
7460
|
+
});
|
|
7461
|
+
}); };
|
|
7432
7462
|
wrappedCallback.userCallbackAsync = callback;
|
|
7433
7463
|
return this.registerCore(methodDefinition, wrappedCallback);
|
|
7434
7464
|
};
|
|
@@ -7539,7 +7569,7 @@ var Server = (function () {
|
|
|
7539
7569
|
return [2, Promise.reject("Please, provide a (unique) string value for the \u201Cname\u201D property in the \u201CmethodDefinition\u201D object: ".concat(JSON.stringify(method)))];
|
|
7540
7570
|
}
|
|
7541
7571
|
unregisterInProgress = this.currentlyUnregistering[methodDefinition.name];
|
|
7542
|
-
if (!unregisterInProgress) return [3, 2];
|
|
7572
|
+
if (!(typeof unregisterInProgress !== "undefined")) return [3, 2];
|
|
7543
7573
|
return [4, unregisterInProgress];
|
|
7544
7574
|
case 1:
|
|
7545
7575
|
_a.sent();
|
|
@@ -8869,10 +8899,11 @@ function gW3ProtocolFactory (instance, connection, clientRepository, serverRepos
|
|
|
8869
8899
|
var server = new ServerProtocol(session, clientRepository, serverRepository, logger.subLogger("server"));
|
|
8870
8900
|
var client = new ClientProtocol(session, clientRepository, logger.subLogger("client"));
|
|
8871
8901
|
function handleReconnect() {
|
|
8902
|
+
var _a, _b;
|
|
8872
8903
|
return __awaiter(this, void 0, void 0, function () {
|
|
8873
|
-
var reconnectionPromises, existingSubscriptions, _loop_1, _i, existingSubscriptions_1, sub, registeredMethods, _loop_2,
|
|
8874
|
-
return __generator(this, function (
|
|
8875
|
-
switch (
|
|
8904
|
+
var reconnectionPromises, existingSubscriptions, _loop_1, _i, existingSubscriptions_1, sub, registeredMethods, _loop_2, _c, registeredMethods_1, method;
|
|
8905
|
+
return __generator(this, function (_d) {
|
|
8906
|
+
switch (_d.label) {
|
|
8876
8907
|
case 0:
|
|
8877
8908
|
logger.info("reconnected - will replay registered methods and subscriptions");
|
|
8878
8909
|
client.drainSubscriptionsCache().forEach(function (sub) {
|
|
@@ -8897,25 +8928,29 @@ function gW3ProtocolFactory (instance, connection, clientRepository, serverRepos
|
|
|
8897
8928
|
serverRepository.reset();
|
|
8898
8929
|
_loop_2 = function (method) {
|
|
8899
8930
|
var def = method.definition;
|
|
8900
|
-
logger.info("re-publishing method ".concat(def.name));
|
|
8901
8931
|
if (method.stream) {
|
|
8902
|
-
reconnectionPromises.push(interop.server.createStream(def, method.streamCallbacks, undefined, undefined, method.stream)
|
|
8932
|
+
reconnectionPromises.push(interop.server.createStream(def, method.streamCallbacks, undefined, undefined, method.stream)
|
|
8933
|
+
.then(function () { return logger.info("subscribing to method ".concat(def.name, " DONE")); })
|
|
8934
|
+
.catch(function () { return logger.warn("subscribing to method ".concat(def.name, " FAILED")); }));
|
|
8903
8935
|
}
|
|
8904
|
-
else if (method
|
|
8905
|
-
reconnectionPromises.push(interop.register(def, method.theFunction.userCallback)
|
|
8936
|
+
else if ((_a = method === null || method === void 0 ? void 0 : method.theFunction) === null || _a === void 0 ? void 0 : _a.userCallback) {
|
|
8937
|
+
reconnectionPromises.push(interop.register(def, method.theFunction.userCallback)
|
|
8938
|
+
.then(function () { return logger.info("registering method ".concat(def.name, " DONE")); })
|
|
8939
|
+
.catch(function () { return logger.warn("registering method ".concat(def.name, " FAILED")); }));
|
|
8906
8940
|
}
|
|
8907
|
-
else if (method
|
|
8908
|
-
reconnectionPromises.push(interop.registerAsync(def, method.theFunction.userCallbackAsync)
|
|
8941
|
+
else if ((_b = method === null || method === void 0 ? void 0 : method.theFunction) === null || _b === void 0 ? void 0 : _b.userCallbackAsync) {
|
|
8942
|
+
reconnectionPromises.push(interop.registerAsync(def, method.theFunction.userCallbackAsync)
|
|
8943
|
+
.then(function () { return logger.info("registering method ".concat(def.name, " DONE")); })
|
|
8944
|
+
.catch(function () { return logger.warn("registering method ".concat(def.name, " FAILED")); }));
|
|
8909
8945
|
}
|
|
8910
|
-
logger.info("re-publishing method ".concat(def.name, " DONE"));
|
|
8911
8946
|
};
|
|
8912
|
-
for (
|
|
8913
|
-
method = registeredMethods_1[
|
|
8947
|
+
for (_c = 0, registeredMethods_1 = registeredMethods; _c < registeredMethods_1.length; _c++) {
|
|
8948
|
+
method = registeredMethods_1[_c];
|
|
8914
8949
|
_loop_2(method);
|
|
8915
8950
|
}
|
|
8916
8951
|
return [4, Promise.all(reconnectionPromises)];
|
|
8917
8952
|
case 1:
|
|
8918
|
-
|
|
8953
|
+
_d.sent();
|
|
8919
8954
|
logger.info("Interop is re-announced");
|
|
8920
8955
|
return [2];
|
|
8921
8956
|
}
|
|
@@ -12375,6 +12410,7 @@ const CanIMethodName = "T42.ACS.CanI";
|
|
|
12375
12410
|
const StartApplicationMethodName = "T42.ACS.StartApplication";
|
|
12376
12411
|
const StopApplicationMethodName = "T42.ACS.StopApplication";
|
|
12377
12412
|
const ActivateApplicationMethodName = "T42.ACS.ActivateApplication";
|
|
12413
|
+
const ACSExecute = "T42.ACS.Execute";
|
|
12378
12414
|
const OnEventMethodName = "T42.ACS.OnEvent";
|
|
12379
12415
|
const GetApplicationsMethodName = "T42.ACS.GetApplications";
|
|
12380
12416
|
|
|
@@ -12960,6 +12996,10 @@ class InstanceImpl {
|
|
|
12960
12996
|
getContext() {
|
|
12961
12997
|
return Promise.resolve(this.context);
|
|
12962
12998
|
}
|
|
12999
|
+
async startedBy() {
|
|
13000
|
+
const result = await this._agm.invoke(ACSExecute, { command: "getStartedBy", Name: this._appName, Id: this._id });
|
|
13001
|
+
return result.returned;
|
|
13002
|
+
}
|
|
12963
13003
|
}
|
|
12964
13004
|
|
|
12965
13005
|
class AppManagerImpl {
|
|
@@ -13016,8 +13056,9 @@ class AppManagerImpl {
|
|
|
13016
13056
|
return undefined;
|
|
13017
13057
|
};
|
|
13018
13058
|
this.getMyApplication = () => {
|
|
13059
|
+
var _a;
|
|
13019
13060
|
if (this._agm.instance) {
|
|
13020
|
-
return this.application(this._agm.instance.applicationName);
|
|
13061
|
+
return (_a = this.application(this._agm.instance.applicationName)) !== null && _a !== void 0 ? _a : this.application(this._agm.instance.application);
|
|
13021
13062
|
}
|
|
13022
13063
|
};
|
|
13023
13064
|
this.handleSnapshotAppsAdded = (newApps) => {
|
|
@@ -15886,20 +15927,15 @@ class GDExecutor {
|
|
|
15886
15927
|
}, "TabHeaderVisibilityChanged");
|
|
15887
15928
|
return w;
|
|
15888
15929
|
}
|
|
15930
|
+
async showGroupPopup(id, options) {
|
|
15931
|
+
const reformatedOptions = this.showPopupCore(id, options);
|
|
15932
|
+
await this.executeGroup("showGroupPopup", {
|
|
15933
|
+
groupId: id,
|
|
15934
|
+
options: reformatedOptions
|
|
15935
|
+
});
|
|
15936
|
+
}
|
|
15889
15937
|
async showPopup(targetWindow, options) {
|
|
15890
|
-
|
|
15891
|
-
throw new Error("The options object is not valid!");
|
|
15892
|
-
}
|
|
15893
|
-
const optionsCopy = { ...options };
|
|
15894
|
-
if (!optionsCopy.targetLocation) {
|
|
15895
|
-
optionsCopy.targetLocation = "bottom";
|
|
15896
|
-
}
|
|
15897
|
-
const reformatedOptions = {
|
|
15898
|
-
...optionsCopy,
|
|
15899
|
-
popupBounds: optionsCopy.size,
|
|
15900
|
-
targetId: targetWindow.id,
|
|
15901
|
-
popupId: optionsCopy.windowId
|
|
15902
|
-
};
|
|
15938
|
+
const reformatedOptions = this.showPopupCore(targetWindow.id, options);
|
|
15903
15939
|
await this.execute("showPopupWindow", {
|
|
15904
15940
|
windowId: targetWindow.id,
|
|
15905
15941
|
options: reformatedOptions
|
|
@@ -16396,16 +16432,33 @@ class GDExecutor {
|
|
|
16396
16432
|
return context;
|
|
16397
16433
|
}
|
|
16398
16434
|
}
|
|
16435
|
+
showPopupCore(id, options) {
|
|
16436
|
+
if (!options) {
|
|
16437
|
+
throw new Error("The options object is not valid!");
|
|
16438
|
+
}
|
|
16439
|
+
const optionsCopy = { ...options };
|
|
16440
|
+
if (!optionsCopy.targetLocation) {
|
|
16441
|
+
optionsCopy.targetLocation = "bottom";
|
|
16442
|
+
}
|
|
16443
|
+
const reformatedOptions = {
|
|
16444
|
+
...optionsCopy,
|
|
16445
|
+
popupBounds: optionsCopy.size,
|
|
16446
|
+
targetId: id,
|
|
16447
|
+
popupId: optionsCopy.windowId
|
|
16448
|
+
};
|
|
16449
|
+
return reformatedOptions;
|
|
16450
|
+
}
|
|
16399
16451
|
}
|
|
16400
16452
|
var executor = new GDExecutor();
|
|
16401
16453
|
|
|
16402
16454
|
class GDEnvironment {
|
|
16403
|
-
constructor(agm, logger, appManagerGetter, displayAPIGetter, channelsAPIGetter, wndId) {
|
|
16455
|
+
constructor(agm, logger, appManagerGetter, displayAPIGetter, channelsAPIGetter, wndId, groupId) {
|
|
16404
16456
|
this._registry = lib();
|
|
16405
16457
|
this._waitTimeout = 10000;
|
|
16406
16458
|
this._agm = agm;
|
|
16407
16459
|
this._logger = logger.subLogger("gd-env");
|
|
16408
16460
|
this._windowId = wndId;
|
|
16461
|
+
this._groupId = groupId;
|
|
16409
16462
|
this._appManagerGetter = appManagerGetter;
|
|
16410
16463
|
this._displayAPIGetter = displayAPIGetter;
|
|
16411
16464
|
this._channelsAPIGetter = channelsAPIGetter;
|
|
@@ -16480,6 +16533,9 @@ class GDEnvironment {
|
|
|
16480
16533
|
my() {
|
|
16481
16534
|
return this._windowId;
|
|
16482
16535
|
}
|
|
16536
|
+
myGroup() {
|
|
16537
|
+
return this._groupId;
|
|
16538
|
+
}
|
|
16483
16539
|
execute(command, windowId, options) {
|
|
16484
16540
|
return this._agm.invoke("T42.Wnd.Execute", {
|
|
16485
16541
|
command,
|
|
@@ -16774,6 +16830,7 @@ class GDEnvironment {
|
|
|
16774
16830
|
}
|
|
16775
16831
|
|
|
16776
16832
|
var envDetector = (agm, logger, appManagerGetter, displayAPIGetter, channelsAPIGetter, gdMajorVersion) => {
|
|
16833
|
+
var _a;
|
|
16777
16834
|
const _logger = logger;
|
|
16778
16835
|
if (gdMajorVersion === 2) {
|
|
16779
16836
|
_logger.trace("running in HC");
|
|
@@ -16781,7 +16838,7 @@ var envDetector = (agm, logger, appManagerGetter, displayAPIGetter, channelsAPIG
|
|
|
16781
16838
|
}
|
|
16782
16839
|
else if (gdMajorVersion >= 3) {
|
|
16783
16840
|
_logger.trace("running in GD 3");
|
|
16784
|
-
return new GDEnvironment(agm, _logger, appManagerGetter, displayAPIGetter, channelsAPIGetter, window.glue42gd.windowId).init();
|
|
16841
|
+
return new GDEnvironment(agm, _logger, appManagerGetter, displayAPIGetter, channelsAPIGetter, window.glue42gd.windowId, (_a = window.webGroupsManager) === null || _a === void 0 ? void 0 : _a.id).init();
|
|
16785
16842
|
}
|
|
16786
16843
|
else {
|
|
16787
16844
|
return new GDEnvironment(agm, _logger, appManagerGetter, displayAPIGetter, channelsAPIGetter).init();
|
|
@@ -16973,6 +17030,14 @@ var groupFactory = (id, executor) => {
|
|
|
16973
17030
|
groupId: id
|
|
16974
17031
|
});
|
|
16975
17032
|
},
|
|
17033
|
+
close: () => {
|
|
17034
|
+
return executor.executeGroup("closeGroup", {
|
|
17035
|
+
groupId: id
|
|
17036
|
+
});
|
|
17037
|
+
},
|
|
17038
|
+
showPopup: (options) => {
|
|
17039
|
+
return executor.showGroupPopup(id, options);
|
|
17040
|
+
},
|
|
16976
17041
|
onHeaderVisibilityChanged,
|
|
16977
17042
|
onWindowAdded,
|
|
16978
17043
|
onWindowRemoved,
|
|
@@ -17039,20 +17104,55 @@ var groupsFactory = (environment, logger) => {
|
|
|
17039
17104
|
environment.onGroupStateChanged((data) => {
|
|
17040
17105
|
const groupWrapper = _groups[data.groupId];
|
|
17041
17106
|
if (data.state === "hibernated") {
|
|
17042
|
-
if (groupWrapper
|
|
17107
|
+
if (groupWrapper === null || groupWrapper === void 0 ? void 0 : groupWrapper.groupAPI) {
|
|
17043
17108
|
groupWrapper.groupInternal.handleGroupHibernateChanged(true);
|
|
17044
17109
|
}
|
|
17045
17110
|
_registry.execute("group-hibernated", data.groupId);
|
|
17046
17111
|
}
|
|
17047
17112
|
else if (data.state === "resumed") {
|
|
17048
|
-
if (groupWrapper
|
|
17113
|
+
if (groupWrapper === null || groupWrapper === void 0 ? void 0 : groupWrapper.groupAPI) {
|
|
17049
17114
|
groupWrapper.groupInternal.handleGroupHibernateChanged(false);
|
|
17050
17115
|
}
|
|
17051
17116
|
_registry.execute("group-resumed", groupWrapper.groupAPI);
|
|
17052
17117
|
}
|
|
17053
17118
|
});
|
|
17054
17119
|
function my() {
|
|
17055
|
-
|
|
17120
|
+
var _a;
|
|
17121
|
+
return findGroupByWindow((_a = environment.myGroup()) !== null && _a !== void 0 ? _a : environment.my());
|
|
17122
|
+
}
|
|
17123
|
+
async function create(options) {
|
|
17124
|
+
if (isUndefinedOrNull(options)) {
|
|
17125
|
+
throw new Error(`options must be defined`);
|
|
17126
|
+
}
|
|
17127
|
+
if (isUndefinedOrNull(options.groups) || !Array.isArray(options.groups) || options.groups.length === 0) {
|
|
17128
|
+
throw new Error(`options.groups must be defined`);
|
|
17129
|
+
}
|
|
17130
|
+
const { groupIds } = await executor.executeGroup("createGroups", {
|
|
17131
|
+
options
|
|
17132
|
+
});
|
|
17133
|
+
const groups = groupIds.map((groupId) => {
|
|
17134
|
+
return waitForGroup(groupId);
|
|
17135
|
+
});
|
|
17136
|
+
return Promise.all(groups);
|
|
17137
|
+
}
|
|
17138
|
+
async function close(idOrGroup, options) {
|
|
17139
|
+
if (isUndefinedOrNull(idOrGroup)) {
|
|
17140
|
+
throw new Error(`group must be defined`);
|
|
17141
|
+
}
|
|
17142
|
+
let groupId = "";
|
|
17143
|
+
if (typeof idOrGroup === "string") {
|
|
17144
|
+
groupId = idOrGroup;
|
|
17145
|
+
}
|
|
17146
|
+
else {
|
|
17147
|
+
groupId = idOrGroup.id;
|
|
17148
|
+
}
|
|
17149
|
+
if (isUndefinedOrNull(options)) {
|
|
17150
|
+
throw new Error(`options must be defined`);
|
|
17151
|
+
}
|
|
17152
|
+
await executor.executeGroup("closeGroup", {
|
|
17153
|
+
groupId,
|
|
17154
|
+
options
|
|
17155
|
+
});
|
|
17056
17156
|
}
|
|
17057
17157
|
function list(success) {
|
|
17058
17158
|
const result = Object.keys(_groups).map((groupId) => {
|
|
@@ -17084,15 +17184,13 @@ var groupsFactory = (environment, logger) => {
|
|
|
17084
17184
|
}
|
|
17085
17185
|
return result.groupAPI;
|
|
17086
17186
|
}
|
|
17087
|
-
else {
|
|
17088
|
-
|
|
17089
|
-
error(`Cannot find the group of the window.`);
|
|
17090
|
-
}
|
|
17187
|
+
else if (typeof error === "function") {
|
|
17188
|
+
error(`Cannot find the group of the window.`);
|
|
17091
17189
|
}
|
|
17092
17190
|
}
|
|
17093
17191
|
function waitForGroup(groupId) {
|
|
17094
17192
|
if (!groupId) {
|
|
17095
|
-
return Promise.reject(`groupId must be defined`);
|
|
17193
|
+
return Promise.reject(new Error(`groupId must be defined`));
|
|
17096
17194
|
}
|
|
17097
17195
|
return new Promise((res, rej) => {
|
|
17098
17196
|
const groupWrapper = _groups[groupId];
|
|
@@ -17109,6 +17207,10 @@ var groupsFactory = (environment, logger) => {
|
|
|
17109
17207
|
}
|
|
17110
17208
|
});
|
|
17111
17209
|
}
|
|
17210
|
+
function getMyGroup() {
|
|
17211
|
+
var _a;
|
|
17212
|
+
return waitForGroup((_a = environment.myGroup()) !== null && _a !== void 0 ? _a : environment.my());
|
|
17213
|
+
}
|
|
17112
17214
|
async function resume(groupId, activate) {
|
|
17113
17215
|
if (!isUndefinedOrNull(activate) && !isBoolean(activate)) {
|
|
17114
17216
|
throw new Error("Activate flag must be a boolean!");
|
|
@@ -17230,9 +17332,12 @@ var groupsFactory = (environment, logger) => {
|
|
|
17230
17332
|
get my() {
|
|
17231
17333
|
return my();
|
|
17232
17334
|
},
|
|
17335
|
+
create,
|
|
17336
|
+
close,
|
|
17233
17337
|
list,
|
|
17234
17338
|
findGroupByWindow,
|
|
17235
17339
|
waitForGroup,
|
|
17340
|
+
getMyGroup,
|
|
17236
17341
|
onGroupAdded,
|
|
17237
17342
|
onGroupRemoved,
|
|
17238
17343
|
hibernate,
|
|
@@ -18395,6 +18500,36 @@ async function switchChannel(channel, id) {
|
|
|
18395
18500
|
data: { newChannel: channel }
|
|
18396
18501
|
});
|
|
18397
18502
|
}
|
|
18503
|
+
async function setRestrictions(restrictions) {
|
|
18504
|
+
var _a;
|
|
18505
|
+
await interop.invoke(T42_ANNOUNCE_METHOD_NAME, {
|
|
18506
|
+
swId: (_a = restrictions.windowId) !== null && _a !== void 0 ? _a : windowId,
|
|
18507
|
+
command: "restrict",
|
|
18508
|
+
data: restrictions
|
|
18509
|
+
});
|
|
18510
|
+
return;
|
|
18511
|
+
}
|
|
18512
|
+
async function getRestrictionsByWindow(id) {
|
|
18513
|
+
try {
|
|
18514
|
+
const result = await interop.invoke(T42_ANNOUNCE_METHOD_NAME, {
|
|
18515
|
+
swId: id !== null && id !== void 0 ? id : windowId,
|
|
18516
|
+
command: "getRestrictions"
|
|
18517
|
+
});
|
|
18518
|
+
return result.returned;
|
|
18519
|
+
}
|
|
18520
|
+
catch (e) {
|
|
18521
|
+
return;
|
|
18522
|
+
}
|
|
18523
|
+
}
|
|
18524
|
+
async function setRestrictionsForAllChannels(restrictions) {
|
|
18525
|
+
var _a;
|
|
18526
|
+
await interop.invoke(T42_ANNOUNCE_METHOD_NAME, {
|
|
18527
|
+
swId: (_a = restrictions.windowId) !== null && _a !== void 0 ? _a : windowId,
|
|
18528
|
+
command: "restrictAll",
|
|
18529
|
+
data: restrictions
|
|
18530
|
+
});
|
|
18531
|
+
return;
|
|
18532
|
+
}
|
|
18398
18533
|
async function getWindowsWithChannels(filter) {
|
|
18399
18534
|
const result = await interop.invoke(T42_ANNOUNCE_METHOD_NAME, { command: "getChannelsInfo", data: { filter } });
|
|
18400
18535
|
return result.returned;
|
|
@@ -18535,19 +18670,25 @@ class ChannelsImpl {
|
|
|
18535
18670
|
}
|
|
18536
18671
|
const id = Utils.generateId();
|
|
18537
18672
|
this.pendingReplays[id] = true;
|
|
18673
|
+
const callbackWithPermissionCheck = async (data, context, updaterId) => {
|
|
18674
|
+
const canRead = await this.canReadFromChannel(context.name);
|
|
18675
|
+
if (canRead) {
|
|
18676
|
+
callback(data, context, updaterId);
|
|
18677
|
+
}
|
|
18678
|
+
};
|
|
18538
18679
|
if (this.lastUpdate) {
|
|
18539
18680
|
let lastUpdate = Object.assign({}, this.lastUpdate);
|
|
18540
|
-
setTimeout(() => {
|
|
18681
|
+
setTimeout(async () => {
|
|
18541
18682
|
if (this.pendingReplays[id]) {
|
|
18542
18683
|
if (this.lastUpdate) {
|
|
18543
18684
|
lastUpdate = this.lastUpdate;
|
|
18544
18685
|
}
|
|
18545
|
-
|
|
18686
|
+
callbackWithPermissionCheck(lastUpdate.context.data, lastUpdate.context, lastUpdate.updaterId);
|
|
18546
18687
|
}
|
|
18547
18688
|
delete this.pendingReplays[id];
|
|
18548
18689
|
}, 0);
|
|
18549
18690
|
}
|
|
18550
|
-
const unsub = this.registry.add(this.subsKey,
|
|
18691
|
+
const unsub = this.registry.add(this.subsKey, callbackWithPermissionCheck);
|
|
18551
18692
|
return () => {
|
|
18552
18693
|
this.pendingReplays[id] = false;
|
|
18553
18694
|
unsub();
|
|
@@ -18574,11 +18715,17 @@ class ChannelsImpl {
|
|
|
18574
18715
|
if (!this.shared.isChannel(name)) {
|
|
18575
18716
|
return Promise.reject(new Error(`A channel with name: ${name} doesn't exist!`));
|
|
18576
18717
|
}
|
|
18718
|
+
if (!await this.canWriteToChannel(name)) {
|
|
18719
|
+
throw new Error(`Window does not have permission to write to channel ${name}`);
|
|
18720
|
+
}
|
|
18577
18721
|
return this.shared.updateData(name, data);
|
|
18578
18722
|
}
|
|
18579
18723
|
if (!this.currentContext) {
|
|
18580
18724
|
throw new Error("Not joined to any channel!");
|
|
18581
18725
|
}
|
|
18726
|
+
if (!await this.canWriteToChannel(this.currentContext)) {
|
|
18727
|
+
throw new Error(`Window does not have permission to write to channel ${this.currentContext}`);
|
|
18728
|
+
}
|
|
18582
18729
|
return this.shared.updateData(this.currentContext, data);
|
|
18583
18730
|
}
|
|
18584
18731
|
all() {
|
|
@@ -18706,6 +18853,15 @@ class ChannelsImpl {
|
|
|
18706
18853
|
}
|
|
18707
18854
|
return [];
|
|
18708
18855
|
}
|
|
18856
|
+
async restrict(restriction) {
|
|
18857
|
+
return setRestrictions(restriction);
|
|
18858
|
+
}
|
|
18859
|
+
async getRestrictions(windowId) {
|
|
18860
|
+
return getRestrictionsByWindow(windowId);
|
|
18861
|
+
}
|
|
18862
|
+
async restrictAll(restriction) {
|
|
18863
|
+
return setRestrictionsForAllChannels(restriction);
|
|
18864
|
+
}
|
|
18709
18865
|
handler(data, context, updaterId) {
|
|
18710
18866
|
if (!context && !updaterId) {
|
|
18711
18867
|
this.lastUpdate = undefined;
|
|
@@ -18760,6 +18916,22 @@ class ChannelsImpl {
|
|
|
18760
18916
|
}
|
|
18761
18917
|
return Promise.resolve();
|
|
18762
18918
|
}
|
|
18919
|
+
async canReadFromChannel(channelName) {
|
|
18920
|
+
const restrictions = await getRestrictionsByWindow();
|
|
18921
|
+
if (!restrictions || !Array.isArray(restrictions.channels) || !restrictions.channels.find(c => c.name === channelName)) {
|
|
18922
|
+
return true;
|
|
18923
|
+
}
|
|
18924
|
+
const byChannel = restrictions.channels.find(c => c.name === channelName);
|
|
18925
|
+
return byChannel.read;
|
|
18926
|
+
}
|
|
18927
|
+
async canWriteToChannel(channelName) {
|
|
18928
|
+
const restrictions = await getRestrictionsByWindow();
|
|
18929
|
+
if (!restrictions || !Array.isArray(restrictions.channels) || !restrictions.channels.find(c => c.name === channelName)) {
|
|
18930
|
+
return true;
|
|
18931
|
+
}
|
|
18932
|
+
const byChannel = restrictions.channels.find(c => c.name === channelName);
|
|
18933
|
+
return byChannel.write;
|
|
18934
|
+
}
|
|
18763
18935
|
}
|
|
18764
18936
|
|
|
18765
18937
|
function factory$4(contexts, agm, getWindows, logger) {
|
|
@@ -18775,6 +18947,9 @@ function factory$4(contexts, agm, getWindows, logger) {
|
|
|
18775
18947
|
get: channels.get.bind(channels),
|
|
18776
18948
|
join: channels.join.bind(channels),
|
|
18777
18949
|
leave: channels.leave.bind(channels),
|
|
18950
|
+
restrict: channels.restrict.bind(channels),
|
|
18951
|
+
getRestrictions: channels.getRestrictions.bind(channels),
|
|
18952
|
+
restrictAll: channels.restrictAll.bind(channels),
|
|
18778
18953
|
current: channels.current.bind(channels),
|
|
18779
18954
|
my: channels.my.bind(channels),
|
|
18780
18955
|
changed: channels.changed.bind(channels),
|
|
@@ -18878,7 +19053,7 @@ function factory$3(agm) {
|
|
|
18878
19053
|
};
|
|
18879
19054
|
}
|
|
18880
19055
|
|
|
18881
|
-
var version = "6.
|
|
19056
|
+
var version = "6.4.0";
|
|
18882
19057
|
|
|
18883
19058
|
var prepareConfig = (options) => {
|
|
18884
19059
|
function getLibConfig(value, defaultMode, trueMode) {
|
|
@@ -19028,13 +19203,14 @@ class Notifications {
|
|
|
19028
19203
|
this.subscriptionsCountForCounter = 0;
|
|
19029
19204
|
this.logger = logger.subLogger("notifications");
|
|
19030
19205
|
this._panel = new PanelAPI(interop, this.onStreamEventCore.bind(this));
|
|
19206
|
+
this._panelAPI = this._panel.toAPI();
|
|
19031
19207
|
this.subscribeInternalEvents();
|
|
19032
19208
|
}
|
|
19033
19209
|
get maxActions() {
|
|
19034
19210
|
return 2;
|
|
19035
19211
|
}
|
|
19036
19212
|
get panel() {
|
|
19037
|
-
return this.
|
|
19213
|
+
return this._panelAPI;
|
|
19038
19214
|
}
|
|
19039
19215
|
async raise(options) {
|
|
19040
19216
|
var _a, _b, _c, _d;
|
|
@@ -19141,7 +19317,7 @@ class Notifications {
|
|
|
19141
19317
|
return result.returned;
|
|
19142
19318
|
}
|
|
19143
19319
|
async list() {
|
|
19144
|
-
const interopResult = await this.interop.invoke(this.NotificationsExecuteMethod, { command: "list" });
|
|
19320
|
+
const interopResult = await this.interop.invoke(this.NotificationsExecuteMethod, { command: "list", data: { statesVersion2: true } });
|
|
19145
19321
|
return interopResult.returned.notifications;
|
|
19146
19322
|
}
|
|
19147
19323
|
async updateData(id, data) {
|
|
@@ -19201,7 +19377,7 @@ class Notifications {
|
|
|
19201
19377
|
await this.interop.invoke(this.NotificationsExecuteMethod, { command: "clearAll" });
|
|
19202
19378
|
}
|
|
19203
19379
|
async clearOld() {
|
|
19204
|
-
await this.interop.invoke(this.NotificationsExecuteMethod, { command: "clearAllOld" });
|
|
19380
|
+
await this.interop.invoke(this.NotificationsExecuteMethod, { command: "clearAllOld", data: { statesVersion2: true } });
|
|
19205
19381
|
}
|
|
19206
19382
|
async clear(id) {
|
|
19207
19383
|
if (!id) {
|
|
@@ -19215,6 +19391,9 @@ class Notifications {
|
|
|
19215
19391
|
async click(id, action, options) {
|
|
19216
19392
|
await this.interop.invoke(this.NotificationsExecuteMethod, { command: "click", data: { id, action, options } });
|
|
19217
19393
|
}
|
|
19394
|
+
async snooze(id, duration) {
|
|
19395
|
+
await this.interop.invoke(this.NotificationsExecuteMethod, { command: "snooze", data: { id, duration } });
|
|
19396
|
+
}
|
|
19218
19397
|
async setState(id, state) {
|
|
19219
19398
|
if (!id) {
|
|
19220
19399
|
throw new Error("The 'id' argument cannot be null or undefined");
|
|
@@ -19250,6 +19429,7 @@ class Notifications {
|
|
|
19250
19429
|
click: this.click.bind(this),
|
|
19251
19430
|
setState: this.setState.bind(this),
|
|
19252
19431
|
updateData: this.updateData.bind(this),
|
|
19432
|
+
snooze: this.snooze.bind(this)
|
|
19253
19433
|
};
|
|
19254
19434
|
}
|
|
19255
19435
|
onStreamEventCore(key, callback) {
|
|
@@ -19360,7 +19540,8 @@ class Notifications {
|
|
|
19360
19540
|
this.interop
|
|
19361
19541
|
.subscribe(this.NotificationsSubscribeStream, {
|
|
19362
19542
|
arguments: {
|
|
19363
|
-
sendDeltaOnly: true
|
|
19543
|
+
sendDeltaOnly: true,
|
|
19544
|
+
statesVersion2: true
|
|
19364
19545
|
}
|
|
19365
19546
|
})
|
|
19366
19547
|
.then((sub) => {
|
|
@@ -20384,7 +20565,7 @@ class Intents {
|
|
|
20384
20565
|
this.intentsResolverResponsePromises[instanceId] = { intent, resolve, reject, promise, methodName: responseMethodName };
|
|
20385
20566
|
}
|
|
20386
20567
|
async invokeStartApp(application, context, options) {
|
|
20387
|
-
const result = await this.interop.invoke("T42.ACS.StartApplication", { Name: application, options });
|
|
20568
|
+
const result = await this.interop.invoke("T42.ACS.StartApplication", { Name: application, options: { ...options, startedByIntentAPI: true } });
|
|
20388
20569
|
return result.returned.Id;
|
|
20389
20570
|
}
|
|
20390
20571
|
subscribeOnInstanceStopped(instance, method) {
|
|
@@ -20913,7 +21094,7 @@ const factoryCore = async (options, glue42gd) => {
|
|
|
20913
21094
|
}
|
|
20914
21095
|
function createPrefs(core) {
|
|
20915
21096
|
var _a, _b;
|
|
20916
|
-
const appName = (_b = (_a = options.application) !== null && _a !== void 0 ? _a : glue42gd === null || glue42gd === void 0 ? void 0 : glue42gd.
|
|
21097
|
+
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;
|
|
20917
21098
|
const prefs = new Prefs(appName, core.interop);
|
|
20918
21099
|
debugLog(prefs);
|
|
20919
21100
|
return prefs;
|