@ibm-aspera/sdk 0.2.8 → 0.2.12
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/.whitesource +3 -0
- package/README.md +1 -1
- package/dist/commonjs/app/core.d.ts +8 -37
- package/dist/commonjs/app/core.js +198 -70
- package/dist/commonjs/connect/core.d.ts +11 -0
- package/dist/commonjs/connect/core.js +73 -0
- package/dist/commonjs/constants/constants.d.ts +1 -1
- package/dist/commonjs/constants/messages.d.ts +5 -0
- package/dist/commonjs/constants/messages.js +5 -0
- package/dist/commonjs/helpers/client/http-client.js +1 -1
- package/dist/commonjs/helpers/client/safari-client.js +1 -1
- package/dist/commonjs/helpers/helpers.d.ts +20 -2
- package/dist/commonjs/helpers/helpers.js +40 -2
- package/dist/commonjs/helpers/ws.js +3 -9
- package/dist/commonjs/http-gateway/core.d.ts +76 -0
- package/dist/commonjs/http-gateway/core.js +254 -0
- package/dist/commonjs/http-gateway/download.d.ts +14 -0
- package/dist/commonjs/http-gateway/download.js +186 -0
- package/dist/commonjs/http-gateway/index.d.ts +11 -0
- package/dist/commonjs/http-gateway/index.js +11 -0
- package/dist/commonjs/http-gateway/models.d.ts +16 -0
- package/dist/commonjs/http-gateway/models.js +2 -0
- package/dist/commonjs/http-gateway/upload.d.ts +14 -0
- package/dist/commonjs/http-gateway/upload.js +124 -0
- package/dist/commonjs/index.d.ts +2 -2
- package/dist/commonjs/index.js +36 -9
- package/dist/commonjs/models/aspera-sdk.model.d.ts +60 -47
- package/dist/commonjs/models/aspera-sdk.model.js +84 -92
- package/dist/commonjs/models/models.d.ts +69 -3
- package/dist/js/aspera-sdk.js +1 -1
- package/dist/js/aspera-sdk.js.LICENSE.txt +9 -1
- package/dist/js/aspera-sdk.js.map +1 -1
- package/package.json +23 -27
- package/scripts/version.sh +24 -0
package/.whitesource
ADDED
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# IBM Aspera JavaScript SDK
|
|
2
|
-
This JavaScript SDK allows web applications to integrate with IBM Aspera to perform high-speed Aspera file transfers.
|
|
2
|
+
This JavaScript SDK allows web applications to integrate with `IBM Aspera for desktop` to perform high-speed Aspera file transfers.
|
|
3
3
|
|
|
4
4
|
Documentation is available on [GitHub Pages](https://ibm.github.io/aspera-sdk-js/docs/)
|
|
5
5
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { AsperaSdkInfo, TransferResponse } from '../models/aspera-sdk.model';
|
|
2
|
-
import { CustomBrandingOptions, DataTransferResponse, AsperaSdkSpec, AsperaSdkTransfer, FileDialogOptions, FolderDialogOptions, InitOptions, ModifyTransferOptions, ResumeTransferOptions,
|
|
2
|
+
import { CustomBrandingOptions, DataTransferResponse, AsperaSdkSpec, AsperaSdkTransfer, FileDialogOptions, FolderDialogOptions, InitOptions, ModifyTransferOptions, ResumeTransferOptions, TransferSpec, WebsocketEvent } from '../models/models';
|
|
3
|
+
import * as ConnectTypes from '@ibm-aspera/connect-sdk-js/dist/esm/core/types';
|
|
3
4
|
/**
|
|
4
5
|
* Check if IBM Aspera for Desktop connection works. This function is called by init
|
|
5
6
|
* when initializing the SDK. This function can be used at any point for checking.
|
|
@@ -8,7 +9,8 @@ import { CustomBrandingOptions, DataTransferResponse, AsperaSdkSpec, AsperaSdkTr
|
|
|
8
9
|
*/
|
|
9
10
|
export declare const testConnection: () => Promise<any>;
|
|
10
11
|
/**
|
|
11
|
-
* Initialize drag and drop.
|
|
12
|
+
* Initialize drag and drop. HTTP Gateway and Connect does not need to init.
|
|
13
|
+
* Ignore if only HTTP Gateway
|
|
12
14
|
* @param initCall - Indicate if called via init flow and should not reject
|
|
13
15
|
*
|
|
14
16
|
* @returns a promise that resolves if the initialization was successful or not
|
|
@@ -37,7 +39,7 @@ export declare const init: (options?: InitOptions) => Promise<any>;
|
|
|
37
39
|
* Start a transfer
|
|
38
40
|
*
|
|
39
41
|
* @param transferSpec standard transferSpec for transfer
|
|
40
|
-
* @param asperaSdkSpec IBM Aspera settings when starting a transfer
|
|
42
|
+
* @param asperaSdkSpec IBM Aspera settings when starting a transfer.
|
|
41
43
|
*
|
|
42
44
|
* @returns a promise that resolves if transfer initiation is successful and rejects if transfer cannot be started
|
|
43
45
|
*/
|
|
@@ -56,22 +58,6 @@ export declare const registerActivityCallback: (callback: (transfers: TransferRe
|
|
|
56
58
|
* @param id the ID returned by `registerActivityCallback`
|
|
57
59
|
*/
|
|
58
60
|
export declare const deregisterActivityCallback: (id: string) => void;
|
|
59
|
-
/**
|
|
60
|
-
* Register a callback event for when a user removes or cancels a transfer
|
|
61
|
-
* directly from IBM Aspera. This may also be called if IBM Aspera
|
|
62
|
-
* is configured to automatically remove completed transfers.
|
|
63
|
-
*
|
|
64
|
-
* @param callback callback function to receive transfers
|
|
65
|
-
*
|
|
66
|
-
* @returns ID representing the callback for deregistration purposes
|
|
67
|
-
*/
|
|
68
|
-
export declare const registerRemovedCallback: (callback: (transfer: AsperaSdkTransfer) => void) => string;
|
|
69
|
-
/**
|
|
70
|
-
* Remove a callback from the removed transfer callback
|
|
71
|
-
*
|
|
72
|
-
* @param id the ID returned by `registerRemovedCallback`
|
|
73
|
-
*/
|
|
74
|
-
export declare const deregisterRemovedCallback: (id: string) => void;
|
|
75
61
|
/**
|
|
76
62
|
* Register a callback for getting updates about the connection status of IBM Aspera SDK.
|
|
77
63
|
*
|
|
@@ -90,22 +76,6 @@ export declare const registerStatusCallback: (callback: (status: WebsocketEvent)
|
|
|
90
76
|
* @param id the ID returned by `registerStatusCallback`
|
|
91
77
|
*/
|
|
92
78
|
export declare const deregisterStatusCallback: (id: string) => void;
|
|
93
|
-
/**
|
|
94
|
-
* Register a callback for getting updates about the Safari extension status.
|
|
95
|
-
*
|
|
96
|
-
* This can be useful if you want to handle the case where the user enable or disable the Safari extension.
|
|
97
|
-
*
|
|
98
|
-
* @param callback callback function to receive events
|
|
99
|
-
*
|
|
100
|
-
* @returns ID representing the callback for deregistration purposes
|
|
101
|
-
*/
|
|
102
|
-
export declare const registerSafariExtensionStatusCallback: (callback: (status: SafariExtensionEvent) => void) => string;
|
|
103
|
-
/**
|
|
104
|
-
* Remove a callback from getting Safari extension status events.
|
|
105
|
-
*
|
|
106
|
-
* @param id the ID returned by `registerStatusCallback`
|
|
107
|
-
*/
|
|
108
|
-
export declare const deregisterSafariExtensionStatusCallback: (id: string) => void;
|
|
109
79
|
/**
|
|
110
80
|
* Remove a transfer. This will stop the transfer if it is in progress.
|
|
111
81
|
*
|
|
@@ -201,11 +171,12 @@ export declare const setBranding: (id: string, options: CustomBrandingOptions) =
|
|
|
201
171
|
*
|
|
202
172
|
* @param callback the function to call once the files are dropped
|
|
203
173
|
* @param elementSelector the selector of the element on the page that should watch for drop events
|
|
174
|
+
* @param connectOptions options for connect
|
|
204
175
|
*/
|
|
205
176
|
export declare const createDropzone: (callback: (data: {
|
|
206
|
-
event:
|
|
177
|
+
event: DragEvent;
|
|
207
178
|
files: DataTransferResponse;
|
|
208
|
-
}) => void, elementSelector: string) => void;
|
|
179
|
+
}) => void, elementSelector: string, connectOptions?: ConnectTypes.DragDropOptions) => void;
|
|
209
180
|
/**
|
|
210
181
|
* Remove dropzone.
|
|
211
182
|
*
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getInfo = exports.removeDropzone = exports.createDropzone = exports.setBranding = exports.modifyTransfer = exports.showDirectory = exports.getTransfer = exports.getAllTransfers = exports.showPreferences = exports.showSelectFolderDialog = exports.showSelectFileDialog = exports.resumeTransfer = exports.stopTransfer = exports.removeTransfer = exports.
|
|
3
|
+
exports.getInfo = exports.removeDropzone = exports.createDropzone = exports.setBranding = exports.modifyTransfer = exports.showDirectory = exports.getTransfer = exports.getAllTransfers = exports.showPreferences = exports.showSelectFolderDialog = exports.showSelectFileDialog = exports.resumeTransfer = exports.stopTransfer = exports.removeTransfer = exports.deregisterStatusCallback = exports.registerStatusCallback = exports.deregisterActivityCallback = exports.registerActivityCallback = exports.startTransfer = exports.init = exports.initDragDrop = exports.testConnection = void 0;
|
|
4
4
|
var messages_1 = require("../constants/messages");
|
|
5
5
|
var client_1 = require("../helpers/client/client");
|
|
6
6
|
var helpers_1 = require("../helpers/helpers");
|
|
7
|
+
var http_gateway_1 = require("../http-gateway");
|
|
8
|
+
var core_1 = require("../http-gateway/core");
|
|
7
9
|
var index_1 = require("../index");
|
|
10
|
+
var http_gateway_sdk_js_1 = require("@ibm-aspera/http-gateway-sdk-js");
|
|
11
|
+
var connect_sdk_js_1 = require("@ibm-aspera/connect-sdk-js");
|
|
12
|
+
var core_2 = require("../connect/core");
|
|
8
13
|
/**
|
|
9
14
|
* Check if IBM Aspera for Desktop connection works. This function is called by init
|
|
10
15
|
* when initializing the SDK. This function can be used at any point for checking.
|
|
@@ -12,22 +17,29 @@ var index_1 = require("../index");
|
|
|
12
17
|
* @returns a promise that resolves if server can connect or rejects if not
|
|
13
18
|
*/
|
|
14
19
|
var testConnection = function () {
|
|
20
|
+
if (index_1.asperaSdk.useHttpGateway || index_1.asperaSdk.useConnect) {
|
|
21
|
+
return Promise.resolve(index_1.asperaSdk.globals.sdkResponseData);
|
|
22
|
+
}
|
|
15
23
|
return client_1.client.request('get_info')
|
|
16
24
|
.then(function (data) {
|
|
17
|
-
index_1.asperaSdk.globals.
|
|
25
|
+
index_1.asperaSdk.globals.asperaSdkInfo = data;
|
|
18
26
|
index_1.asperaSdk.globals.asperaAppVerified = true;
|
|
19
|
-
return
|
|
27
|
+
return index_1.asperaSdk.globals.sdkResponseData;
|
|
20
28
|
});
|
|
21
29
|
};
|
|
22
30
|
exports.testConnection = testConnection;
|
|
23
31
|
/**
|
|
24
|
-
* Initialize drag and drop.
|
|
32
|
+
* Initialize drag and drop. HTTP Gateway and Connect does not need to init.
|
|
33
|
+
* Ignore if only HTTP Gateway
|
|
25
34
|
* @param initCall - Indicate if called via init flow and should not reject
|
|
26
35
|
*
|
|
27
36
|
* @returns a promise that resolves if the initialization was successful or not
|
|
28
37
|
*/
|
|
29
38
|
var initDragDrop = function (initCall) {
|
|
30
|
-
if (
|
|
39
|
+
if (index_1.asperaSdk.useHttpGateway || index_1.asperaSdk.useConnect) {
|
|
40
|
+
return Promise.resolve(true);
|
|
41
|
+
}
|
|
42
|
+
else if (!index_1.asperaSdk.isReady) {
|
|
31
43
|
return (0, helpers_1.throwError)(messages_1.messages.serverNotVerified);
|
|
32
44
|
}
|
|
33
45
|
var promiseInfo = (0, helpers_1.generatePromiseObjects)();
|
|
@@ -65,39 +77,113 @@ exports.initDragDrop = initDragDrop;
|
|
|
65
77
|
* rejects if unable to connect
|
|
66
78
|
*/
|
|
67
79
|
var init = function (options) {
|
|
68
|
-
var _a, _b;
|
|
80
|
+
var _a, _b, _c, _d;
|
|
69
81
|
var appId = (_a = options === null || options === void 0 ? void 0 : options.appId) !== null && _a !== void 0 ? _a : (0, helpers_1.randomUUID)();
|
|
70
82
|
var supportMultipleUsers = (_b = options === null || options === void 0 ? void 0 : options.supportMultipleUsers) !== null && _b !== void 0 ? _b : false;
|
|
71
83
|
index_1.asperaSdk.globals.appId = appId;
|
|
84
|
+
// Watch for old HTTP Gateway transfers in case used.
|
|
85
|
+
(0, http_gateway_sdk_js_1.registerActivityCallback)(function (oldHttpTransfers) {
|
|
86
|
+
oldHttpTransfers.transfers.forEach(function (oldHttpTransfer) {
|
|
87
|
+
(0, core_1.sendTransferUpdate)(oldHttpTransfer);
|
|
88
|
+
});
|
|
89
|
+
});
|
|
72
90
|
if (supportMultipleUsers) {
|
|
73
91
|
index_1.asperaSdk.globals.supportMultipleUsers = true;
|
|
74
92
|
index_1.asperaSdk.globals.sessionId = (0, helpers_1.randomUUID)();
|
|
75
93
|
}
|
|
76
|
-
|
|
77
|
-
.then(function () { return (0, exports.testConnection)(); })
|
|
78
|
-
.then(function () { return (0, exports.initDragDrop)(true); })
|
|
79
|
-
.catch(function (error) {
|
|
94
|
+
var handleErrors = function (error) {
|
|
80
95
|
(0, helpers_1.errorLog)(messages_1.messages.serverError, error);
|
|
81
96
|
index_1.asperaSdk.globals.asperaAppVerified = false;
|
|
82
97
|
throw (0, helpers_1.generateErrorBody)(messages_1.messages.serverError, error);
|
|
83
|
-
}
|
|
98
|
+
};
|
|
99
|
+
var getConnectStartCalls = function () {
|
|
100
|
+
index_1.asperaSdk.globals.connect = new connect_sdk_js_1.Connect({
|
|
101
|
+
minVersion: options.connectSettings.minVersion || '3.10.1',
|
|
102
|
+
dragDropEnabled: options.connectSettings.dragDropEnabled,
|
|
103
|
+
connectMethod: options.connectSettings.method,
|
|
104
|
+
});
|
|
105
|
+
index_1.asperaSdk.globals.connectInstaller = new connect_sdk_js_1.ConnectInstaller({
|
|
106
|
+
sdkLocation: options.connectSettings.sdkLocation,
|
|
107
|
+
correlationId: options.connectSettings.correlationId,
|
|
108
|
+
style: 'carbon',
|
|
109
|
+
});
|
|
110
|
+
index_1.asperaSdk.globals.connectAW4 = {
|
|
111
|
+
Connect: connect_sdk_js_1.Connect,
|
|
112
|
+
ConnectInstaller: connect_sdk_js_1.ConnectInstaller,
|
|
113
|
+
};
|
|
114
|
+
return (0, core_2.initConnect)(!options.connectSettings.hideIncludedInstaller);
|
|
115
|
+
};
|
|
116
|
+
var getDesktopStartCalls = function () {
|
|
117
|
+
return index_1.asperaSdk.activityTracking.setup()
|
|
118
|
+
.then(function () { return (0, exports.testConnection)(); })
|
|
119
|
+
.then(function () { return (0, exports.initDragDrop)(true); })
|
|
120
|
+
.then(function () { return index_1.asperaSdk.globals.sdkResponseData; })
|
|
121
|
+
.catch(handleErrors);
|
|
122
|
+
};
|
|
123
|
+
if (((_c = options === null || options === void 0 ? void 0 : options.httpGatewaySettings) === null || _c === void 0 ? void 0 : _c.url) && !index_1.asperaSdk.globals.httpGatewayVerified) {
|
|
124
|
+
var finalHttpGatewayUrl = options.httpGatewaySettings.url.trim();
|
|
125
|
+
if (finalHttpGatewayUrl.indexOf('http') !== 0) {
|
|
126
|
+
finalHttpGatewayUrl = "https://".concat(finalHttpGatewayUrl);
|
|
127
|
+
}
|
|
128
|
+
if (finalHttpGatewayUrl.endsWith('/')) {
|
|
129
|
+
finalHttpGatewayUrl = finalHttpGatewayUrl.slice(0, -1);
|
|
130
|
+
}
|
|
131
|
+
index_1.asperaSdk.globals.httpGatewayUrl = finalHttpGatewayUrl;
|
|
132
|
+
return fetch("".concat(index_1.asperaSdk.globals.httpGatewayUrl, "/info"), { method: 'GET' }).then(function (response) {
|
|
133
|
+
return response.json().then(function (responseData) {
|
|
134
|
+
if (response.status >= 400) {
|
|
135
|
+
throw Error(responseData);
|
|
136
|
+
}
|
|
137
|
+
return responseData;
|
|
138
|
+
});
|
|
139
|
+
}).then(function (response) {
|
|
140
|
+
var _a, _b;
|
|
141
|
+
index_1.asperaSdk.globals.httpGatewayInfo = response;
|
|
142
|
+
index_1.asperaSdk.globals.httpGatewayVerified = true;
|
|
143
|
+
var iframeContainer = document.createElement('div');
|
|
144
|
+
iframeContainer.id = 'aspera-http-gateway-iframes';
|
|
145
|
+
iframeContainer.style = 'display: none;';
|
|
146
|
+
document.body.appendChild(iframeContainer);
|
|
147
|
+
index_1.asperaSdk.globals.httpGatewayIframeContainer = iframeContainer;
|
|
148
|
+
if ((_a = options === null || options === void 0 ? void 0 : options.httpGatewaySettings) === null || _a === void 0 ? void 0 : _a.forceGateway) {
|
|
149
|
+
return Promise.resolve(index_1.asperaSdk.globals.sdkResponseData);
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
return ((_b = options === null || options === void 0 ? void 0 : options.connectSettings) === null || _b === void 0 ? void 0 : _b.useConnect) ? getConnectStartCalls() : getDesktopStartCalls();
|
|
153
|
+
}
|
|
154
|
+
}).catch(function (error) {
|
|
155
|
+
var _a;
|
|
156
|
+
// If HTTP Gateway fails log and move on to desktop
|
|
157
|
+
(0, helpers_1.errorLog)(messages_1.messages.httpInitFail, error);
|
|
158
|
+
return ((_a = options === null || options === void 0 ? void 0 : options.connectSettings) === null || _a === void 0 ? void 0 : _a.useConnect) ? getConnectStartCalls() : getDesktopStartCalls();
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
return ((_d = options === null || options === void 0 ? void 0 : options.connectSettings) === null || _d === void 0 ? void 0 : _d.useConnect) ? getConnectStartCalls() : getDesktopStartCalls();
|
|
84
162
|
};
|
|
85
163
|
exports.init = init;
|
|
86
164
|
/**
|
|
87
165
|
* Start a transfer
|
|
88
166
|
*
|
|
89
167
|
* @param transferSpec standard transferSpec for transfer
|
|
90
|
-
* @param asperaSdkSpec IBM Aspera settings when starting a transfer
|
|
168
|
+
* @param asperaSdkSpec IBM Aspera settings when starting a transfer.
|
|
91
169
|
*
|
|
92
170
|
* @returns a promise that resolves if transfer initiation is successful and rejects if transfer cannot be started
|
|
93
171
|
*/
|
|
94
172
|
var startTransfer = function (transferSpec, asperaSdkSpec) {
|
|
95
|
-
if (!index_1.asperaSdk.isReady) {
|
|
96
|
-
return (0, helpers_1.throwError)(messages_1.messages.serverNotVerified);
|
|
97
|
-
}
|
|
98
173
|
if (!(0, helpers_1.isValidTransferSpec)(transferSpec)) {
|
|
99
174
|
return (0, helpers_1.throwError)(messages_1.messages.notValidTransferSpec, { transferSpec: transferSpec });
|
|
100
175
|
}
|
|
176
|
+
if (index_1.asperaSdk.useHttpGateway) {
|
|
177
|
+
return transferSpec.direction === 'receive' ? (0, http_gateway_1.httpDownload)(transferSpec, asperaSdkSpec) : (0, http_gateway_1.httpUpload)(transferSpec, asperaSdkSpec);
|
|
178
|
+
}
|
|
179
|
+
else if (index_1.asperaSdk.useConnect) {
|
|
180
|
+
return index_1.asperaSdk.globals.connect.startTransferPromise(transferSpec, asperaSdkSpec).then(function (response) {
|
|
181
|
+
return response.transfer_specs[0];
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
else if (!index_1.asperaSdk.isReady) {
|
|
185
|
+
return (0, helpers_1.throwError)(messages_1.messages.serverNotVerified);
|
|
186
|
+
}
|
|
101
187
|
var promiseInfo = (0, helpers_1.generatePromiseObjects)();
|
|
102
188
|
var payload = {
|
|
103
189
|
transfer_spec: transferSpec,
|
|
@@ -133,28 +219,6 @@ var deregisterActivityCallback = function (id) {
|
|
|
133
219
|
index_1.asperaSdk.activityTracking.removeCallback(id);
|
|
134
220
|
};
|
|
135
221
|
exports.deregisterActivityCallback = deregisterActivityCallback;
|
|
136
|
-
/**
|
|
137
|
-
* Register a callback event for when a user removes or cancels a transfer
|
|
138
|
-
* directly from IBM Aspera. This may also be called if IBM Aspera
|
|
139
|
-
* is configured to automatically remove completed transfers.
|
|
140
|
-
*
|
|
141
|
-
* @param callback callback function to receive transfers
|
|
142
|
-
*
|
|
143
|
-
* @returns ID representing the callback for deregistration purposes
|
|
144
|
-
*/
|
|
145
|
-
var registerRemovedCallback = function (callback) {
|
|
146
|
-
return index_1.asperaSdk.activityTracking.setRemovedCallback(callback);
|
|
147
|
-
};
|
|
148
|
-
exports.registerRemovedCallback = registerRemovedCallback;
|
|
149
|
-
/**
|
|
150
|
-
* Remove a callback from the removed transfer callback
|
|
151
|
-
*
|
|
152
|
-
* @param id the ID returned by `registerRemovedCallback`
|
|
153
|
-
*/
|
|
154
|
-
var deregisterRemovedCallback = function (id) {
|
|
155
|
-
index_1.asperaSdk.activityTracking.removeRemovedCallback(id);
|
|
156
|
-
};
|
|
157
|
-
exports.deregisterRemovedCallback = deregisterRemovedCallback;
|
|
158
222
|
/**
|
|
159
223
|
* Register a callback for getting updates about the connection status of IBM Aspera SDK.
|
|
160
224
|
*
|
|
@@ -179,28 +243,6 @@ var deregisterStatusCallback = function (id) {
|
|
|
179
243
|
index_1.asperaSdk.activityTracking.removeWebSocketEventCallback(id);
|
|
180
244
|
};
|
|
181
245
|
exports.deregisterStatusCallback = deregisterStatusCallback;
|
|
182
|
-
/**
|
|
183
|
-
* Register a callback for getting updates about the Safari extension status.
|
|
184
|
-
*
|
|
185
|
-
* This can be useful if you want to handle the case where the user enable or disable the Safari extension.
|
|
186
|
-
*
|
|
187
|
-
* @param callback callback function to receive events
|
|
188
|
-
*
|
|
189
|
-
* @returns ID representing the callback for deregistration purposes
|
|
190
|
-
*/
|
|
191
|
-
var registerSafariExtensionStatusCallback = function (callback) {
|
|
192
|
-
return index_1.asperaSdk.activityTracking.setSafariExtensionEventCallback(callback);
|
|
193
|
-
};
|
|
194
|
-
exports.registerSafariExtensionStatusCallback = registerSafariExtensionStatusCallback;
|
|
195
|
-
/**
|
|
196
|
-
* Remove a callback from getting Safari extension status events.
|
|
197
|
-
*
|
|
198
|
-
* @param id the ID returned by `registerStatusCallback`
|
|
199
|
-
*/
|
|
200
|
-
var deregisterSafariExtensionStatusCallback = function (id) {
|
|
201
|
-
index_1.asperaSdk.activityTracking.removeSafariExtensionEventCallback(id);
|
|
202
|
-
};
|
|
203
|
-
exports.deregisterSafariExtensionStatusCallback = deregisterSafariExtensionStatusCallback;
|
|
204
246
|
/**
|
|
205
247
|
* Remove a transfer. This will stop the transfer if it is in progress.
|
|
206
248
|
*
|
|
@@ -209,6 +251,12 @@ exports.deregisterSafariExtensionStatusCallback = deregisterSafariExtensionStatu
|
|
|
209
251
|
* @returns a promise that resolves if transfer is removed and rejects if transfer cannot be removed
|
|
210
252
|
*/
|
|
211
253
|
var removeTransfer = function (id) {
|
|
254
|
+
if (index_1.asperaSdk.useHttpGateway) {
|
|
255
|
+
return (0, core_1.httpRemoveTransfer)(id);
|
|
256
|
+
}
|
|
257
|
+
else if (index_1.asperaSdk.useConnect) {
|
|
258
|
+
return index_1.asperaSdk.globals.connect.removeTransfer(id);
|
|
259
|
+
}
|
|
212
260
|
if (!index_1.asperaSdk.isReady) {
|
|
213
261
|
return (0, helpers_1.throwError)(messages_1.messages.serverNotVerified);
|
|
214
262
|
}
|
|
@@ -233,6 +281,9 @@ exports.removeTransfer = removeTransfer;
|
|
|
233
281
|
* @returns a promise that resolves if transfer is stopped and rejects if transfer cannot be stopped
|
|
234
282
|
*/
|
|
235
283
|
var stopTransfer = function (id) {
|
|
284
|
+
if (index_1.asperaSdk.useConnect) {
|
|
285
|
+
return index_1.asperaSdk.globals.connect.stopTransfer(id);
|
|
286
|
+
}
|
|
236
287
|
if (!index_1.asperaSdk.isReady) {
|
|
237
288
|
return (0, helpers_1.throwError)(messages_1.messages.serverNotVerified);
|
|
238
289
|
}
|
|
@@ -258,6 +309,11 @@ exports.stopTransfer = stopTransfer;
|
|
|
258
309
|
* @returns a promise that resolves with the new transfer object if transfer is resumed
|
|
259
310
|
*/
|
|
260
311
|
var resumeTransfer = function (id, options) {
|
|
312
|
+
if (index_1.asperaSdk.useConnect) {
|
|
313
|
+
return index_1.asperaSdk.globals.connect.resumeTransfer(id, options).then(function (response) {
|
|
314
|
+
return response.transfer_spec;
|
|
315
|
+
});
|
|
316
|
+
}
|
|
261
317
|
if (!index_1.asperaSdk.isReady) {
|
|
262
318
|
return (0, helpers_1.throwError)(messages_1.messages.serverNotVerified);
|
|
263
319
|
}
|
|
@@ -283,7 +339,15 @@ exports.resumeTransfer = resumeTransfer;
|
|
|
283
339
|
* @returns a promise that resolves with the selected file(s) and rejects if user cancels dialog
|
|
284
340
|
*/
|
|
285
341
|
var showSelectFileDialog = function (options) {
|
|
286
|
-
if (
|
|
342
|
+
if (index_1.asperaSdk.useHttpGateway) {
|
|
343
|
+
return (0, core_1.httpGatewaySelectFileFolderDialog)(options, false);
|
|
344
|
+
}
|
|
345
|
+
else if (index_1.asperaSdk.useConnect) {
|
|
346
|
+
return index_1.asperaSdk.globals.connect.showSelectFileDialogPromise(options).then(function (response) {
|
|
347
|
+
return response;
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
else if (!index_1.asperaSdk.isReady) {
|
|
287
351
|
return (0, helpers_1.throwError)(messages_1.messages.serverNotVerified);
|
|
288
352
|
}
|
|
289
353
|
var promiseInfo = (0, helpers_1.generatePromiseObjects)();
|
|
@@ -308,7 +372,15 @@ exports.showSelectFileDialog = showSelectFileDialog;
|
|
|
308
372
|
* @returns a promise that resolves with the selected folder(s) and rejects if user cancels dialog
|
|
309
373
|
*/
|
|
310
374
|
var showSelectFolderDialog = function (options) {
|
|
311
|
-
if (
|
|
375
|
+
if (index_1.asperaSdk.useHttpGateway) {
|
|
376
|
+
return (0, core_1.httpGatewaySelectFileFolderDialog)(options, true);
|
|
377
|
+
}
|
|
378
|
+
else if (index_1.asperaSdk.useConnect) {
|
|
379
|
+
return index_1.asperaSdk.globals.connect.showSelectFolderDialogPromise(options).then(function (response) {
|
|
380
|
+
return response;
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
else if (!index_1.asperaSdk.isReady) {
|
|
312
384
|
return (0, helpers_1.throwError)(messages_1.messages.serverNotVerified);
|
|
313
385
|
}
|
|
314
386
|
var promiseInfo = (0, helpers_1.generatePromiseObjects)();
|
|
@@ -331,6 +403,9 @@ exports.showSelectFolderDialog = showSelectFolderDialog;
|
|
|
331
403
|
* @returns a promise that resolves when the preferences page is opened.
|
|
332
404
|
*/
|
|
333
405
|
var showPreferences = function () {
|
|
406
|
+
if (index_1.asperaSdk.useConnect) {
|
|
407
|
+
return index_1.asperaSdk.globals.connect.showPreferences();
|
|
408
|
+
}
|
|
334
409
|
if (!index_1.asperaSdk.isReady) {
|
|
335
410
|
return (0, helpers_1.throwError)(messages_1.messages.serverNotVerified);
|
|
336
411
|
}
|
|
@@ -350,10 +425,23 @@ exports.showPreferences = showPreferences;
|
|
|
350
425
|
* @returns a promise that resolves with an array of transfers.
|
|
351
426
|
*/
|
|
352
427
|
var getAllTransfers = function () {
|
|
428
|
+
var promiseInfo = (0, helpers_1.generatePromiseObjects)();
|
|
429
|
+
if (index_1.asperaSdk.useHttpGateway) {
|
|
430
|
+
return Promise.resolve((0, core_1.httpGetAllTransfers)());
|
|
431
|
+
}
|
|
432
|
+
else if (index_1.asperaSdk.useConnect) {
|
|
433
|
+
index_1.asperaSdk.globals.connect.getAllTransfers({
|
|
434
|
+
success: function (data) {
|
|
435
|
+
promiseInfo.resolver(data.transfers);
|
|
436
|
+
}, error: function (error) {
|
|
437
|
+
promiseInfo.rejecter(error);
|
|
438
|
+
},
|
|
439
|
+
});
|
|
440
|
+
return promiseInfo.promise;
|
|
441
|
+
}
|
|
353
442
|
if (!index_1.asperaSdk.isReady) {
|
|
354
443
|
return (0, helpers_1.throwError)(messages_1.messages.serverNotVerified);
|
|
355
444
|
}
|
|
356
|
-
var promiseInfo = (0, helpers_1.generatePromiseObjects)();
|
|
357
445
|
var payload = {
|
|
358
446
|
app_id: index_1.asperaSdk.globals.appId,
|
|
359
447
|
};
|
|
@@ -374,6 +462,20 @@ exports.getAllTransfers = getAllTransfers;
|
|
|
374
462
|
* @returns a promise that resolves with the transfer.
|
|
375
463
|
*/
|
|
376
464
|
var getTransfer = function (id) {
|
|
465
|
+
if (index_1.asperaSdk.useHttpGateway) {
|
|
466
|
+
var transfer = (0, core_1.httpGetTransfer)(id);
|
|
467
|
+
if (transfer) {
|
|
468
|
+
return Promise.resolve(transfer);
|
|
469
|
+
}
|
|
470
|
+
else {
|
|
471
|
+
return Promise.reject((0, helpers_1.generateErrorBody)(messages_1.messages.getTransferFailed, { reason: 'Not found' }));
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
else if (index_1.asperaSdk.useConnect) {
|
|
475
|
+
return index_1.asperaSdk.globals.connect.getTransfer(id).then(function (response) {
|
|
476
|
+
return response.transfer_info;
|
|
477
|
+
});
|
|
478
|
+
}
|
|
377
479
|
if (!index_1.asperaSdk.isReady) {
|
|
378
480
|
return (0, helpers_1.throwError)(messages_1.messages.serverNotVerified);
|
|
379
481
|
}
|
|
@@ -399,6 +501,9 @@ exports.getTransfer = getTransfer;
|
|
|
399
501
|
* @returns a promise that resolves if the file can be shown and rejects if not
|
|
400
502
|
*/
|
|
401
503
|
var showDirectory = function (id) {
|
|
504
|
+
if (index_1.asperaSdk.useConnect) {
|
|
505
|
+
return index_1.asperaSdk.globals.connect.showDirectory(id);
|
|
506
|
+
}
|
|
402
507
|
if (!index_1.asperaSdk.isReady) {
|
|
403
508
|
return (0, helpers_1.throwError)(messages_1.messages.serverNotVerified);
|
|
404
509
|
}
|
|
@@ -424,6 +529,11 @@ exports.showDirectory = showDirectory;
|
|
|
424
529
|
* @returns a promise that resolves if the transfer rate can be modified and rejects if not
|
|
425
530
|
*/
|
|
426
531
|
var modifyTransfer = function (id, options) {
|
|
532
|
+
if (index_1.asperaSdk.useConnect) {
|
|
533
|
+
return index_1.asperaSdk.globals.connect.modifyTransfer(id, options).then(function (response) {
|
|
534
|
+
return response;
|
|
535
|
+
});
|
|
536
|
+
}
|
|
427
537
|
if (!index_1.asperaSdk.isReady) {
|
|
428
538
|
return (0, helpers_1.throwError)(messages_1.messages.serverNotVerified);
|
|
429
539
|
}
|
|
@@ -478,8 +588,18 @@ exports.setBranding = setBranding;
|
|
|
478
588
|
*
|
|
479
589
|
* @param callback the function to call once the files are dropped
|
|
480
590
|
* @param elementSelector the selector of the element on the page that should watch for drop events
|
|
591
|
+
* @param connectOptions options for connect
|
|
481
592
|
*/
|
|
482
|
-
var createDropzone = function (callback, elementSelector) {
|
|
593
|
+
var createDropzone = function (callback, elementSelector, connectOptions) {
|
|
594
|
+
if (index_1.asperaSdk.useConnect) {
|
|
595
|
+
index_1.asperaSdk.globals.connect.setDragDropTargets(elementSelector, connectOptions, function (result) {
|
|
596
|
+
callback({
|
|
597
|
+
event: result.event,
|
|
598
|
+
files: result.files,
|
|
599
|
+
});
|
|
600
|
+
});
|
|
601
|
+
return;
|
|
602
|
+
}
|
|
483
603
|
var elements = document.querySelectorAll(elementSelector);
|
|
484
604
|
if (!elements || !elements.length) {
|
|
485
605
|
(0, helpers_1.errorLog)(messages_1.messages.unableToFindElementOnPage);
|
|
@@ -490,8 +610,8 @@ var createDropzone = function (callback, elementSelector) {
|
|
|
490
610
|
};
|
|
491
611
|
var dropEvent = function (event) {
|
|
492
612
|
event.preventDefault();
|
|
493
|
-
var files = [];
|
|
494
613
|
if (event.dataTransfer && event.dataTransfer.files && event.dataTransfer.files.length && event.dataTransfer.files[0]) {
|
|
614
|
+
var files = [];
|
|
495
615
|
for (var i = 0; i < event.dataTransfer.files.length; i++) {
|
|
496
616
|
var file = event.dataTransfer.files[i];
|
|
497
617
|
files.push({
|
|
@@ -505,11 +625,16 @@ var createDropzone = function (callback, elementSelector) {
|
|
|
505
625
|
files: files,
|
|
506
626
|
app_id: index_1.asperaSdk.globals.appId,
|
|
507
627
|
};
|
|
508
|
-
|
|
509
|
-
.
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
628
|
+
if (index_1.asperaSdk.isReady) {
|
|
629
|
+
client_1.client.request('dropped_files', payload)
|
|
630
|
+
.then(function (data) { return callback({ event: event, files: data }); })
|
|
631
|
+
.catch(function (error) {
|
|
632
|
+
(0, helpers_1.errorLog)(messages_1.messages.unableToReadDropped, error);
|
|
633
|
+
});
|
|
634
|
+
}
|
|
635
|
+
else if (index_1.asperaSdk.httpGatewayIsReady) {
|
|
636
|
+
(0, core_1.handleHttpGatewayDrop)(event.dataTransfer.items, callback, event);
|
|
637
|
+
}
|
|
513
638
|
}
|
|
514
639
|
};
|
|
515
640
|
elements.forEach(function (element) {
|
|
@@ -544,11 +669,14 @@ exports.removeDropzone = removeDropzone;
|
|
|
544
669
|
* @returns a promise that returns information about the user's IBM Aspera installation.
|
|
545
670
|
*/
|
|
546
671
|
var getInfo = function () {
|
|
672
|
+
if (index_1.asperaSdk.useHttpGateway || index_1.asperaSdk.useConnect) {
|
|
673
|
+
return Promise.resolve(index_1.asperaSdk.globals.sdkResponseData);
|
|
674
|
+
}
|
|
547
675
|
if (!index_1.asperaSdk.isReady) {
|
|
548
676
|
return (0, helpers_1.throwError)(messages_1.messages.serverNotVerified);
|
|
549
677
|
}
|
|
550
678
|
return new Promise(function (resolve, _) {
|
|
551
|
-
resolve(index_1.asperaSdk.globals.
|
|
679
|
+
resolve(index_1.asperaSdk.globals.sdkResponseData);
|
|
552
680
|
});
|
|
553
681
|
};
|
|
554
682
|
exports.getInfo = getInfo;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as ConnectTypes from '@ibm-aspera/connect-sdk-js/dist/esm/core/types';
|
|
2
|
+
/**
|
|
3
|
+
* Connect Core Logic
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* Most logic is called directly by Desktop SDK functions
|
|
7
|
+
* You may not need to import anything from this file.
|
|
8
|
+
*/
|
|
9
|
+
export declare const handleTransfers: (transfers: ConnectTypes.TransferInfo[]) => void;
|
|
10
|
+
export declare const connectInstallationFlow: () => void;
|
|
11
|
+
export declare const initConnect: (useIncludedInstaller?: boolean) => Promise<unknown>;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.initConnect = exports.connectInstallationFlow = exports.handleTransfers = void 0;
|
|
4
|
+
var index_1 = require("../index");
|
|
5
|
+
var connect_sdk_js_1 = require("@ibm-aspera/connect-sdk-js");
|
|
6
|
+
var transferMonitorActivated = false;
|
|
7
|
+
var installerFlowActivated = false;
|
|
8
|
+
/**
|
|
9
|
+
* Connect Core Logic
|
|
10
|
+
*
|
|
11
|
+
* @remarks
|
|
12
|
+
* Most logic is called directly by Desktop SDK functions
|
|
13
|
+
* You may not need to import anything from this file.
|
|
14
|
+
*/
|
|
15
|
+
var handleTransfers = function (transfers) {
|
|
16
|
+
index_1.asperaSdk.activityTracking.handleTransferActivity({
|
|
17
|
+
type: 'transferUpdated',
|
|
18
|
+
data: { transfers: transfers },
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
exports.handleTransfers = handleTransfers;
|
|
22
|
+
var connectInstallationFlow = function () {
|
|
23
|
+
if (installerFlowActivated) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
installerFlowActivated = true;
|
|
27
|
+
var handleInstallerEvent = function (eventType, eventStatus) {
|
|
28
|
+
// Verify that the event matches
|
|
29
|
+
if (index_1.asperaSdk.globals.connectAW4.Connect.EVENT.STATUS !== eventType) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
// Depending on status show the proper installer screen
|
|
33
|
+
switch (eventStatus) {
|
|
34
|
+
case index_1.asperaSdk.globals.connectAW4.Connect.STATUS.INITIALIZING:
|
|
35
|
+
index_1.asperaSdk.globals.connectInstaller.showLaunching();
|
|
36
|
+
break;
|
|
37
|
+
case index_1.asperaSdk.globals.connectAW4.Connect.STATUS.EXTENSION_INSTALL:
|
|
38
|
+
index_1.asperaSdk.globals.connectInstaller.showExtensionInstall();
|
|
39
|
+
break;
|
|
40
|
+
case index_1.asperaSdk.globals.connectAW4.Connect.STATUS.FAILED:
|
|
41
|
+
index_1.asperaSdk.globals.connectInstaller.showDownload();
|
|
42
|
+
break;
|
|
43
|
+
case index_1.asperaSdk.globals.connectAW4.Connect.STATUS.OUTDATED:
|
|
44
|
+
index_1.asperaSdk.globals.connectInstaller.showUpdate();
|
|
45
|
+
break;
|
|
46
|
+
case index_1.asperaSdk.globals.connectAW4.Connect.STATUS.RUNNING:
|
|
47
|
+
index_1.asperaSdk.globals.connectInstaller.connected();
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
index_1.asperaSdk.globals.connect.addEventListener(index_1.asperaSdk.globals.connectAW4.Connect.EVENT.STATUS, handleInstallerEvent);
|
|
52
|
+
};
|
|
53
|
+
exports.connectInstallationFlow = connectInstallationFlow;
|
|
54
|
+
var initConnect = function (useIncludedInstaller) {
|
|
55
|
+
index_1.asperaSdk.globals.connect.addEventListener(connect_sdk_js_1.Connect.EVENT.STATUS, function (eventType, eventStatus) {
|
|
56
|
+
if (eventType === connect_sdk_js_1.Connect.EVENT.STATUS) {
|
|
57
|
+
index_1.asperaSdk.globals.connectStatus = eventStatus;
|
|
58
|
+
index_1.asperaSdk.activityTracking.sendManualEventCallback(eventStatus);
|
|
59
|
+
if (eventStatus === 'RUNNING' && !transferMonitorActivated) {
|
|
60
|
+
transferMonitorActivated = true;
|
|
61
|
+
index_1.asperaSdk.globals.connect.addEventListener(connect_sdk_js_1.Connect.EVENT.TRANSFER, function (_event, data) {
|
|
62
|
+
(0, exports.handleTransfers)(data.transfers);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
index_1.asperaSdk.globals.connect.initSession(index_1.asperaSdk.globals.appId);
|
|
68
|
+
if (useIncludedInstaller) {
|
|
69
|
+
(0, exports.connectInstallationFlow)();
|
|
70
|
+
}
|
|
71
|
+
return Promise.resolve({ connectMode: true });
|
|
72
|
+
};
|
|
73
|
+
exports.initConnect = initConnect;
|
|
@@ -5,4 +5,4 @@ export declare const protocol = "aspera://";
|
|
|
5
5
|
/** @ignore */
|
|
6
6
|
export declare const baseInstallerUrl = "https://downloads.ibmaspera.com/downloads/desktop";
|
|
7
7
|
/** @ignore */
|
|
8
|
-
export declare const installerUrl
|
|
8
|
+
export declare const installerUrl = "https://downloads.ibmaspera.com/downloads/desktop/latest/stable";
|
|
@@ -27,4 +27,9 @@ export declare const messages: {
|
|
|
27
27
|
websocketClosedError: string;
|
|
28
28
|
websocketClosedUnexpect: string;
|
|
29
29
|
websocketNotReady: string;
|
|
30
|
+
httpNotAvailable: string;
|
|
31
|
+
httpInitFail: string;
|
|
32
|
+
filePickerCancel: string;
|
|
33
|
+
fileNotAllowed: string;
|
|
34
|
+
httpNetworkFail: string;
|
|
30
35
|
};
|
|
@@ -30,4 +30,9 @@ exports.messages = {
|
|
|
30
30
|
websocketClosedError: 'The websocket was closed due to an error',
|
|
31
31
|
websocketClosedUnexpect: 'The websocket was closed unexpectedly',
|
|
32
32
|
websocketNotReady: 'The websocket is not ready. Run init first',
|
|
33
|
+
httpNotAvailable: 'IBM Aspera HTTP Gateway is not available',
|
|
34
|
+
httpInitFail: 'IBM Aspera HTTP Gateway could not be started',
|
|
35
|
+
filePickerCancel: 'User canceled the select file or folder dialog.',
|
|
36
|
+
fileNotAllowed: 'TransferSpec contained file not selected by user.',
|
|
37
|
+
httpNetworkFail: 'HTTP network encountered unknown error.',
|
|
33
38
|
};
|
|
@@ -43,7 +43,7 @@ var JSONRPCHttpClient = /** @class */ (function () {
|
|
|
43
43
|
headers: {
|
|
44
44
|
'content-type': 'application/json',
|
|
45
45
|
},
|
|
46
|
-
body:
|
|
46
|
+
body: (0, helpers_1.safeJsonString)(request),
|
|
47
47
|
};
|
|
48
48
|
var rpcServerURL = (0, exports.getRpcServerUrl)();
|
|
49
49
|
return fetch(rpcServerURL, options).then(function (response) {
|