@ibm-aspera/sdk 0.2.12 → 0.2.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commonjs/app/core.js +5 -5
- package/dist/commonjs/helpers/ws.js +8 -23
- package/dist/commonjs/http-gateway/download.js +2 -1
- package/dist/commonjs/models/aspera-sdk.model.js +40 -7
- package/dist/js/aspera-sdk.js +1 -1
- package/dist/js/aspera-sdk.js.LICENSE.txt +1 -1
- package/dist/js/aspera-sdk.js.map +1 -1
- package/package.json +8 -4
- package/.whitesource +0 -3
|
@@ -77,9 +77,8 @@ exports.initDragDrop = initDragDrop;
|
|
|
77
77
|
* rejects if unable to connect
|
|
78
78
|
*/
|
|
79
79
|
var init = function (options) {
|
|
80
|
-
var _a, _b, _c
|
|
80
|
+
var _a, _b, _c;
|
|
81
81
|
var appId = (_a = options === null || options === void 0 ? void 0 : options.appId) !== null && _a !== void 0 ? _a : (0, helpers_1.randomUUID)();
|
|
82
|
-
var supportMultipleUsers = (_b = options === null || options === void 0 ? void 0 : options.supportMultipleUsers) !== null && _b !== void 0 ? _b : false;
|
|
83
82
|
index_1.asperaSdk.globals.appId = appId;
|
|
84
83
|
// Watch for old HTTP Gateway transfers in case used.
|
|
85
84
|
(0, http_gateway_sdk_js_1.registerActivityCallback)(function (oldHttpTransfers) {
|
|
@@ -87,7 +86,8 @@ var init = function (options) {
|
|
|
87
86
|
(0, core_1.sendTransferUpdate)(oldHttpTransfer);
|
|
88
87
|
});
|
|
89
88
|
});
|
|
90
|
-
|
|
89
|
+
// For now ignore multi user support in Safari
|
|
90
|
+
if ((options === null || options === void 0 ? void 0 : options.supportMultipleUsers) && !(0, helpers_1.isSafari)()) {
|
|
91
91
|
index_1.asperaSdk.globals.supportMultipleUsers = true;
|
|
92
92
|
index_1.asperaSdk.globals.sessionId = (0, helpers_1.randomUUID)();
|
|
93
93
|
}
|
|
@@ -120,7 +120,7 @@ var init = function (options) {
|
|
|
120
120
|
.then(function () { return index_1.asperaSdk.globals.sdkResponseData; })
|
|
121
121
|
.catch(handleErrors);
|
|
122
122
|
};
|
|
123
|
-
if (((
|
|
123
|
+
if (((_b = options === null || options === void 0 ? void 0 : options.httpGatewaySettings) === null || _b === void 0 ? void 0 : _b.url) && !index_1.asperaSdk.globals.httpGatewayVerified) {
|
|
124
124
|
var finalHttpGatewayUrl = options.httpGatewaySettings.url.trim();
|
|
125
125
|
if (finalHttpGatewayUrl.indexOf('http') !== 0) {
|
|
126
126
|
finalHttpGatewayUrl = "https://".concat(finalHttpGatewayUrl);
|
|
@@ -158,7 +158,7 @@ var init = function (options) {
|
|
|
158
158
|
return ((_a = options === null || options === void 0 ? void 0 : options.connectSettings) === null || _a === void 0 ? void 0 : _a.useConnect) ? getConnectStartCalls() : getDesktopStartCalls();
|
|
159
159
|
});
|
|
160
160
|
}
|
|
161
|
-
return ((
|
|
161
|
+
return ((_c = options === null || options === void 0 ? void 0 : options.connectSettings) === null || _c === void 0 ? void 0 : _c.useConnect) ? getConnectStartCalls() : getDesktopStartCalls();
|
|
162
162
|
};
|
|
163
163
|
exports.init = init;
|
|
164
164
|
/**
|
|
@@ -109,7 +109,7 @@ var WebsocketService = /** @class */ (function () {
|
|
|
109
109
|
};
|
|
110
110
|
WebsocketService.prototype.connect = function () {
|
|
111
111
|
var _this = this;
|
|
112
|
-
this.getWebSocketConnection(
|
|
112
|
+
this.getWebSocketConnection(index_1.asperaSdk.globals.rpcPort)
|
|
113
113
|
.then(function (webSocket) {
|
|
114
114
|
_this.globalSocket = webSocket;
|
|
115
115
|
_this.globalSocket.onerror = _this.handleError;
|
|
@@ -130,31 +130,16 @@ var WebsocketService = /** @class */ (function () {
|
|
|
130
130
|
_this.connect();
|
|
131
131
|
}, 1000);
|
|
132
132
|
};
|
|
133
|
-
WebsocketService.prototype.getWebSocketConnection = function (
|
|
133
|
+
WebsocketService.prototype.getWebSocketConnection = function (port) {
|
|
134
134
|
var webSocketUrl = (0, helpers_1.getWebsocketUrl)(index_1.asperaSdk.globals.asperaAppUrl);
|
|
135
|
-
var checkPort = function (port) {
|
|
136
|
-
return new Promise(function (resolve, reject) {
|
|
137
|
-
var webSocket = new WebSocket("".concat(webSocketUrl, ":").concat(port));
|
|
138
|
-
webSocket.onopen = function () {
|
|
139
|
-
resolve(webSocket);
|
|
140
|
-
};
|
|
141
|
-
webSocket.onerror = function () {
|
|
142
|
-
reject("Connection failed on port ".concat(port));
|
|
143
|
-
};
|
|
144
|
-
});
|
|
145
|
-
};
|
|
146
135
|
return new Promise(function (resolve, reject) {
|
|
147
|
-
var
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
.catch(function (error) {
|
|
154
|
-
connectPort(port + 1);
|
|
155
|
-
});
|
|
136
|
+
var webSocket = new WebSocket("".concat(webSocketUrl, ":").concat(port));
|
|
137
|
+
webSocket.onopen = function () {
|
|
138
|
+
resolve(webSocket);
|
|
139
|
+
};
|
|
140
|
+
webSocket.onerror = function () {
|
|
141
|
+
reject("Connection failed on port ".concat(port));
|
|
156
142
|
};
|
|
157
|
-
connectPort(startPort);
|
|
158
143
|
});
|
|
159
144
|
};
|
|
160
145
|
WebsocketService.prototype.notifyEvent = function (event) {
|
|
@@ -39,13 +39,14 @@ var httpDownloadPresigned = function (transferSpec, asperaSdkSpec) {
|
|
|
39
39
|
headers['Authorization'] = "Bearer ".concat(asperaSdkSpec.http_gateway_authentication.token);
|
|
40
40
|
headers['X-Aspera-AccessKey'] = asperaSdkSpec.http_gateway_authentication.access_key;
|
|
41
41
|
}
|
|
42
|
+
var protocol = url.protocol === 'https:' ? 'https' : 'http';
|
|
42
43
|
return fetch("".concat(url.toString(), "/presign"), {
|
|
43
44
|
method: 'POST',
|
|
44
45
|
headers: headers,
|
|
45
46
|
body: (0, helpers_1.safeJsonString)({
|
|
46
47
|
transfer_spec: transferSpec,
|
|
47
48
|
method: 'GET',
|
|
48
|
-
protocol:
|
|
49
|
+
protocol: protocol,
|
|
49
50
|
headers: {
|
|
50
51
|
host: url.host,
|
|
51
52
|
},
|
|
@@ -15,6 +15,7 @@ exports.AsperaSdk = exports.ActivityTracking = void 0;
|
|
|
15
15
|
var constants_1 = require("../constants/constants");
|
|
16
16
|
var messages_1 = require("../constants/messages");
|
|
17
17
|
var safari_client_1 = require("../helpers/client/safari-client");
|
|
18
|
+
var client_1 = require("../helpers/client/client");
|
|
18
19
|
var helpers_1 = require("../helpers/helpers");
|
|
19
20
|
var ws_1 = require("../helpers/ws");
|
|
20
21
|
var index_1 = require("../index");
|
|
@@ -175,14 +176,46 @@ var ActivityTracking = /** @class */ (function () {
|
|
|
175
176
|
if (index_1.asperaSdk.globals.sessionId) {
|
|
176
177
|
this.registerDesktopAppSession();
|
|
177
178
|
}
|
|
178
|
-
|
|
179
|
-
|
|
179
|
+
var finalCall = function () {
|
|
180
|
+
if ((0, helpers_1.isSafari)()) {
|
|
181
|
+
return safari_client_1.safariClient.monitorTransferActivity();
|
|
182
|
+
}
|
|
183
|
+
return ws_1.websocketService.init()
|
|
184
|
+
.then(function () {
|
|
185
|
+
ws_1.websocketService.registerMessage('transfer_activity', function (data) { return _this.handleTransferActivity(data); });
|
|
186
|
+
ws_1.websocketService.registerEvent(function (status) { return _this.handleWebSocketEvents(status); });
|
|
187
|
+
});
|
|
188
|
+
};
|
|
189
|
+
if (index_1.asperaSdk.globals.supportMultipleUsers) {
|
|
190
|
+
var retryCount_1 = 0;
|
|
191
|
+
var makeVerifyCall_1 = function (incrementIt) {
|
|
192
|
+
if (incrementIt) {
|
|
193
|
+
index_1.asperaSdk.globals.rpcPort = index_1.asperaSdk.globals.rpcPort + 1;
|
|
194
|
+
}
|
|
195
|
+
if (index_1.asperaSdk.globals.rpcPort > 33029) {
|
|
196
|
+
retryCount_1++;
|
|
197
|
+
index_1.asperaSdk.globals.rpcPort = 33024;
|
|
198
|
+
return new Promise(function (resolve) { return setTimeout(resolve, retryCount_1 * 1050); }).then(function () { return makeVerifyCall_1(false); });
|
|
199
|
+
}
|
|
200
|
+
return client_1.client.request('verify_session', { app_id: index_1.asperaSdk.globals.appId, session_id: index_1.asperaSdk.globals.sessionId })
|
|
201
|
+
.then(function (data) {
|
|
202
|
+
if (data.result) {
|
|
203
|
+
return finalCall();
|
|
204
|
+
}
|
|
205
|
+
return makeVerifyCall_1(true);
|
|
206
|
+
}).catch(function () {
|
|
207
|
+
if (retryCount_1 > 5) {
|
|
208
|
+
index_1.asperaSdk.globals.rpcPort = 33024;
|
|
209
|
+
return Promise.reject('Unable to find port running for session');
|
|
210
|
+
}
|
|
211
|
+
return makeVerifyCall_1(true);
|
|
212
|
+
});
|
|
213
|
+
};
|
|
214
|
+
return makeVerifyCall_1(false);
|
|
215
|
+
}
|
|
216
|
+
else {
|
|
217
|
+
return finalCall();
|
|
180
218
|
}
|
|
181
|
-
return ws_1.websocketService.init()
|
|
182
|
-
.then(function () {
|
|
183
|
-
ws_1.websocketService.registerMessage('transfer_activity', function (data) { return _this.handleTransferActivity(data); });
|
|
184
|
-
ws_1.websocketService.registerEvent(function (status) { return _this.handleWebSocketEvents(status); });
|
|
185
|
-
});
|
|
186
219
|
};
|
|
187
220
|
/**
|
|
188
221
|
* Register a callback for getting transfers back to the consumer
|