@ibm-aspera/sdk 0.2.29 → 0.4.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/README.md +17 -13
- package/dist/commonjs/app/core.d.ts +234 -0
- package/dist/commonjs/app/core.js +812 -0
- package/dist/commonjs/app/installer.d.ts +9 -0
- package/dist/commonjs/app/installer.js +50 -0
- package/dist/commonjs/connect/core.d.ts +11 -0
- package/dist/commonjs/connect/core.js +73 -0
- package/dist/commonjs/constants/constants.d.ts +8 -0
- package/dist/commonjs/constants/constants.js +11 -0
- package/dist/commonjs/constants/messages.d.ts +38 -0
- package/dist/commonjs/constants/messages.js +41 -0
- package/dist/commonjs/helpers/client/client.d.ts +5 -0
- package/dist/commonjs/helpers/client/client.js +7 -0
- package/dist/commonjs/helpers/client/http-client.d.ts +42 -0
- package/dist/commonjs/helpers/client/http-client.js +84 -0
- package/dist/commonjs/helpers/client/safari-client.d.ts +101 -0
- package/dist/commonjs/helpers/client/safari-client.js +264 -0
- package/dist/commonjs/helpers/helpers.d.ts +109 -0
- package/dist/commonjs/helpers/helpers.js +249 -0
- package/dist/commonjs/helpers/http.d.ts +16 -0
- package/dist/commonjs/helpers/http.js +42 -0
- package/dist/commonjs/helpers/ws.d.ts +62 -0
- package/dist/commonjs/helpers/ws.js +161 -0
- package/dist/commonjs/http-gateway/core.d.ts +98 -0
- package/dist/commonjs/http-gateway/core.js +388 -0
- package/dist/commonjs/http-gateway/download.d.ts +14 -0
- package/dist/commonjs/http-gateway/download.js +187 -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 +12 -0
- package/dist/commonjs/index.js +109 -0
- package/dist/commonjs/models/aspera-sdk.model.d.ts +259 -0
- package/dist/commonjs/models/aspera-sdk.model.js +349 -0
- package/dist/commonjs/models/models.d.ts +760 -0
- package/dist/commonjs/models/models.js +2 -0
- package/dist/js/aspera-sdk.js +3 -0
- package/dist/js/aspera-sdk.js.LICENSE.txt +15 -0
- package/dist/js/aspera-sdk.js.map +1 -0
- package/package.json +8 -5
- package/.editorconfig +0 -13
- package/.github/CODEOWNERS +0 -1
- package/.github/CODE_OF_CONDUCT.md +0 -128
- package/.github/CONTRIBUTING.md +0 -147
- package/.github/dependabot.yml +0 -10
- package/.github/workflows/ci.yml +0 -39
- package/.github/workflows/documentation.yml +0 -44
- package/.github/workflows/publish.yml +0 -23
- package/.github/workflows/version.yml +0 -32
- package/.whitesource +0 -3
- package/CHANGELOG.md +0 -204
- package/docs/DEVELOPMENT.md +0 -38
- package/eslint.config.js +0 -104
- package/example/README.md +0 -7
- package/example/index.html +0 -14
- package/example/package-lock.json +0 -2989
- package/example/package.json +0 -30
- package/example/public/404.html +0 -5
- package/example/public/sdk-code.js +0 -326
- package/example/src/App/App.scss +0 -40
- package/example/src/App/index.tsx +0 -196
- package/example/src/Views/AllTogether.tsx +0 -26
- package/example/src/Views/DragDrop.tsx +0 -23
- package/example/src/Views/Home.tsx +0 -10
- package/example/src/Views/Initialize.tsx +0 -31
- package/example/src/Views/Installer.tsx +0 -154
- package/example/src/Views/MonitorTransfers.tsx +0 -88
- package/example/src/Views/Other.tsx +0 -24
- package/example/src/Views/SelectItems.tsx +0 -46
- package/example/src/Views/StartTransfer.tsx +0 -37
- package/example/src/Views/Test.tsx +0 -20
- package/example/src/Views/Views.scss +0 -111
- package/example/src/helpers/index.ts +0 -19
- package/example/src/index.scss +0 -47
- package/example/src/main.tsx +0 -17
- package/example/src/vite-env.d.ts +0 -2
- package/example/tsconfig.json +0 -30
- package/example/vite.config.ts +0 -23
- package/jest.config.js +0 -19
- package/jest.setup.js +0 -0
- package/renovate.json +0 -12
- package/src/app/core.ts +0 -765
- package/src/app/installer.ts +0 -53
- package/src/connect/core.ts +0 -83
- package/src/constants/constants.ts +0 -19
- package/src/constants/messages.ts +0 -35
- package/src/helpers/client/client.ts +0 -11
- package/src/helpers/client/http-client.ts +0 -92
- package/src/helpers/client/safari-client.ts +0 -334
- package/src/helpers/helpers.ts +0 -253
- package/src/helpers/http.ts +0 -39
- package/src/helpers/ws.ts +0 -191
- package/src/http-gateway/core.ts +0 -273
- package/src/http-gateway/download.ts +0 -217
- package/src/http-gateway/index.ts +0 -19
- package/src/http-gateway/models.ts +0 -20
- package/src/http-gateway/upload.ts +0 -148
- package/src/index.ts +0 -72
- package/src/models/aspera-sdk.model.ts +0 -446
- package/src/models/models.ts +0 -740
- package/tests/client.spec.ts +0 -52
- package/tests/core.spec.ts +0 -13
- package/tests/helpers.spec.ts +0 -127
- package/tests/http.spec.ts +0 -14
- package/tests/installer.spec.ts +0 -135
- package/tests/mocks.ts +0 -11
- package/tsconfig.json +0 -14
- package/tsconfig.module.json +0 -16
- package/typedoc.js +0 -7
- package/webpack.config.js +0 -35
package/src/index.ts
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import {AsperaSdk} from './models/aspera-sdk.model';
|
|
2
|
-
import {createDropzone, deregisterActivityCallback, deregisterStatusCallback, getAllTransfers, getInfo, getTransfer, init, initDragDrop, modifyTransfer, registerActivityCallback, registerStatusCallback, removeDropzone, removeTransfer, resumeTransfer, setBranding, showDirectory, showPreferences, showSelectFileDialog, showSelectFolderDialog, startTransfer, stopTransfer, testConnection,} from './app/core';
|
|
3
|
-
import {getInstallerInfo} from './app/installer';
|
|
4
|
-
import {getInstallerUrls, isSafari} from './helpers/helpers';
|
|
5
|
-
import * as httpGatewayCalls from './http-gateway';
|
|
6
|
-
|
|
7
|
-
export const asperaSdk: AsperaSdk = new AsperaSdk();
|
|
8
|
-
|
|
9
|
-
asperaSdk.init = init;
|
|
10
|
-
asperaSdk.testConnection = testConnection;
|
|
11
|
-
asperaSdk.startTransfer = startTransfer;
|
|
12
|
-
asperaSdk.registerActivityCallback = registerActivityCallback;
|
|
13
|
-
asperaSdk.deregisterActivityCallback = deregisterActivityCallback;
|
|
14
|
-
asperaSdk.removeTransfer = removeTransfer;
|
|
15
|
-
asperaSdk.showDirectory = showDirectory;
|
|
16
|
-
asperaSdk.stopTransfer = stopTransfer;
|
|
17
|
-
asperaSdk.resumeTransfer = resumeTransfer;
|
|
18
|
-
asperaSdk.getAllTransfers = getAllTransfers;
|
|
19
|
-
asperaSdk.getTransfer = getTransfer;
|
|
20
|
-
asperaSdk.showSelectFileDialog = showSelectFileDialog;
|
|
21
|
-
asperaSdk.showSelectFolderDialog = showSelectFolderDialog;
|
|
22
|
-
asperaSdk.showPreferences = showPreferences;
|
|
23
|
-
asperaSdk.modifyTransfer = modifyTransfer;
|
|
24
|
-
asperaSdk.createDropzone = createDropzone;
|
|
25
|
-
asperaSdk.removeDropzone = removeDropzone;
|
|
26
|
-
asperaSdk.getInstallerInfo = getInstallerInfo;
|
|
27
|
-
asperaSdk.registerStatusCallback = registerStatusCallback;
|
|
28
|
-
asperaSdk.deregisterStatusCallback = deregisterStatusCallback;
|
|
29
|
-
asperaSdk.initDragDrop = initDragDrop;
|
|
30
|
-
asperaSdk.setBranding = setBranding;
|
|
31
|
-
asperaSdk.getInfo = getInfo;
|
|
32
|
-
asperaSdk.isSafari = isSafari;
|
|
33
|
-
asperaSdk.getInstallerUrls = getInstallerUrls;
|
|
34
|
-
asperaSdk.httpGatewayCalls = httpGatewayCalls;
|
|
35
|
-
|
|
36
|
-
const launch = asperaSdk.globals.launch;
|
|
37
|
-
asperaSdk.launch = launch;
|
|
38
|
-
|
|
39
|
-
if (typeof (<any>window) === 'object') {
|
|
40
|
-
(<any>window).asperaSdk = asperaSdk;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export {
|
|
44
|
-
isSafari,
|
|
45
|
-
init,
|
|
46
|
-
testConnection,
|
|
47
|
-
startTransfer,
|
|
48
|
-
launch,
|
|
49
|
-
registerActivityCallback,
|
|
50
|
-
deregisterActivityCallback,
|
|
51
|
-
removeTransfer,
|
|
52
|
-
showDirectory,
|
|
53
|
-
stopTransfer,
|
|
54
|
-
resumeTransfer,
|
|
55
|
-
getAllTransfers,
|
|
56
|
-
getTransfer,
|
|
57
|
-
showSelectFileDialog,
|
|
58
|
-
showSelectFolderDialog,
|
|
59
|
-
showPreferences,
|
|
60
|
-
modifyTransfer,
|
|
61
|
-
createDropzone,
|
|
62
|
-
removeDropzone,
|
|
63
|
-
initDragDrop,
|
|
64
|
-
getInstallerInfo,
|
|
65
|
-
registerStatusCallback,
|
|
66
|
-
deregisterStatusCallback,
|
|
67
|
-
setBranding,
|
|
68
|
-
getInfo,
|
|
69
|
-
getInstallerUrls,
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
export default asperaSdk;
|
|
@@ -1,446 +0,0 @@
|
|
|
1
|
-
import {CustomBrandingOptions, DataTransferResponse, AsperaSdkSpec, AsperaSdkTransfer, FileDialogOptions, FolderDialogOptions, InitOptions, InstallerInfoResponse, InstallerOptions, ModifyTransferOptions, ResumeTransferOptions, SafariExtensionEvent, TransferSpec, WebsocketEvent, InstallerUrlInfo} from './models';
|
|
2
|
-
import {hiddenStyleList, installerUrl, protocol} from '../constants/constants';
|
|
3
|
-
import {messages} from '../constants/messages';
|
|
4
|
-
import {safariClient} from '../helpers/client/safari-client';
|
|
5
|
-
import {client} from '../helpers/client/client';
|
|
6
|
-
import {errorLog, isSafari} from '../helpers/helpers';
|
|
7
|
-
import {websocketService} from '../helpers/ws';
|
|
8
|
-
import {asperaSdk} from '../index';
|
|
9
|
-
import {HttpGatewayInfo} from '../http-gateway/models';
|
|
10
|
-
import * as ConnectTypes from '@ibm-aspera/connect-sdk-js/dist/esm/core/types';
|
|
11
|
-
import {Connect, ConnectInstaller} from '@ibm-aspera/connect-sdk-js';
|
|
12
|
-
|
|
13
|
-
class AsperaSdkGlobals {
|
|
14
|
-
/** The URL of the IBM Aspera HTTP server to use with the SDK */
|
|
15
|
-
asperaAppUrl = 'http://127.0.0.1';
|
|
16
|
-
/** The URL of the IBM Aspera Desktop HTTP server to use with the SDK */
|
|
17
|
-
rpcPort = 33024;
|
|
18
|
-
/** The default URL to check for latest Aspera installers */
|
|
19
|
-
installerUrl = installerUrl;
|
|
20
|
-
/** Aspera SDK info */
|
|
21
|
-
asperaSdkInfo: AsperaSdkClientInfo;
|
|
22
|
-
/** Indicate that the server has been verified as working */
|
|
23
|
-
asperaAppVerified = false;
|
|
24
|
-
/** The unique ID for the website */
|
|
25
|
-
appId: string;
|
|
26
|
-
/** Indicate if multiple session is supported */
|
|
27
|
-
supportMultipleUsers = false;
|
|
28
|
-
/** The session ID for the current user */
|
|
29
|
-
sessionId?: string;
|
|
30
|
-
/** Map of drop zones created by querySelector */
|
|
31
|
-
dropZonesCreated: Map<string, {event: string; callback: (event: any) => void}[]> = new Map();
|
|
32
|
-
/** HTTP Gateway URL after successful passing */
|
|
33
|
-
httpGatewayUrl?: string;
|
|
34
|
-
/** Indicate that the HTTP Gateway has been verified as working */
|
|
35
|
-
httpGatewayVerified = false;
|
|
36
|
-
/** HTTP Gateway info */
|
|
37
|
-
httpGatewayInfo?: HttpGatewayInfo;
|
|
38
|
-
/** Http Gateway IFRAME container */
|
|
39
|
-
httpGatewayIframeContainer?: HTMLDivElement;
|
|
40
|
-
/** Connect raw AW4 objects */
|
|
41
|
-
connectAW4?: {
|
|
42
|
-
Connect: typeof Connect,
|
|
43
|
-
ConnectInstaller: typeof ConnectInstaller,
|
|
44
|
-
};
|
|
45
|
-
/** Connect instance */
|
|
46
|
-
connect?: ConnectTypes.ConnectClientType;
|
|
47
|
-
/** Connect installer instance */
|
|
48
|
-
connectInstaller?: ConnectTypes.ConnectInstallerClientType;
|
|
49
|
-
/** Connect status */
|
|
50
|
-
connectStatus: ConnectTypes.ConnectStatusStrings = 'WAITING';
|
|
51
|
-
|
|
52
|
-
backupLaunchMethod(url: string): void {
|
|
53
|
-
window.alert(messages.loadingProtocol);
|
|
54
|
-
window.location.href = url;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Launch the IBM Aspera App via protocol url. By default, a hidden IFRAME attempts to
|
|
59
|
-
* open the app but if that fails a fallback of opening a new window happens.
|
|
60
|
-
*/
|
|
61
|
-
launch(): void {
|
|
62
|
-
try {
|
|
63
|
-
const element = document.createElement('iframe');
|
|
64
|
-
element.src = protocol;
|
|
65
|
-
element.onerror = error => {
|
|
66
|
-
errorLog(messages.failedToGenerateIframe, error);
|
|
67
|
-
this.backupLaunchMethod(protocol);
|
|
68
|
-
};
|
|
69
|
-
element.setAttribute('style', hiddenStyleList);
|
|
70
|
-
document.body.appendChild(element);
|
|
71
|
-
} catch (error) {
|
|
72
|
-
errorLog(messages.failedToGenerateIframe, error);
|
|
73
|
-
this.backupLaunchMethod(protocol);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
get sdkResponseData(): AsperaSdkInfo {
|
|
78
|
-
return {
|
|
79
|
-
verified: this.asperaAppVerified,
|
|
80
|
-
...this.asperaSdkInfo,
|
|
81
|
-
httpGateway: {
|
|
82
|
-
verified: this.httpGatewayVerified,
|
|
83
|
-
url: this.httpGatewayUrl,
|
|
84
|
-
info: this.httpGatewayInfo,
|
|
85
|
-
},
|
|
86
|
-
connect: {
|
|
87
|
-
active: this.connectStatus === 'RUNNING',
|
|
88
|
-
status: this.connectStatus,
|
|
89
|
-
},
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export interface AsperaSdkClientInfo {
|
|
95
|
-
/** The version of IBM Aspera SDK */
|
|
96
|
-
version: string;
|
|
97
|
-
/** The public key corresponding to the SSH private key generated by IBM Aspera */
|
|
98
|
-
client_pubkey?: string;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
export type AsperaSdkInfo = AsperaSdkClientInfo&{
|
|
102
|
-
verified: boolean;
|
|
103
|
-
httpGateway: {
|
|
104
|
-
verified: boolean;
|
|
105
|
-
url?: string;
|
|
106
|
-
info?: HttpGatewayInfo;
|
|
107
|
-
};
|
|
108
|
-
connect: {
|
|
109
|
-
active: boolean;
|
|
110
|
-
status: ConnectTypes.ConnectStatusStrings;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
export interface TransferResponse {
|
|
115
|
-
transfers: AsperaSdkTransfer[];
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
export type ActivityMessageTypes = 'transferUpdated'|'transferRemoved';
|
|
119
|
-
|
|
120
|
-
export interface ActivityMessage {
|
|
121
|
-
type: ActivityMessageTypes;
|
|
122
|
-
data: unknown;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
export class ActivityTracking {
|
|
126
|
-
/** Map of callbacks that receive transfer update events */
|
|
127
|
-
private activity_callbacks: Map<string, Function> = new Map();
|
|
128
|
-
/** Map of callbacks that receive connection events */
|
|
129
|
-
private event_callbacks: Map<string, Function> = new Map();
|
|
130
|
-
/** Keep track of the last WebSocket event **/
|
|
131
|
-
private lastWebSocketEvent: WebsocketEvent = 'CLOSED';
|
|
132
|
-
/** Keep track of the last notified WebSocket event **/
|
|
133
|
-
private lastNotifiedWebSocketEvent: WebsocketEvent = undefined;
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* Notify all consumers when a message is received from the websocket
|
|
137
|
-
*
|
|
138
|
-
* @param message the message received from the websocket
|
|
139
|
-
*/
|
|
140
|
-
handleTransferActivity(message: ActivityMessage): void {
|
|
141
|
-
if (message.type === 'transferUpdated' || message.type === 'transferRemoved') {
|
|
142
|
-
this.activity_callbacks.forEach(callback => {
|
|
143
|
-
if (typeof callback === 'function') {
|
|
144
|
-
callback(message.data);
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* Handle and notify if needed when a connection webSocketEvent occurs. For example, when the SDK
|
|
152
|
-
* websocket connection to IBM Aspera App is closed or reconnected.
|
|
153
|
-
*
|
|
154
|
-
* @param webSocketEvent the event type.
|
|
155
|
-
*/
|
|
156
|
-
handleWebSocketEvents(webSocketEvent: WebsocketEvent): void {
|
|
157
|
-
if (this.lastWebSocketEvent === webSocketEvent) {
|
|
158
|
-
return;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
this.lastWebSocketEvent = webSocketEvent;
|
|
162
|
-
|
|
163
|
-
this.notifyWebSocketEvent(webSocketEvent);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
/**
|
|
167
|
-
* Notify all consumers when a connection webSocketEvent occurs.
|
|
168
|
-
*
|
|
169
|
-
* @param webSocketEvent the event type.
|
|
170
|
-
*/
|
|
171
|
-
private notifyWebSocketEvent(webSocketEvent: WebsocketEvent): void {
|
|
172
|
-
if (this.lastNotifiedWebSocketEvent === webSocketEvent) {
|
|
173
|
-
return;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
this.lastNotifiedWebSocketEvent = webSocketEvent;
|
|
177
|
-
|
|
178
|
-
this.event_callbacks.forEach(callback => {
|
|
179
|
-
if (typeof callback === 'function') {
|
|
180
|
-
callback(webSocketEvent);
|
|
181
|
-
}
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
/** Trigger manual event for other event types. */
|
|
186
|
-
sendManualEventCallback(status: string): void {
|
|
187
|
-
this.event_callbacks.forEach(callback => {
|
|
188
|
-
if (typeof callback === 'function') {
|
|
189
|
-
callback(status);
|
|
190
|
-
}
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
/**
|
|
195
|
-
* Notify all consumers when the client changes status. For example, when
|
|
196
|
-
* IBM Aspera App is launched or closed.
|
|
197
|
-
*
|
|
198
|
-
* @param running whether the client is running or not.
|
|
199
|
-
*/
|
|
200
|
-
handleClientEvents(running: boolean): void {
|
|
201
|
-
let webSocketEvent: WebsocketEvent;
|
|
202
|
-
|
|
203
|
-
if (!running) {
|
|
204
|
-
webSocketEvent = 'CLOSED';
|
|
205
|
-
} else {
|
|
206
|
-
webSocketEvent = this.lastWebSocketEvent;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
this.notifyWebSocketEvent(webSocketEvent);
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
/**
|
|
213
|
-
* Notify all consumers when a Safari extension safariExtensionEvent occurs (enabled/disabled).
|
|
214
|
-
*
|
|
215
|
-
* @param safariExtensionEvent the event type.
|
|
216
|
-
*/
|
|
217
|
-
handleSafariExtensionEvents(safariExtensionEvent: SafariExtensionEvent): void {
|
|
218
|
-
asperaSdk.SAFARI_EXTENSION_STATUS = safariExtensionEvent;
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
/**
|
|
222
|
-
* Set up the activity tracking with IBM Aspera.
|
|
223
|
-
*
|
|
224
|
-
* @returns a promise that resolves when the websocket connection is established.
|
|
225
|
-
* Currently, this promise does not reject.
|
|
226
|
-
*/
|
|
227
|
-
setup(): Promise<unknown> {
|
|
228
|
-
if (asperaSdk.globals.sessionId) {
|
|
229
|
-
this.registerDesktopAppSession();
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
const finalCall = (): Promise<unknown> => {
|
|
233
|
-
if (isSafari()) {
|
|
234
|
-
return safariClient.monitorTransferActivity();
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
return websocketService.init()
|
|
238
|
-
.then(() => {
|
|
239
|
-
websocketService.registerMessage('transfer_activity', (data: ActivityMessage) => this.handleTransferActivity(data));
|
|
240
|
-
websocketService.registerEvent((status: 'CLOSED'|'RECONNECT') => this.handleWebSocketEvents(status));
|
|
241
|
-
});
|
|
242
|
-
};
|
|
243
|
-
|
|
244
|
-
if (asperaSdk.globals.supportMultipleUsers) {
|
|
245
|
-
let retryCount = 0;
|
|
246
|
-
const makeVerifyCall = (incrementIt: boolean): Promise<unknown> => {
|
|
247
|
-
if (incrementIt) {
|
|
248
|
-
asperaSdk.globals.rpcPort = asperaSdk.globals.rpcPort + 1;
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
if (asperaSdk.globals.rpcPort > 33029) {
|
|
252
|
-
retryCount++;
|
|
253
|
-
asperaSdk.globals.rpcPort = 33024;
|
|
254
|
-
|
|
255
|
-
return new Promise(resolve => setTimeout(resolve, retryCount * 1050)).then(() => makeVerifyCall(false));
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
return client.request('verify_session', {app_id: asperaSdk.globals.appId, session_id: asperaSdk.globals.sessionId})
|
|
259
|
-
.then(data => {
|
|
260
|
-
if (data.result) {
|
|
261
|
-
return finalCall();
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
return makeVerifyCall(true);
|
|
265
|
-
}).catch(() => {
|
|
266
|
-
if (retryCount > 5) {
|
|
267
|
-
asperaSdk.globals.rpcPort = 33024;
|
|
268
|
-
return Promise.reject('Unable to find port running for session');
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
return makeVerifyCall(true);
|
|
272
|
-
});
|
|
273
|
-
};
|
|
274
|
-
|
|
275
|
-
return makeVerifyCall(false);
|
|
276
|
-
} else {
|
|
277
|
-
return finalCall();
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
/**
|
|
282
|
-
* Register a callback for getting transfers back to the consumer
|
|
283
|
-
*
|
|
284
|
-
* @param callback the function to call with the array of transfers
|
|
285
|
-
*
|
|
286
|
-
* @returns the ID of the callback index
|
|
287
|
-
*/
|
|
288
|
-
setCallback(callback: (transfers: TransferResponse) => void): string {
|
|
289
|
-
if (typeof callback !== 'function') {
|
|
290
|
-
errorLog(messages.callbackIsNotFunction);
|
|
291
|
-
return;
|
|
292
|
-
}
|
|
293
|
-
const id = `callback-${this.activity_callbacks.size + 1}`;
|
|
294
|
-
this.activity_callbacks.set(id, callback);
|
|
295
|
-
return id;
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
/**
|
|
299
|
-
* Remove the callback (deregister) from the list of callbacks
|
|
300
|
-
*
|
|
301
|
-
* @param id the string of the callback to remove
|
|
302
|
-
*/
|
|
303
|
-
removeCallback(id: string): void {
|
|
304
|
-
this.activity_callbacks.delete(id);
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
/**
|
|
308
|
-
* Register a callback for getting websocket events back to the consumer
|
|
309
|
-
*
|
|
310
|
-
* @param callback the function to call with the websocket event
|
|
311
|
-
*
|
|
312
|
-
* @returns the ID of the callback index
|
|
313
|
-
*/
|
|
314
|
-
setWebSocketEventCallback(callback: (status: WebsocketEvent) => void): string {
|
|
315
|
-
if (typeof callback !== 'function') {
|
|
316
|
-
errorLog(messages.callbackIsNotFunction);
|
|
317
|
-
return;
|
|
318
|
-
}
|
|
319
|
-
const id = `callback-${this.event_callbacks.size + 1}`;
|
|
320
|
-
this.event_callbacks.set(id, callback);
|
|
321
|
-
callback(this.lastWebSocketEvent);
|
|
322
|
-
return id;
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
/**
|
|
326
|
-
* Remove the callback (deregister) from the list of callbacks
|
|
327
|
-
*
|
|
328
|
-
* @param id the string of the callback to remove
|
|
329
|
-
*/
|
|
330
|
-
removeWebSocketEventCallback(id: string): void {
|
|
331
|
-
this.event_callbacks.delete(id);
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
private registerDesktopAppSession(): void {
|
|
335
|
-
const iframe = document.createElement('iframe');
|
|
336
|
-
iframe.style.display = 'none';
|
|
337
|
-
iframe.src = `aspera://initialize?app_id=${asperaSdk.globals.appId}&session_id=${asperaSdk.globals.sessionId}`;
|
|
338
|
-
document.body.appendChild(iframe);
|
|
339
|
-
|
|
340
|
-
setTimeout(() => {
|
|
341
|
-
document.body.removeChild(iframe);
|
|
342
|
-
}, 1000);
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
export class AsperaSdk {
|
|
347
|
-
/** Global information about IBM Aspera */
|
|
348
|
-
globals: AsperaSdkGlobals = new AsperaSdkGlobals();
|
|
349
|
-
/** Activity tracking for watching transfers */
|
|
350
|
-
activityTracking: ActivityTracking = new ActivityTracking();
|
|
351
|
-
/** HTTP Gateway file store. Key is the file name. */
|
|
352
|
-
httpGatewaySelectedFiles: Map<string, File> = new Map();
|
|
353
|
-
/** Function to initialize IBM Aspera */
|
|
354
|
-
init: (options: InitOptions) => Promise<any>;
|
|
355
|
-
/** Function to test the IBM Aspera status */
|
|
356
|
-
testConnection: () => Promise<any>;
|
|
357
|
-
/** Function to initiate a transfer */
|
|
358
|
-
startTransfer: (transferSpec: TransferSpec, AsperaSdkSpec: AsperaSdkSpec) => Promise<AsperaSdkTransfer>;
|
|
359
|
-
/** Function to launch IBM Aspera */
|
|
360
|
-
launch: () => void;
|
|
361
|
-
/** Register callback for the transfer activity monitor */
|
|
362
|
-
registerActivityCallback: (callback: (transfers: TransferResponse) => void) => string;
|
|
363
|
-
/** Deregister callback to remove it from the callbacks getting transfer data */
|
|
364
|
-
deregisterActivityCallback: (id: string) => void;
|
|
365
|
-
/** Register callback for connection status events from the app */
|
|
366
|
-
registerStatusCallback: (callback: (status: WebsocketEvent) => void) => string;
|
|
367
|
-
/** Deregister callback to remove it from the callbacks getting connection events */
|
|
368
|
-
deregisterStatusCallback: (id: string) => void;
|
|
369
|
-
/** Function to remove a transfer */
|
|
370
|
-
removeTransfer: (transferId: string) => Promise<any>;
|
|
371
|
-
/** Function to show the transfer's download directory in Finder or Windows Explorer */
|
|
372
|
-
showDirectory: (transferId: string) => Promise<any>;
|
|
373
|
-
/** Function to stop a transfer */
|
|
374
|
-
stopTransfer: (transferId: string) => Promise<any>;
|
|
375
|
-
/** Function to resume a transfer */
|
|
376
|
-
resumeTransfer: (transferId: string, options?: ResumeTransferOptions) => Promise<AsperaSdkTransfer>;
|
|
377
|
-
/** Function to get a list of all transfers */
|
|
378
|
-
getAllTransfers: () => Promise<AsperaSdkTransfer[]>;
|
|
379
|
-
/** Function to get information for a specific transfer */
|
|
380
|
-
getTransfer: (transferId: string) => Promise<AsperaSdkTransfer>;
|
|
381
|
-
/** Function to display a file dialog for the user to select files. */
|
|
382
|
-
showSelectFileDialog: (options?: FileDialogOptions) => Promise<DataTransferResponse>;
|
|
383
|
-
/** Function to display a folder dialog for the user to select folders. */
|
|
384
|
-
showSelectFolderDialog: (options?: FolderDialogOptions) => Promise<DataTransferResponse>;
|
|
385
|
-
/** Function to display the IBM Aspera preferences page */
|
|
386
|
-
showPreferences: () => Promise<any>;
|
|
387
|
-
/** Function to modify a running transfer */
|
|
388
|
-
modifyTransfer: (transferId: string, options: ModifyTransferOptions) => Promise<AsperaSdkTransfer>;
|
|
389
|
-
/** Function to set custom branding for IBM Aspera */
|
|
390
|
-
setBranding: (id: string, options: CustomBrandingOptions) => Promise<any>;
|
|
391
|
-
/** Create dropzone for drop events of files */
|
|
392
|
-
createDropzone: (callback: (data: {event: any; files: DataTransferResponse}) => void, elementSelector: string) => void;
|
|
393
|
-
/** Remove dropzone for drop events of files */
|
|
394
|
-
removeDropzone: (elementSelector: string) => void;
|
|
395
|
-
/** Function to get latest installer information */
|
|
396
|
-
getInstallerInfo: (options: InstallerOptions) => Promise<InstallerInfoResponse>;
|
|
397
|
-
/** Initialize drag and drop */
|
|
398
|
-
initDragDrop: () => Promise<any>;
|
|
399
|
-
/** Function to get information about the IBM Aspera instance */
|
|
400
|
-
getInfo: () => Promise<AsperaSdkInfo>;
|
|
401
|
-
/** Function to get whether IBM Aspera is running on Safari */
|
|
402
|
-
isSafari: () => boolean;
|
|
403
|
-
/** Function to get URLs for installer management. */
|
|
404
|
-
getInstallerUrls: () => InstallerUrlInfo;
|
|
405
|
-
/** Indicate if Safari Extension is enabled. If the extension is disabled during the lifecycle this will not update to disabled. */
|
|
406
|
-
SAFARI_EXTENSION_STATUS: SafariExtensionEvent = 'DISABLED';
|
|
407
|
-
/** Aspera HTTP Gateway calls. This normally is not needed by clients but expose just in case. */
|
|
408
|
-
httpGatewayCalls: unknown;
|
|
409
|
-
/** Store of HTTP Gateway transfers */
|
|
410
|
-
httpGatewayTransferStore: Map<string, AsperaSdkTransfer> = new Map();
|
|
411
|
-
/** HTTP Gateway in app threshold limit. This can be changed globally for the app. */
|
|
412
|
-
httpGatewayInBrowserDownloadThreshold = 1000000000;
|
|
413
|
-
|
|
414
|
-
/**
|
|
415
|
-
* Check if IBM Aspera is ready to be used and has been verified.
|
|
416
|
-
*
|
|
417
|
-
* @returns a boolean indicating if SDK can be used for requests
|
|
418
|
-
*/
|
|
419
|
-
get isReady(): boolean {
|
|
420
|
-
return this.globals.asperaAppVerified && this.globals.appId !== '';
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
/** Indicate that Connect is available. */
|
|
424
|
-
get useConnect(): boolean {
|
|
425
|
-
return this.globals.connectStatus === 'RUNNING';
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
/** Indicate that HTTP Gateway is available. */
|
|
429
|
-
get httpGatewayIsReady(): boolean {
|
|
430
|
-
return !!this.globals.httpGatewayVerified;
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
/** Indicates if internal calls should use Gateway */
|
|
434
|
-
get useHttpGateway(): boolean {
|
|
435
|
-
return this.httpGatewayIsReady && !this.isReady && !this.useConnect;
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
/** Indicates if old HTTP Gateway SDK should be used (v2 and lower) */
|
|
439
|
-
get useOldHttpGateway(): boolean {
|
|
440
|
-
if (!this.useHttpGateway) {
|
|
441
|
-
return false;
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
return Number(this.globals.httpGatewayInfo.version.split('.')[0] || 3) <= 2;
|
|
445
|
-
}
|
|
446
|
-
}
|