@ibm-aspera/sdk 0.19.0 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commonjs/app/core.d.ts +43 -17
- package/dist/commonjs/app/core.js +144 -28
- package/dist/commonjs/app/status.d.ts +11 -1
- package/dist/commonjs/app/status.js +35 -4
- package/dist/commonjs/connect/core.js +3 -0
- package/dist/commonjs/helpers/connect-extension.d.ts +8 -0
- package/dist/commonjs/helpers/connect-extension.js +58 -0
- package/dist/commonjs/helpers/helpers.d.ts +6 -0
- package/dist/commonjs/helpers/helpers.js +19 -1
- package/dist/commonjs/helpers/ws.d.ts +16 -0
- package/dist/commonjs/helpers/ws.js +49 -2
- package/dist/commonjs/http-gateway/core.js +10 -12
- package/dist/commonjs/http-gateway/download.js +2 -2
- package/dist/commonjs/http-gateway/upload.js +2 -2
- package/dist/commonjs/http-gateway/v2/app/core.d.ts +84 -0
- package/dist/commonjs/http-gateway/v2/app/core.js +170 -0
- package/dist/commonjs/http-gateway/v2/app/download.d.ts +15 -0
- package/dist/commonjs/http-gateway/v2/app/download.js +68 -0
- package/dist/commonjs/http-gateway/v2/app/upload.d.ts +169 -0
- package/dist/commonjs/http-gateway/v2/app/upload.js +601 -0
- package/dist/commonjs/http-gateway/v2/constants/constants.d.ts +6 -0
- package/dist/commonjs/http-gateway/v2/constants/constants.js +9 -0
- package/dist/commonjs/http-gateway/v2/constants/messages.d.ts +35 -0
- package/dist/commonjs/http-gateway/v2/constants/messages.js +38 -0
- package/dist/commonjs/http-gateway/v2/helpers/helpers.d.ts +121 -0
- package/dist/commonjs/http-gateway/v2/helpers/helpers.js +294 -0
- package/dist/commonjs/http-gateway/v2/helpers/http.d.ts +86 -0
- package/dist/commonjs/http-gateway/v2/helpers/http.js +153 -0
- package/dist/commonjs/http-gateway/v2/index.d.ts +35 -0
- package/dist/commonjs/http-gateway/v2/index.js +70 -0
- package/dist/commonjs/http-gateway/v2/models/http-gateway-global.model.d.ts +254 -0
- package/dist/commonjs/http-gateway/v2/models/http-gateway-global.model.js +367 -0
- package/dist/commonjs/http-gateway/v2/models/models.d.ts +127 -0
- package/dist/commonjs/http-gateway/v2/models/models.js +87 -0
- package/dist/commonjs/index.d.ts +3 -3
- package/dist/commonjs/index.js +3 -1
- package/dist/commonjs/models/aspera-sdk.model.d.ts +2 -1
- package/dist/commonjs/models/aspera-sdk.model.js +8 -0
- package/dist/commonjs/models/models.d.ts +10 -1
- 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 +1 -2
- package/scripts/release.sh +7 -7
- package/scripts/version.sh +24 -15
|
@@ -0,0 +1,367 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HttpGateway = exports.ActivityTracking = exports.TransferResponse = exports.ServerInfo = void 0;
|
|
4
|
+
var constants_1 = require("../constants/constants");
|
|
5
|
+
var messages_1 = require("../constants/messages");
|
|
6
|
+
var helpers_1 = require("../helpers/helpers");
|
|
7
|
+
var HttpGatewayGlobals = /** @class */ (function () {
|
|
8
|
+
function HttpGatewayGlobals() {
|
|
9
|
+
/** Chunk size to use for uploads in bytes */
|
|
10
|
+
this.chunkSize = 64000;
|
|
11
|
+
/** The ID to use for HTTP Gateway needed DOM items */
|
|
12
|
+
this.mainContainerId = 'aspera-httpgateway';
|
|
13
|
+
/** The ID to use for the form container for forms */
|
|
14
|
+
this.formContainerId = 'aspera-httpgateway-form-container';
|
|
15
|
+
/** The ID to use for the download container */
|
|
16
|
+
this.downloadsContainerId = 'aspera-httpgateway-downloads-container';
|
|
17
|
+
/** Map of all forms currently in the container */
|
|
18
|
+
this.formsAvailable = new Map();
|
|
19
|
+
/** Map of form with files from drop events */
|
|
20
|
+
this.formsFilesFromDrop = new Map();
|
|
21
|
+
/** Map of folders with files from drop events */
|
|
22
|
+
this.folderFiles = new Map();
|
|
23
|
+
/** Indicates if running in software mode (no DOM) */
|
|
24
|
+
this.softwareMode = false;
|
|
25
|
+
/** Indicates if multiple server support should be used (will not lock out if gateway server is not working) */
|
|
26
|
+
this.supportMultipleServers = false;
|
|
27
|
+
/** Number of concurrent uploads to support */
|
|
28
|
+
this.concurrentUploads = 3;
|
|
29
|
+
/** Map of dropzones created by querySelector */
|
|
30
|
+
this.dropzonesCreated = new Map();
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Add a form item to the form container for transferring if form already exists the existing one is returned
|
|
34
|
+
*
|
|
35
|
+
* @param id ID to use for the form reference
|
|
36
|
+
*/
|
|
37
|
+
HttpGatewayGlobals.prototype.createOrUseForm = function (id) {
|
|
38
|
+
if (this.formsAvailable.get(id)) {
|
|
39
|
+
return this.formsAvailable.get(id);
|
|
40
|
+
}
|
|
41
|
+
var form = document.createElement('form');
|
|
42
|
+
form.id = id;
|
|
43
|
+
this.formsAvailable.set(id, form);
|
|
44
|
+
this.formContainer.appendChild(form);
|
|
45
|
+
return this.formsAvailable.get(id);
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Delete a form from the container by the ID
|
|
49
|
+
*
|
|
50
|
+
* @param id the form to delete
|
|
51
|
+
*/
|
|
52
|
+
HttpGatewayGlobals.prototype.deleteFormFromContainer = function (id) {
|
|
53
|
+
var foundForm = this.formsAvailable.get(id);
|
|
54
|
+
this.formsFilesFromDrop.delete(id);
|
|
55
|
+
if (foundForm) {
|
|
56
|
+
this.formContainer.removeChild(foundForm);
|
|
57
|
+
this.formsAvailable.delete(id);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Removes all forms from the Parent container
|
|
62
|
+
*/
|
|
63
|
+
HttpGatewayGlobals.prototype.removeAllFormsFromContainer = function () {
|
|
64
|
+
while (this.formContainer.firstChild) {
|
|
65
|
+
this.formContainer.removeChild(this.formContainer.firstChild);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Get or create an array of Files to store drop events in
|
|
70
|
+
*
|
|
71
|
+
* @param id the form to associate the files with
|
|
72
|
+
*/
|
|
73
|
+
HttpGatewayGlobals.prototype.getOrCreateFormFileListFromDrop = function (id) {
|
|
74
|
+
if (!this.formsFilesFromDrop.get(id)) {
|
|
75
|
+
this.formsFilesFromDrop.set(id, []);
|
|
76
|
+
}
|
|
77
|
+
return this.formsFilesFromDrop.get(id);
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Get or create an array of Folder data to store folder entries
|
|
81
|
+
*
|
|
82
|
+
* @param id the form to associate the folders with
|
|
83
|
+
*/
|
|
84
|
+
HttpGatewayGlobals.prototype.getOrCreateFolderDataList = function (id) {
|
|
85
|
+
if (!this.folderFiles.get(id)) {
|
|
86
|
+
this.folderFiles.set(id, new Map());
|
|
87
|
+
}
|
|
88
|
+
return this.folderFiles.get(id);
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Setup HTTP Gateway SDK server and formContainer
|
|
92
|
+
*
|
|
93
|
+
* @param serverUrl URL to use for the server
|
|
94
|
+
* @param softwareMode indicate if software mode is in use
|
|
95
|
+
* @param supportMultipleServers indicate if multiple servers are supported
|
|
96
|
+
*/
|
|
97
|
+
HttpGatewayGlobals.prototype.setUpServer = function (serverUrl, softwareMode, supportMultipleServers) {
|
|
98
|
+
if (typeof serverUrl === 'string') {
|
|
99
|
+
this.serverUrl = serverUrl;
|
|
100
|
+
}
|
|
101
|
+
this.softwareMode = !!softwareMode;
|
|
102
|
+
this.supportMultipleServers = !!supportMultipleServers;
|
|
103
|
+
if (!this.softwareMode) {
|
|
104
|
+
if (!this.mainContainer) {
|
|
105
|
+
this.mainContainer = document.createElement('div');
|
|
106
|
+
this.mainContainer.id = this.mainContainerId;
|
|
107
|
+
this.mainContainer.setAttribute('style', constants_1.hiddenStyleList);
|
|
108
|
+
document.querySelector('body').appendChild(this.mainContainer);
|
|
109
|
+
}
|
|
110
|
+
if (!this.formContainer) {
|
|
111
|
+
this.formsAvailable.clear();
|
|
112
|
+
this.formContainer = document.createElement('div');
|
|
113
|
+
this.formContainer.id = this.formContainerId;
|
|
114
|
+
document.querySelector("#".concat(this.mainContainerId)).appendChild(this.formContainer);
|
|
115
|
+
}
|
|
116
|
+
if (!this.downloadsContainer) {
|
|
117
|
+
this.downloadsContainer = document.createElement('div');
|
|
118
|
+
this.downloadsContainer.id = this.downloadsContainerId;
|
|
119
|
+
document.querySelector("#".concat(this.mainContainerId)).appendChild(this.downloadsContainer);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
HttpGatewayGlobals.prototype.backupDownloadMethod = function (url) {
|
|
124
|
+
window.alert(messages_1.messages.loadingDownload);
|
|
125
|
+
window.location.href = url;
|
|
126
|
+
};
|
|
127
|
+
/**
|
|
128
|
+
* Download a file based on a URL. By default a hidden IFRAME attempts to download
|
|
129
|
+
* the file but if that fails a fallback of opening a new window happens.
|
|
130
|
+
*
|
|
131
|
+
* @param url the URL of the file to download
|
|
132
|
+
*/
|
|
133
|
+
HttpGatewayGlobals.prototype.triggerDownloadFromUrl = function (url) {
|
|
134
|
+
var _this = this;
|
|
135
|
+
try {
|
|
136
|
+
var element = document.createElement('iframe');
|
|
137
|
+
element.src = url;
|
|
138
|
+
element.onerror = function (error) {
|
|
139
|
+
(0, helpers_1.errorLog)(messages_1.messages.failedToGenerateIframe, error);
|
|
140
|
+
_this.backupDownloadMethod(url);
|
|
141
|
+
};
|
|
142
|
+
document.querySelector("#".concat(this.downloadsContainerId)).appendChild(element);
|
|
143
|
+
}
|
|
144
|
+
catch (error) {
|
|
145
|
+
(0, helpers_1.errorLog)(messages_1.messages.failedToGenerateIframe, error);
|
|
146
|
+
this.backupDownloadMethod(url);
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
return HttpGatewayGlobals;
|
|
150
|
+
}());
|
|
151
|
+
var ServerInfo = /** @class */ (function () {
|
|
152
|
+
function ServerInfo() {
|
|
153
|
+
}
|
|
154
|
+
return ServerInfo;
|
|
155
|
+
}());
|
|
156
|
+
exports.ServerInfo = ServerInfo;
|
|
157
|
+
var TransferResponse = /** @class */ (function () {
|
|
158
|
+
function TransferResponse() {
|
|
159
|
+
}
|
|
160
|
+
return TransferResponse;
|
|
161
|
+
}());
|
|
162
|
+
exports.TransferResponse = TransferResponse;
|
|
163
|
+
var ActivityTracking = /** @class */ (function () {
|
|
164
|
+
function ActivityTracking() {
|
|
165
|
+
/** Map of transfers by ID */
|
|
166
|
+
this.transfers = new Map();
|
|
167
|
+
/** Map of callbacks that receive transfers */
|
|
168
|
+
this.callbacks = new Map();
|
|
169
|
+
/** Indicate if a callback should happen */
|
|
170
|
+
this.needCallback = false;
|
|
171
|
+
/** Queued uploads */
|
|
172
|
+
this.queuedUploads = [];
|
|
173
|
+
this.pollCallbacks();
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Get transfer response object including all transfers
|
|
177
|
+
*
|
|
178
|
+
* @returns transfer data object with transfers array
|
|
179
|
+
*/
|
|
180
|
+
ActivityTracking.prototype.getAllTransfersResponse = function () {
|
|
181
|
+
var transfers = this.getAllTransfers();
|
|
182
|
+
return {
|
|
183
|
+
iteration_token: '',
|
|
184
|
+
result_count: transfers.length,
|
|
185
|
+
transfers: transfers
|
|
186
|
+
};
|
|
187
|
+
};
|
|
188
|
+
/**
|
|
189
|
+
* Remove all transfers that are not active
|
|
190
|
+
*/
|
|
191
|
+
ActivityTracking.prototype.clearNonActiveTransfers = function () {
|
|
192
|
+
var _this = this;
|
|
193
|
+
var transferIdsToRemove = this.getAllTransfers().filter(function (transfer) {
|
|
194
|
+
return transfer.status === 'completed' || transfer.status === 'failed';
|
|
195
|
+
}).map(function (transfer) { return transfer.uuid; });
|
|
196
|
+
transferIdsToRemove.forEach(function (id) {
|
|
197
|
+
_this.removeTransfer(id);
|
|
198
|
+
});
|
|
199
|
+
};
|
|
200
|
+
/**
|
|
201
|
+
* Poll transfer callbacks
|
|
202
|
+
*/
|
|
203
|
+
ActivityTracking.prototype.pollCallbacks = function () {
|
|
204
|
+
var _this = this;
|
|
205
|
+
setTimeout(function () {
|
|
206
|
+
if (_this.needCallback) {
|
|
207
|
+
_this.callbacks.forEach(function (value) {
|
|
208
|
+
if (typeof value === 'function') {
|
|
209
|
+
value(_this.getAllTransfersResponse());
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
_this.needCallback = false;
|
|
214
|
+
_this.pollCallbacks();
|
|
215
|
+
}, 2000);
|
|
216
|
+
};
|
|
217
|
+
/**
|
|
218
|
+
* Trigger activity callback on activity events
|
|
219
|
+
*/
|
|
220
|
+
ActivityTracking.prototype.triggerActivityCallbacks = function () {
|
|
221
|
+
this.needCallback = true;
|
|
222
|
+
};
|
|
223
|
+
/**
|
|
224
|
+
* Register a callback for getting transfers back to the consumer
|
|
225
|
+
*
|
|
226
|
+
* @param callback the function to call with the array of transfers
|
|
227
|
+
*
|
|
228
|
+
* @returns the ID of the callback index
|
|
229
|
+
*/
|
|
230
|
+
ActivityTracking.prototype.setCallback = function (callback) {
|
|
231
|
+
if (typeof callback !== 'function') {
|
|
232
|
+
(0, helpers_1.errorLog)(messages_1.messages.callbackIsNotFunction);
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
var id = "callback-".concat(this.callbacks.size + 1);
|
|
236
|
+
this.callbacks.set(id, callback);
|
|
237
|
+
return id;
|
|
238
|
+
};
|
|
239
|
+
/**
|
|
240
|
+
* Remove the callback (deregister) from the list of callbacks
|
|
241
|
+
*
|
|
242
|
+
* @param id the string of the callback to remove
|
|
243
|
+
*/
|
|
244
|
+
ActivityTracking.prototype.removeCallback = function (id) {
|
|
245
|
+
this.callbacks.delete(id);
|
|
246
|
+
};
|
|
247
|
+
/**
|
|
248
|
+
* Set the transfer in the transfers map
|
|
249
|
+
*
|
|
250
|
+
* @param id transfer id for tracking transfers
|
|
251
|
+
* @param transfer transfer object
|
|
252
|
+
*/
|
|
253
|
+
ActivityTracking.prototype.setTransfer = function (id, transfer) {
|
|
254
|
+
this.transfers.set(id, transfer);
|
|
255
|
+
this.triggerActivityCallbacks();
|
|
256
|
+
};
|
|
257
|
+
/**
|
|
258
|
+
* Get the status of a specific transfer by ID (only returns for items during the session)
|
|
259
|
+
*
|
|
260
|
+
* @param id the ID of the transfer to retrieve that has been started during the session
|
|
261
|
+
*
|
|
262
|
+
* @returns an HttpTransfer object that includes the transfer info and status
|
|
263
|
+
*/
|
|
264
|
+
ActivityTracking.prototype.getTransferById = function (id) {
|
|
265
|
+
return this.transfers.get(id);
|
|
266
|
+
};
|
|
267
|
+
/**
|
|
268
|
+
* Get all active transfers (transfers that are not completed or failed)
|
|
269
|
+
*/
|
|
270
|
+
ActivityTracking.prototype.getActiveTransfers = function () {
|
|
271
|
+
return (0, helpers_1.iterableToArray)(this.transfers.values()).filter(function (transfer) {
|
|
272
|
+
return transfer.status !== 'completed' && transfer.status !== 'failed';
|
|
273
|
+
});
|
|
274
|
+
};
|
|
275
|
+
/**
|
|
276
|
+
* Remove a transfer from the transfer list
|
|
277
|
+
*
|
|
278
|
+
* @param id the ID of the transfer to remove
|
|
279
|
+
*/
|
|
280
|
+
ActivityTracking.prototype.removeTransfer = function (id) {
|
|
281
|
+
this.transfers.delete(id);
|
|
282
|
+
this.triggerActivityCallbacks();
|
|
283
|
+
};
|
|
284
|
+
/**
|
|
285
|
+
* Get the list of transfers started during the session for checking status
|
|
286
|
+
*
|
|
287
|
+
* @param returnMap boolean to indicate if the raw Map should be returned instead of an array
|
|
288
|
+
*
|
|
289
|
+
* @returns an Array of transfers or a Map of transfers (with the ID as key). Array is default
|
|
290
|
+
*/
|
|
291
|
+
ActivityTracking.prototype.getAllTransfers = function (returnMap) {
|
|
292
|
+
var transferList = [];
|
|
293
|
+
var transferMap = new Map();
|
|
294
|
+
this.transfers.forEach(function (value, key) {
|
|
295
|
+
transferList.push(value);
|
|
296
|
+
transferMap.set(key, value);
|
|
297
|
+
});
|
|
298
|
+
return returnMap ? transferMap : transferList;
|
|
299
|
+
};
|
|
300
|
+
return ActivityTracking;
|
|
301
|
+
}());
|
|
302
|
+
exports.ActivityTracking = ActivityTracking;
|
|
303
|
+
var HttpGateway = /** @class */ (function () {
|
|
304
|
+
function HttpGateway() {
|
|
305
|
+
var _this = this;
|
|
306
|
+
/** Global information about the HTTP Gateway */
|
|
307
|
+
this.globals = new HttpGatewayGlobals();
|
|
308
|
+
/** Activity tracking for watching transfers */
|
|
309
|
+
this.activityTracking = new ActivityTracking();
|
|
310
|
+
/**
|
|
311
|
+
* If the user attempts to leave the page warn that by leaving they will have their transfer abort
|
|
312
|
+
* NOTE: Only IE will show custom text. No way to indicate why they are being blocked.
|
|
313
|
+
*/
|
|
314
|
+
this.checkForPageLeave = function (event) {
|
|
315
|
+
if (_this.activityTracking.getActiveTransfers().length) {
|
|
316
|
+
event.preventDefault();
|
|
317
|
+
event.returnValue = messages_1.messages.leavingWhileUploading;
|
|
318
|
+
return messages_1.messages.leavingWhileUploading;
|
|
319
|
+
}
|
|
320
|
+
else {
|
|
321
|
+
delete event['returnValue'];
|
|
322
|
+
}
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
Object.defineProperty(HttpGateway.prototype, "isReady", {
|
|
326
|
+
/**
|
|
327
|
+
* Check if the HTTP Server is ready to be used and has been verified
|
|
328
|
+
*
|
|
329
|
+
* @returns a boolean indicating if SDK can be used for transfers
|
|
330
|
+
*/
|
|
331
|
+
get: function () {
|
|
332
|
+
return this.globals.serverVerified || this.globals.supportMultipleServers;
|
|
333
|
+
},
|
|
334
|
+
enumerable: false,
|
|
335
|
+
configurable: true
|
|
336
|
+
});
|
|
337
|
+
/**
|
|
338
|
+
* Overwrite default chunk size for chunking transfer data.
|
|
339
|
+
* This is an optional function, a default recommended size is set on start.
|
|
340
|
+
*
|
|
341
|
+
* @param size the size to use
|
|
342
|
+
*/
|
|
343
|
+
HttpGateway.prototype.overwriteDefaultChunkSize = function (size) {
|
|
344
|
+
if (size && size > 0) {
|
|
345
|
+
this.globals.chunkSize = size;
|
|
346
|
+
}
|
|
347
|
+
else {
|
|
348
|
+
(0, helpers_1.errorLog)(messages_1.messages.invalidChunkSize, { requestedSize: size });
|
|
349
|
+
}
|
|
350
|
+
};
|
|
351
|
+
/**
|
|
352
|
+
* Overwrite default concurrent transfer number for parallel transfers
|
|
353
|
+
* This is an optional function, a default recommended number is set on start.
|
|
354
|
+
*
|
|
355
|
+
* @param transfers the number of concurrent uploads to use
|
|
356
|
+
*/
|
|
357
|
+
HttpGateway.prototype.overwriteDefaultConcurrentUploads = function (transfers) {
|
|
358
|
+
if (transfers && transfers > 0) {
|
|
359
|
+
this.globals.concurrentUploads = transfers;
|
|
360
|
+
}
|
|
361
|
+
else {
|
|
362
|
+
(0, helpers_1.errorLog)(messages_1.messages.invalidConcurrentUploads, { requestedSize: transfers });
|
|
363
|
+
}
|
|
364
|
+
};
|
|
365
|
+
return HttpGateway;
|
|
366
|
+
}());
|
|
367
|
+
exports.HttpGateway = HttpGateway;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
export interface PromiseObject {
|
|
2
|
+
promise: Promise<any>;
|
|
3
|
+
resolver: (response?: any) => void;
|
|
4
|
+
rejecter: (response?: any) => void;
|
|
5
|
+
}
|
|
6
|
+
export type TransferStatus = 'failed' | 'completed' | 'running' | 'initiating' | 'queued' | 'cancelled';
|
|
7
|
+
export type FeatureFlags = 'noBase64Encoding';
|
|
8
|
+
export interface ErrorResponse {
|
|
9
|
+
error: boolean;
|
|
10
|
+
message: string;
|
|
11
|
+
debugData?: any;
|
|
12
|
+
}
|
|
13
|
+
export interface HttpTransferOptions {
|
|
14
|
+
/** Indicate custom Server URL */
|
|
15
|
+
serverUrlOverride?: string;
|
|
16
|
+
}
|
|
17
|
+
export declare class HttpTransfer {
|
|
18
|
+
constructor(id: string, spec: TransferSpec, files: File[], status?: TransferStatus, options?: HttpTransferOptions);
|
|
19
|
+
setEndTime(): void;
|
|
20
|
+
uuid: string;
|
|
21
|
+
httpGatewayTransfer: boolean;
|
|
22
|
+
serverUrlOverride?: string;
|
|
23
|
+
transfer_spec: TransferSpec;
|
|
24
|
+
add_time: string;
|
|
25
|
+
current_file: string;
|
|
26
|
+
end_time: string;
|
|
27
|
+
transport: string;
|
|
28
|
+
status: TransferStatus;
|
|
29
|
+
error_desc: string;
|
|
30
|
+
error_code: number;
|
|
31
|
+
bytes_written: number;
|
|
32
|
+
bytes_expected: number;
|
|
33
|
+
files: any[];
|
|
34
|
+
private recentPackets;
|
|
35
|
+
get calculated_rate_kbps(): number;
|
|
36
|
+
recentPacketTransfer(bytes: number): void;
|
|
37
|
+
get elapsed_usec(): number;
|
|
38
|
+
get percentage(): number;
|
|
39
|
+
}
|
|
40
|
+
export interface TransferSpecPath {
|
|
41
|
+
source: string;
|
|
42
|
+
destination?: string;
|
|
43
|
+
}
|
|
44
|
+
export interface FolderData {
|
|
45
|
+
path: string;
|
|
46
|
+
files: File[];
|
|
47
|
+
}
|
|
48
|
+
export declare class FileSelected {
|
|
49
|
+
constructor(file: any);
|
|
50
|
+
name: string;
|
|
51
|
+
size: number;
|
|
52
|
+
type: string;
|
|
53
|
+
}
|
|
54
|
+
export interface DownloadOptions {
|
|
55
|
+
/** Require all files to be zipped when downloaded (even if one file) */
|
|
56
|
+
zipRequire?: boolean;
|
|
57
|
+
/** Do not auto download. Return link to consumer */
|
|
58
|
+
disableAutoDownload?: boolean;
|
|
59
|
+
/** Indicate custom Server URL */
|
|
60
|
+
serverUrlOverride?: string;
|
|
61
|
+
}
|
|
62
|
+
export interface UploadOptions {
|
|
63
|
+
/** Indicate custom Server URL */
|
|
64
|
+
serverUrlOverride?: string;
|
|
65
|
+
}
|
|
66
|
+
export interface ConnectStyleFile {
|
|
67
|
+
lastModified: number;
|
|
68
|
+
name: string;
|
|
69
|
+
size: number;
|
|
70
|
+
type: string;
|
|
71
|
+
}
|
|
72
|
+
export interface TransferSpec {
|
|
73
|
+
authentication?: string;
|
|
74
|
+
cipher?: string;
|
|
75
|
+
content_protection?: string;
|
|
76
|
+
content_protection_passphrase?: string;
|
|
77
|
+
cookie?: string;
|
|
78
|
+
create_dir?: boolean;
|
|
79
|
+
destination_root?: string;
|
|
80
|
+
dgram_size?: number;
|
|
81
|
+
direction?: string;
|
|
82
|
+
fasp_port?: number;
|
|
83
|
+
http_fallback?: boolean;
|
|
84
|
+
http_fallback_port?: number;
|
|
85
|
+
lock_min_rate?: boolean;
|
|
86
|
+
lock_rate_policy?: boolean;
|
|
87
|
+
lock_target_rate?: boolean;
|
|
88
|
+
min_rate_kbps?: number;
|
|
89
|
+
paths?: TransferSpecPath[];
|
|
90
|
+
preserve_times?: boolean;
|
|
91
|
+
rate_policy?: string;
|
|
92
|
+
remote_host?: string;
|
|
93
|
+
remote_password?: string;
|
|
94
|
+
remote_user?: string;
|
|
95
|
+
resume?: string;
|
|
96
|
+
source_root?: string;
|
|
97
|
+
ssh_port?: number;
|
|
98
|
+
tags?: any;
|
|
99
|
+
target_rate_cap_kbps?: number;
|
|
100
|
+
target_rate_kbps?: number;
|
|
101
|
+
token?: string;
|
|
102
|
+
/** GATEWAY SPECIFIC */
|
|
103
|
+
zip_required?: boolean;
|
|
104
|
+
}
|
|
105
|
+
export interface DataTransferResponse {
|
|
106
|
+
dataTransfer: {
|
|
107
|
+
files: FileSelected[];
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
export interface VideoPlayerOptions {
|
|
111
|
+
/** Specifies that the video will start playing as soon as it is ready (default is false) */
|
|
112
|
+
autoplay?: boolean;
|
|
113
|
+
/** Specifies that video controls should be displayed (such as a play/pause button etc). (default is true) */
|
|
114
|
+
controls?: boolean;
|
|
115
|
+
/** Specifies that the video will start over again, every time it is finished (default is false) */
|
|
116
|
+
loop?: boolean;
|
|
117
|
+
/** Specifies that the audio output of the video should be muted (default is false) */
|
|
118
|
+
muted?: boolean;
|
|
119
|
+
/** URL of an image to be shown while the video is downloading, or until the user hits the play button (default is unset) */
|
|
120
|
+
poster?: string;
|
|
121
|
+
/** Sets the height of the video player (default is auto) */
|
|
122
|
+
height?: number;
|
|
123
|
+
/** Sets the width of the video player (default is 100% of DOM element) */
|
|
124
|
+
width?: number;
|
|
125
|
+
/** Indicate custom Server URL */
|
|
126
|
+
serverUrlOverride?: string;
|
|
127
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FileSelected = exports.HttpTransfer = void 0;
|
|
4
|
+
var HttpTransfer = /** @class */ (function () {
|
|
5
|
+
function HttpTransfer(id, spec, files, status, options) {
|
|
6
|
+
this.httpGatewayTransfer = true;
|
|
7
|
+
this.recentPackets = [];
|
|
8
|
+
this.uuid = id;
|
|
9
|
+
this.status = status || 'initiating';
|
|
10
|
+
this.add_time = new Date().toISOString();
|
|
11
|
+
this.transfer_spec = spec;
|
|
12
|
+
this.transport = 'http_gateway';
|
|
13
|
+
if (options && typeof options === 'object' && options.serverUrlOverride) {
|
|
14
|
+
this.serverUrlOverride = options.serverUrlOverride;
|
|
15
|
+
}
|
|
16
|
+
this.files = files.map(function (file) {
|
|
17
|
+
return {
|
|
18
|
+
lastModified: file.lastModified,
|
|
19
|
+
name: file.name,
|
|
20
|
+
size: file.size,
|
|
21
|
+
type: file.type
|
|
22
|
+
};
|
|
23
|
+
});
|
|
24
|
+
this.current_file = this.files[0] ? this.files[0].name : '';
|
|
25
|
+
}
|
|
26
|
+
HttpTransfer.prototype.setEndTime = function () {
|
|
27
|
+
this.end_time = new Date().toISOString();
|
|
28
|
+
};
|
|
29
|
+
Object.defineProperty(HttpTransfer.prototype, "calculated_rate_kbps", {
|
|
30
|
+
get: function () {
|
|
31
|
+
if (this.recentPackets.length) {
|
|
32
|
+
var timeBetweenLastPackets = this.recentPackets[this.recentPackets.length - 1].timeStamp - this.recentPackets[0].timeStamp;
|
|
33
|
+
var bytesWrittenInLastPackets_1 = 0;
|
|
34
|
+
this.recentPackets.forEach(function (packet) {
|
|
35
|
+
bytesWrittenInLastPackets_1 += packet.bytes;
|
|
36
|
+
});
|
|
37
|
+
if (timeBetweenLastPackets && bytesWrittenInLastPackets_1) {
|
|
38
|
+
return (((bytesWrittenInLastPackets_1 * 8) / (timeBetweenLastPackets / 1000000)) / 1000);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return 0;
|
|
42
|
+
},
|
|
43
|
+
enumerable: false,
|
|
44
|
+
configurable: true
|
|
45
|
+
});
|
|
46
|
+
HttpTransfer.prototype.recentPacketTransfer = function (bytes) {
|
|
47
|
+
if (this.recentPackets.length >= 5) {
|
|
48
|
+
this.recentPackets.shift();
|
|
49
|
+
}
|
|
50
|
+
this.recentPackets.push({
|
|
51
|
+
timeStamp: new Date().getTime() * 1000,
|
|
52
|
+
bytes: bytes
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
Object.defineProperty(HttpTransfer.prototype, "elapsed_usec", {
|
|
56
|
+
get: function () {
|
|
57
|
+
var endTime = this.end_time ? new Date(this.end_time).getTime() : new Date().getTime();
|
|
58
|
+
return (endTime - new Date(this.add_time).getTime()) * 1000;
|
|
59
|
+
},
|
|
60
|
+
enumerable: false,
|
|
61
|
+
configurable: true
|
|
62
|
+
});
|
|
63
|
+
Object.defineProperty(HttpTransfer.prototype, "percentage", {
|
|
64
|
+
get: function () {
|
|
65
|
+
if (this.bytes_written > 0 && this.bytes_written <= this.bytes_expected) {
|
|
66
|
+
return ((this.bytes_written / this.bytes_expected));
|
|
67
|
+
}
|
|
68
|
+
else if (this.bytes_written > this.bytes_expected) {
|
|
69
|
+
return 1;
|
|
70
|
+
}
|
|
71
|
+
return 0;
|
|
72
|
+
},
|
|
73
|
+
enumerable: false,
|
|
74
|
+
configurable: true
|
|
75
|
+
});
|
|
76
|
+
return HttpTransfer;
|
|
77
|
+
}());
|
|
78
|
+
exports.HttpTransfer = HttpTransfer;
|
|
79
|
+
var FileSelected = /** @class */ (function () {
|
|
80
|
+
function FileSelected(file) {
|
|
81
|
+
this.name = file.name;
|
|
82
|
+
this.size = file.size;
|
|
83
|
+
this.type = file.type;
|
|
84
|
+
}
|
|
85
|
+
return FileSelected;
|
|
86
|
+
}());
|
|
87
|
+
exports.FileSelected = FileSelected;
|
package/dist/commonjs/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { AsperaSdk } from './models/aspera-sdk.model';
|
|
2
|
-
import { authenticate, createDropzone, deregisterActivityCallback, deregisterStatusCallback, getAllTransfers, getCapabilities, getChecksum, getFilesList, getInfo, getStatus, getTransfer, hasCapability, init, initDragDrop, initSession, modifyTransfer, showPreferencesPage, readAsArrayBuffer, readChunkAsArrayBuffer, readDirectory, registerActivityCallback, registerStatusCallback, removeDropzone, removeTransfer, resumeTransfer, setBranding, showAbout, showDirectory, showPreferences, showSaveFileDialog, showSelectFileDialog, showSelectFolderDialog, showTransferManager, showTransferMonitor, startTransfer, stopTransfer, testConnection, testSshPorts } from './app/core';
|
|
2
|
+
import { authenticate, createDropzone, deregisterActivityCallback, deregisterStatusCallback, getAllTransfers, getCapabilities, getChecksum, getFilesList, getInfo, getStatus, getTransfer, hasCapability, init, initDragDrop, initSession, modifyTransfer, showPreferencesPage, readAsArrayBuffer, readChunkAsArrayBuffer, readDirectory, registerActivityCallback, registerStatusCallback, removeDropzone, removeTransfer, resumeTransfer, setBranding, showAbout, showDirectory, showPreferences, showSaveFileDialog, showSelectFileDialog, showSelectFolderDialog, showTransferManager, showTransferMonitor, startTransfer, stopTransfer, testConnection, testSshPorts, currentTransferClient } from './app/core';
|
|
3
3
|
import { getInstallerInfo } from './app/installer';
|
|
4
4
|
import { getInstallerUrls, isSafari } from './helpers/helpers';
|
|
5
5
|
export declare const asperaSdk: AsperaSdk;
|
|
6
6
|
declare const launch: () => void;
|
|
7
|
-
export { isSafari, init, authenticate, testSshPorts, testConnection, startTransfer, launch, registerActivityCallback, deregisterActivityCallback, removeTransfer, showAbout, showDirectory, stopTransfer, resumeTransfer, getAllTransfers, getTransfer, getFilesList, showSelectFileDialog, showSelectFolderDialog, showSaveFileDialog, showPreferences, showTransferManager, showTransferMonitor, showPreferencesPage as openPreferencesPage, modifyTransfer, createDropzone, removeDropzone, initDragDrop, getInstallerInfo, registerStatusCallback, deregisterStatusCallback, initSession, getStatus, setBranding, getInfo, readAsArrayBuffer, readChunkAsArrayBuffer, getInstallerUrls, getCapabilities, hasCapability, getChecksum, readDirectory, };
|
|
8
|
-
export type { AsperaSdkSpec, AsperaSdkTransfer, BrowserStyleFile, ChecksumFileResponse, DirectoryEntry, DirectoryListFilters, CustomBrandingOptions, CustomTheme, CustomThemeItems, DataTransferResponse, DropzoneEventData, DropzoneEventType, EntryType, DropzoneOptions, FileDialogOptions, FileError, FileFilter, FileStat, FileStatus, FolderDialogOptions, SaveFileDialogOptions, GetChecksumOptions, InitOptions, InstallerInfo, InstallerInfoResponse, InstallerOptions, InstallerUrlInfo, ModifyTransferOptions, ShowPreferencesPageOptions as OpenPreferencesPageOptions, OverwritePolicy, PaginatedFilesResponse, Pagination, Path, PreferencesPage, ReadAsArrayBufferResponse, ReadChunkAsArrayBufferResponse, ReadDirectoryOptions, ReadDirectoryResponse, ResumePolicy, ResumeTransferOptions, SafariExtensionEvent, SdkCapabilities, TestSshPortsOptions, TransferSpec, TransferStatus, SdkStatus, WebsocketEvent, } from './models/models';
|
|
7
|
+
export { isSafari, init, authenticate, testSshPorts, testConnection, startTransfer, launch, registerActivityCallback, deregisterActivityCallback, removeTransfer, showAbout, showDirectory, stopTransfer, resumeTransfer, getAllTransfers, getTransfer, getFilesList, showSelectFileDialog, showSelectFolderDialog, showSaveFileDialog, showPreferences, showTransferManager, showTransferMonitor, showPreferencesPage as openPreferencesPage, modifyTransfer, createDropzone, removeDropzone, initDragDrop, getInstallerInfo, registerStatusCallback, deregisterStatusCallback, initSession, getStatus, setBranding, getInfo, readAsArrayBuffer, readChunkAsArrayBuffer, getInstallerUrls, getCapabilities, hasCapability, getChecksum, readDirectory, currentTransferClient, };
|
|
8
|
+
export type { AsperaSdkSpec, AsperaSdkTransfer, BrowserStyleFile, ChecksumFileResponse, DirectoryEntry, DirectoryListFilters, CustomBrandingOptions, CustomTheme, CustomThemeItems, DataTransferResponse, DropzoneEventData, DropzoneEventType, EntryType, DropzoneOptions, FileDialogOptions, FileError, FileFilter, FileStat, FileStatus, FolderDialogOptions, SaveFileDialogOptions, GetChecksumOptions, InitOptions, InstallerInfo, InstallerInfoResponse, InstallerOptions, InstallerUrlInfo, ModifyTransferOptions, ShowPreferencesPageOptions as OpenPreferencesPageOptions, OverwritePolicy, PaginatedFilesResponse, Pagination, Path, PreferencesPage, ReadAsArrayBufferResponse, ReadChunkAsArrayBufferResponse, ReadDirectoryOptions, ReadDirectoryResponse, ResumePolicy, ResumeTransferOptions, SafariExtensionEvent, SdkCapabilities, TestSshPortsOptions, TransferSpec, TransferStatus, SdkStatus, TransferClient, WebsocketEvent, } from './models/models';
|
|
9
9
|
export type { ActivityMessage, ActivityMessageTypes, AsperaSdkClientInfo, AsperaSdkInfo, TransferResponse, } from './models/aspera-sdk.model';
|
|
10
10
|
export { AsperaSdk, AsperaSdkGlobals } from './models/aspera-sdk.model';
|
|
11
11
|
export type { HttpGatewayInfo } from './http-gateway/models';
|
package/dist/commonjs/index.js
CHANGED
|
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.AsperaSdkGlobals = exports.AsperaSdk = exports.readDirectory = exports.getChecksum = exports.hasCapability = exports.getCapabilities = exports.getInstallerUrls = exports.readChunkAsArrayBuffer = exports.readAsArrayBuffer = exports.getInfo = exports.setBranding = exports.getStatus = exports.initSession = exports.deregisterStatusCallback = exports.registerStatusCallback = exports.getInstallerInfo = exports.initDragDrop = exports.removeDropzone = exports.createDropzone = exports.modifyTransfer = exports.openPreferencesPage = exports.showTransferMonitor = exports.showTransferManager = exports.showPreferences = exports.showSaveFileDialog = exports.showSelectFolderDialog = exports.showSelectFileDialog = exports.getFilesList = exports.getTransfer = exports.getAllTransfers = exports.resumeTransfer = exports.stopTransfer = exports.showDirectory = exports.showAbout = exports.removeTransfer = exports.deregisterActivityCallback = exports.registerActivityCallback = exports.launch = exports.startTransfer = exports.testConnection = exports.testSshPorts = exports.authenticate = exports.init = exports.isSafari = exports.asperaSdk = void 0;
|
|
36
|
+
exports.AsperaSdkGlobals = exports.AsperaSdk = exports.currentTransferClient = exports.readDirectory = exports.getChecksum = exports.hasCapability = exports.getCapabilities = exports.getInstallerUrls = exports.readChunkAsArrayBuffer = exports.readAsArrayBuffer = exports.getInfo = exports.setBranding = exports.getStatus = exports.initSession = exports.deregisterStatusCallback = exports.registerStatusCallback = exports.getInstallerInfo = exports.initDragDrop = exports.removeDropzone = exports.createDropzone = exports.modifyTransfer = exports.openPreferencesPage = exports.showTransferMonitor = exports.showTransferManager = exports.showPreferences = exports.showSaveFileDialog = exports.showSelectFolderDialog = exports.showSelectFileDialog = exports.getFilesList = exports.getTransfer = exports.getAllTransfers = exports.resumeTransfer = exports.stopTransfer = exports.showDirectory = exports.showAbout = exports.removeTransfer = exports.deregisterActivityCallback = exports.registerActivityCallback = exports.launch = exports.startTransfer = exports.testConnection = exports.testSshPorts = exports.authenticate = exports.init = exports.isSafari = exports.asperaSdk = void 0;
|
|
37
37
|
var aspera_sdk_model_1 = require("./models/aspera-sdk.model");
|
|
38
38
|
var core_1 = require("./app/core");
|
|
39
39
|
Object.defineProperty(exports, "authenticate", { enumerable: true, get: function () { return core_1.authenticate; } });
|
|
@@ -74,6 +74,7 @@ Object.defineProperty(exports, "startTransfer", { enumerable: true, get: functio
|
|
|
74
74
|
Object.defineProperty(exports, "stopTransfer", { enumerable: true, get: function () { return core_1.stopTransfer; } });
|
|
75
75
|
Object.defineProperty(exports, "testConnection", { enumerable: true, get: function () { return core_1.testConnection; } });
|
|
76
76
|
Object.defineProperty(exports, "testSshPorts", { enumerable: true, get: function () { return core_1.testSshPorts; } });
|
|
77
|
+
Object.defineProperty(exports, "currentTransferClient", { enumerable: true, get: function () { return core_1.currentTransferClient; } });
|
|
77
78
|
var installer_1 = require("./app/installer");
|
|
78
79
|
Object.defineProperty(exports, "getInstallerInfo", { enumerable: true, get: function () { return installer_1.getInstallerInfo; } });
|
|
79
80
|
var helpers_1 = require("./helpers/helpers");
|
|
@@ -122,6 +123,7 @@ exports.asperaSdk.getCapabilities = core_1.getCapabilities;
|
|
|
122
123
|
exports.asperaSdk.hasCapability = core_1.hasCapability;
|
|
123
124
|
exports.asperaSdk.getChecksum = core_1.getChecksum;
|
|
124
125
|
exports.asperaSdk.readDirectory = core_1.readDirectory;
|
|
126
|
+
exports.asperaSdk.currentTransferClient = core_1.currentTransferClient;
|
|
125
127
|
exports.asperaSdk.httpGatewayCalls = httpGatewayCalls;
|
|
126
128
|
var launch = exports.asperaSdk.globals.launch;
|
|
127
129
|
exports.launch = launch;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CustomBrandingOptions, DataTransferResponse, DropzoneEventData, DropzoneEventType, DropzoneOptions, AsperaSdkSpec, AsperaSdkTransfer, FileDialogOptions, FolderDialogOptions, SaveFileDialogOptions, InitOptions, InstallerInfoResponse, InstallerOptions, ModifyTransferOptions, Pagination, PaginatedFilesResponse, ResumeTransferOptions, SafariExtensionEvent, SdkStatus, TransferSpec, WebsocketEvent, InstallerUrlInfo, SdkCapabilities, GetChecksumOptions, ChecksumFileResponse, ReadDirectoryOptions, ReadDirectoryResponse, ShowPreferencesPageOptions, TestSshPortsOptions } from './models';
|
|
1
|
+
import { CustomBrandingOptions, DataTransferResponse, DropzoneEventData, DropzoneEventType, DropzoneOptions, AsperaSdkSpec, AsperaSdkTransfer, FileDialogOptions, FolderDialogOptions, SaveFileDialogOptions, InitOptions, InstallerInfoResponse, InstallerOptions, ModifyTransferOptions, Pagination, PaginatedFilesResponse, ResumeTransferOptions, SafariExtensionEvent, SdkStatus, TransferSpec, WebsocketEvent, InstallerUrlInfo, SdkCapabilities, GetChecksumOptions, ChecksumFileResponse, ReadDirectoryOptions, ReadDirectoryResponse, ShowPreferencesPageOptions, TestSshPortsOptions, TransferClient } from './models';
|
|
2
2
|
import { HttpGatewayInfo } from '../http-gateway/models';
|
|
3
3
|
import * as ConnectTypes from '@ibm-aspera/connect-sdk-js/dist/esm/core/types';
|
|
4
4
|
import { Connect, ConnectInstaller } from '@ibm-aspera/connect-sdk-js';
|
|
@@ -238,6 +238,7 @@ export declare class AsperaSdk {
|
|
|
238
238
|
getChecksum: (options: GetChecksumOptions) => Promise<ChecksumFileResponse>;
|
|
239
239
|
/** Function to read directory contents and return entries as a flat list */
|
|
240
240
|
readDirectory: (options: ReadDirectoryOptions) => Promise<ReadDirectoryResponse>;
|
|
241
|
+
currentTransferClient: () => TransferClient | undefined;
|
|
241
242
|
/** Indicate if Safari Extension is enabled. If the extension is disabled during the lifecycle this will not update to disabled. */
|
|
242
243
|
SAFARI_EXTENSION_STATUS: SafariExtensionEvent;
|
|
243
244
|
/** Aspera HTTP Gateway calls. This normally is not needed by clients but expose just in case. */
|
|
@@ -99,6 +99,14 @@ var ActivityTracking = /** @class */ (function () {
|
|
|
99
99
|
var data = message.data && typeof message.data === 'object' && 'transfers' in message.data
|
|
100
100
|
? message.data
|
|
101
101
|
: { transfers: [message.data] };
|
|
102
|
+
var transfers = data.transfers;
|
|
103
|
+
if (Array.isArray(transfers)) {
|
|
104
|
+
transfers.forEach(function (t) {
|
|
105
|
+
if (!t.transfer_client) {
|
|
106
|
+
t.transfer_client = 'desktop';
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
}
|
|
102
110
|
if (message.type === 'transferUpdated' || message.type === 'transferRemoved') {
|
|
103
111
|
this.activity_callbacks.forEach(function (callback) {
|
|
104
112
|
if (typeof callback === 'function') {
|