@ibm-aspera/sdk 0.2.7 → 0.2.9

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.
Files changed (91) hide show
  1. package/.whitesource +3 -0
  2. package/README.md +1 -1
  3. package/dist/commonjs/app/core.d.ts +7 -21
  4. package/dist/commonjs/app/core.js +115 -47
  5. package/dist/commonjs/constants/constants.d.ts +1 -1
  6. package/dist/commonjs/constants/messages.d.ts +6 -0
  7. package/dist/commonjs/constants/messages.js +6 -0
  8. package/dist/commonjs/helpers/client/http-client.js +1 -1
  9. package/dist/commonjs/helpers/client/safari-client.js +1 -1
  10. package/dist/commonjs/helpers/helpers.d.ts +20 -2
  11. package/dist/commonjs/helpers/helpers.js +40 -2
  12. package/dist/commonjs/helpers/ws.js +2 -8
  13. package/dist/commonjs/http-gateway/core.d.ts +76 -0
  14. package/dist/commonjs/http-gateway/core.js +254 -0
  15. package/dist/commonjs/http-gateway/download.d.ts +14 -0
  16. package/dist/commonjs/http-gateway/download.js +186 -0
  17. package/dist/commonjs/http-gateway/index.d.ts +11 -0
  18. package/dist/commonjs/http-gateway/index.js +11 -0
  19. package/dist/commonjs/http-gateway/models.d.ts +16 -0
  20. package/dist/commonjs/http-gateway/models.js +2 -0
  21. package/dist/commonjs/http-gateway/upload.d.ts +14 -0
  22. package/dist/commonjs/http-gateway/upload.js +124 -0
  23. package/dist/commonjs/index.d.ts +2 -2
  24. package/dist/commonjs/index.js +36 -5
  25. package/dist/commonjs/models/aspera-sdk.model.d.ts +39 -27
  26. package/dist/commonjs/models/aspera-sdk.model.js +62 -58
  27. package/dist/commonjs/models/models.d.ts +49 -3
  28. package/dist/js/aspera-sdk.js +1 -1
  29. package/dist/js/aspera-sdk.js.LICENSE.txt +9 -1
  30. package/dist/js/aspera-sdk.js.map +1 -1
  31. package/package.json +21 -19
  32. package/.editorconfig +0 -13
  33. package/.eslintrc.js +0 -131
  34. package/.github/CODE_OF_CONDUCT.md +0 -128
  35. package/.github/CONTRIBUTING.md +0 -147
  36. package/.github/workflows/ci.yml +0 -36
  37. package/.github/workflows/documentation.yml +0 -43
  38. package/.github/workflows/npm_upload.yml +0 -30
  39. package/.husky/pre-commit +0 -4
  40. package/CHANGELOG.md +0 -165
  41. package/docs/DEVELOPMENT.md +0 -38
  42. package/example/README.md +0 -7
  43. package/example/index.html +0 -14
  44. package/example/package-lock.json +0 -2847
  45. package/example/package.json +0 -29
  46. package/example/public/404.html +0 -5
  47. package/example/public/sdk-code.js +0 -334
  48. package/example/src/App/App.scss +0 -40
  49. package/example/src/App/index.tsx +0 -174
  50. package/example/src/Views/AllTogether.tsx +0 -26
  51. package/example/src/Views/DragDrop.tsx +0 -23
  52. package/example/src/Views/Home.tsx +0 -10
  53. package/example/src/Views/Initialize.tsx +0 -21
  54. package/example/src/Views/Installer.tsx +0 -119
  55. package/example/src/Views/MonitorTransfers.tsx +0 -88
  56. package/example/src/Views/Other.tsx +0 -25
  57. package/example/src/Views/SelectItems.tsx +0 -46
  58. package/example/src/Views/StartTransfer.tsx +0 -32
  59. package/example/src/Views/Test.tsx +0 -20
  60. package/example/src/Views/Views.scss +0 -111
  61. package/example/src/helpers/index.ts +0 -19
  62. package/example/src/index.scss +0 -47
  63. package/example/src/main.tsx +0 -17
  64. package/example/src/vite-env.d.ts +0 -2
  65. package/example/tsconfig.json +0 -30
  66. package/example/vite.config.ts +0 -22
  67. package/jest.config.js +0 -15
  68. package/jest.setup.js +0 -0
  69. package/src/app/core.ts +0 -611
  70. package/src/app/installer.ts +0 -53
  71. package/src/constants/constants.ts +0 -19
  72. package/src/constants/messages.ts +0 -29
  73. package/src/helpers/client/client.ts +0 -11
  74. package/src/helpers/client/http-client.ts +0 -92
  75. package/src/helpers/client/safari-client.ts +0 -334
  76. package/src/helpers/helpers.ts +0 -214
  77. package/src/helpers/http.ts +0 -39
  78. package/src/helpers/ws.ts +0 -215
  79. package/src/index.ts +0 -78
  80. package/src/models/aspera-sdk.model.ts +0 -399
  81. package/src/models/models.ts +0 -676
  82. package/tests/client.spec.ts +0 -52
  83. package/tests/core.spec.ts +0 -13
  84. package/tests/helpers.spec.ts +0 -124
  85. package/tests/http.spec.ts +0 -14
  86. package/tests/installer.spec.ts +0 -135
  87. package/tests/mocks.ts +0 -11
  88. package/tsconfig.json +0 -13
  89. package/tsconfig.module.json +0 -16
  90. package/typedoc.js +0 -17
  91. package/webpack.config.js +0 -35
package/src/app/core.ts DELETED
@@ -1,611 +0,0 @@
1
- import {messages} from '../constants/messages';
2
- import {client} from '../helpers/client/client';
3
- import {errorLog, generateErrorBody, generatePromiseObjects, isValidTransferSpec, randomUUID, throwError} from '../helpers/helpers';
4
- import {asperaSdk} from '../index';
5
- import {AsperaSdkInfo, TransferResponse} from '../models/aspera-sdk.model';
6
- import {CustomBrandingOptions, DataTransferResponse, AsperaSdkSpec, BrowserStyleFile, AsperaSdkTransfer, FileDialogOptions, FolderDialogOptions, InitOptions, ModifyTransferOptions, ResumeTransferOptions, SafariExtensionEvent, TransferSpec, WebsocketEvent} from '../models/models';
7
-
8
- /**
9
- * Check if IBM Aspera for Desktop connection works. This function is called by init
10
- * when initializing the SDK. This function can be used at any point for checking.
11
- *
12
- * @returns a promise that resolves if server can connect or rejects if not
13
- */
14
- export const testConnection = (): Promise<any> => {
15
- return client.request('get_info')
16
- .then((data: AsperaSdkInfo) => {
17
- asperaSdk.globals.AsperaSdkInfo = data;
18
- asperaSdk.globals.asperaAppVerified = true;
19
- return data;
20
- });
21
- };
22
-
23
- /**
24
- * Initialize drag and drop.
25
- *
26
- * @returns a promise that resolves if the initialization was successful or not
27
- */
28
- export const initDragDrop = (): Promise<boolean> => {
29
- if (!asperaSdk.isReady) {
30
- return throwError(messages.serverNotVerified);
31
- }
32
-
33
- const promiseInfo = generatePromiseObjects();
34
-
35
- client.request('init_drag_drop')
36
- .then((data: boolean) => promiseInfo.resolver(data))
37
- .catch(error => {
38
- errorLog(messages.dragDropInitFailed, error);
39
- promiseInfo.rejecter(generateErrorBody(messages.dragDropInitFailed, error));
40
- });
41
-
42
- return promiseInfo.promise;
43
- };
44
-
45
- /**
46
- * Initialize IBM Aspera client. If client cannot (reject/catch), then
47
- * client should attempt fixing server URL or trying again. If still fails disable UI elements.
48
- *
49
- * @param options initialization options:
50
- *
51
- * - `appId` the unique ID for the website. Transfers initiated during this session
52
- * will be associated with this ID. It is recommended to use a unique ID to keep transfer
53
- * information private from other websites.
54
- *
55
- * - `supportMultipleUsers` when enabled (defaults to false), the SDK will iterate over a port
56
- * range and generate a session id to determine the running instance of the desktop app for the
57
- * current user. This is needed when multiple users may be logged into the same machine
58
- * simultaneously, for example on a Windows Server.
59
- *
60
- * @returns a promise that resolves if IBM Aspera Desktop is running properly or
61
- * rejects if unable to connect
62
- */
63
- export const init = (options?: InitOptions): Promise<any> => {
64
- const appId = options?.appId ?? randomUUID();
65
- const supportMultipleUsers = options?.supportMultipleUsers ?? false;
66
-
67
- asperaSdk.globals.appId = appId;
68
-
69
- if (supportMultipleUsers) {
70
- asperaSdk.globals.supportMultipleUsers = true;
71
- asperaSdk.globals.sessionId = randomUUID();
72
- }
73
-
74
- return asperaSdk.activityTracking.setup()
75
- .then(() => testConnection())
76
- .then(() => initDragDrop())
77
- .catch(error => {
78
- errorLog(messages.serverError, error);
79
- asperaSdk.globals.asperaAppVerified = false;
80
- throw generateErrorBody(messages.serverError, error);
81
- });
82
- };
83
-
84
- /**
85
- * Start a transfer
86
- *
87
- * @param transferSpec standard transferSpec for transfer
88
- * @param asperaSdkSpec IBM Aspera settings when starting a transfer
89
- *
90
- * @returns a promise that resolves if transfer initiation is successful and rejects if transfer cannot be started
91
- */
92
- export const startTransfer = (transferSpec: TransferSpec, asperaSdkSpec: AsperaSdkSpec): Promise<AsperaSdkTransfer> => {
93
- if (!asperaSdk.isReady) {
94
- return throwError(messages.serverNotVerified);
95
- }
96
-
97
- if (!isValidTransferSpec(transferSpec)) {
98
- return throwError(messages.notValidTransferSpec, {transferSpec});
99
- }
100
-
101
- const promiseInfo = generatePromiseObjects();
102
-
103
- const payload = {
104
- transfer_spec: transferSpec,
105
- desktop_spec: asperaSdkSpec,
106
- app_id: asperaSdk.globals.appId,
107
- };
108
-
109
- client.request('start_transfer', payload)
110
- .then((data: any) => promiseInfo.resolver(data))
111
- .catch(error => {
112
- errorLog(messages.transferFailed, error);
113
- promiseInfo.rejecter(generateErrorBody(messages.transferFailed, error));
114
- });
115
-
116
- return promiseInfo.promise;
117
- };
118
-
119
- /**
120
- * Register a callback event for getting transfer updates
121
- *
122
- * @param callback callback function to receive transfers
123
- *
124
- * @returns ID representing the callback for deregistration purposes
125
- */
126
- export const registerActivityCallback = (callback: (transfers: TransferResponse) => void): string => {
127
- return asperaSdk.activityTracking.setCallback(callback);
128
- };
129
-
130
- /**
131
- * Remove a callback from the transfer callback
132
- *
133
- * @param id the ID returned by `registerActivityCallback`
134
- */
135
- export const deregisterActivityCallback = (id: string): void => {
136
- asperaSdk.activityTracking.removeCallback(id);
137
- };
138
-
139
- /**
140
- * Register a callback event for when a user removes or cancels a transfer
141
- * directly from IBM Aspera. This may also be called if IBM Aspera
142
- * is configured to automatically remove completed transfers.
143
- *
144
- * @param callback callback function to receive transfers
145
- *
146
- * @returns ID representing the callback for deregistration purposes
147
- */
148
- export const registerRemovedCallback = (callback: (transfer: AsperaSdkTransfer) => void): string => {
149
- return asperaSdk.activityTracking.setRemovedCallback(callback);
150
- };
151
-
152
- /**
153
- * Remove a callback from the removed transfer callback
154
- *
155
- * @param id the ID returned by `registerRemovedCallback`
156
- */
157
- export const deregisterRemovedCallback = (id: string): void => {
158
- asperaSdk.activityTracking.removeRemovedCallback(id);
159
- };
160
-
161
- /**
162
- * Register a callback for getting updates about the connection status of IBM Aspera SDK.
163
- *
164
- * For example, to be notified of when the SDK loses connection with the application or connection
165
- * is re-established. This can be useful if you want to handle the case where the user quits IBM Aspera
166
- * after `init` has already been called, and want to prompt the user to relaunch the application.
167
- *
168
- * @param callback callback function to receive events
169
- *
170
- * @returns ID representing the callback for deregistration purposes
171
- */
172
- export const registerStatusCallback = (callback: (status: WebsocketEvent) => void): string => {
173
- return asperaSdk.activityTracking.setWebSocketEventCallback(callback);
174
- };
175
-
176
- /**
177
- * Remove a callback from getting connection status events.
178
- *
179
- * @param id the ID returned by `registerStatusCallback`
180
- */
181
- export const deregisterStatusCallback = (id: string): void => {
182
- asperaSdk.activityTracking.removeWebSocketEventCallback(id);
183
- };
184
-
185
- /**
186
- * Register a callback for getting updates about the Safari extension status.
187
- *
188
- * This can be useful if you want to handle the case where the user enable or disable the Safari extension.
189
- *
190
- * @param callback callback function to receive events
191
- *
192
- * @returns ID representing the callback for deregistration purposes
193
- */
194
- export const registerSafariExtensionStatusCallback = (callback: (status: SafariExtensionEvent) => void): string => {
195
- return asperaSdk.activityTracking.setSafariExtensionEventCallback(callback);
196
- };
197
-
198
- /**
199
- * Remove a callback from getting Safari extension status events.
200
- *
201
- * @param id the ID returned by `registerStatusCallback`
202
- */
203
- export const deregisterSafariExtensionStatusCallback = (id: string): void => {
204
- asperaSdk.activityTracking.removeSafariExtensionEventCallback(id);
205
- };
206
-
207
- /**
208
- * Remove a transfer. This will stop the transfer if it is in progress.
209
- *
210
- * @param id transfer uuid
211
- *
212
- * @returns a promise that resolves if transfer is removed and rejects if transfer cannot be removed
213
- */
214
- export const removeTransfer = (id: string): Promise<any> => {
215
- if (!asperaSdk.isReady) {
216
- return throwError(messages.serverNotVerified);
217
- }
218
-
219
- const promiseInfo = generatePromiseObjects();
220
-
221
- const payload = {
222
- transfer_id: id,
223
- };
224
-
225
- client.request('remove_transfer', payload)
226
- .then((data: any) => promiseInfo.resolver(data))
227
- .catch(error => {
228
- errorLog(messages.removeTransferFailed, error);
229
- promiseInfo.rejecter(generateErrorBody(messages.removeTransferFailed, error));
230
- });
231
-
232
- return promiseInfo.promise;
233
- };
234
-
235
- /**
236
- * Stop a transfer.
237
- *
238
- * @param id transfer uuid
239
- *
240
- * @returns a promise that resolves if transfer is stopped and rejects if transfer cannot be stopped
241
- */
242
- export const stopTransfer = (id: string): Promise<any> => {
243
- if (!asperaSdk.isReady) {
244
- return throwError(messages.serverNotVerified);
245
- }
246
-
247
- const promiseInfo = generatePromiseObjects();
248
-
249
- const payload = {
250
- transfer_id: id,
251
- };
252
-
253
- client.request('stop_transfer', payload)
254
- .then((data: any) => promiseInfo.resolver(data))
255
- .catch(error => {
256
- errorLog(messages.stopTransferFailed, error);
257
- promiseInfo.rejecter(generateErrorBody(messages.stopTransferFailed, error));
258
- });
259
-
260
- return promiseInfo.promise;
261
- };
262
-
263
- /**
264
- * Resume a paused or failed transfer.
265
- *
266
- * @param id transfer uuid
267
- * @param options resume transfer options
268
- *
269
- * @returns a promise that resolves with the new transfer object if transfer is resumed
270
- */
271
- export const resumeTransfer = (id: string, options?: ResumeTransferOptions): Promise<AsperaSdkTransfer> => {
272
- if (!asperaSdk.isReady) {
273
- return throwError(messages.serverNotVerified);
274
- }
275
-
276
- const promiseInfo = generatePromiseObjects();
277
-
278
- const payload = {
279
- transfer_id: id,
280
- transfer_spec: options,
281
- };
282
-
283
- client.request('resume_transfer', payload)
284
- .then((data: AsperaSdkTransfer) => promiseInfo.resolver(data))
285
- .catch(error => {
286
- errorLog(messages.resumeTransferFailed, error);
287
- promiseInfo.rejecter(generateErrorBody(messages.resumeTransferFailed, error));
288
- });
289
-
290
- return promiseInfo.promise;
291
- };
292
-
293
- /**
294
- * Displays a file browser dialog for the user to select files.
295
- *
296
- * @param options file dialog options
297
- *
298
- * @returns a promise that resolves with the selected file(s) and rejects if user cancels dialog
299
- */
300
- export const showSelectFileDialog = (options?: FileDialogOptions): Promise<DataTransferResponse> => {
301
- if (!asperaSdk.isReady) {
302
- return throwError(messages.serverNotVerified);
303
- }
304
-
305
- const promiseInfo = generatePromiseObjects();
306
-
307
- const payload = {
308
- options: options || {},
309
- app_id: asperaSdk.globals.appId,
310
- };
311
-
312
- client.request('show_file_dialog', payload)
313
- .then((data: any) => promiseInfo.resolver(data))
314
- .catch(error => {
315
- errorLog(messages.showSelectFileDialogFailed, error);
316
- promiseInfo.rejecter(generateErrorBody(messages.showSelectFileDialogFailed, error));
317
- });
318
-
319
- return promiseInfo.promise;
320
- };
321
-
322
- /**
323
- * Displays a folder browser dialog for the user to select folders.
324
- *
325
- * @param options folder dialog options
326
- *
327
- * @returns a promise that resolves with the selected folder(s) and rejects if user cancels dialog
328
- */
329
- export const showSelectFolderDialog = (options?: FolderDialogOptions): Promise<DataTransferResponse> => {
330
- if (!asperaSdk.isReady) {
331
- return throwError(messages.serverNotVerified);
332
- }
333
-
334
- const promiseInfo = generatePromiseObjects();
335
-
336
- const payload = {
337
- options: options || {},
338
- app_id: asperaSdk.globals.appId,
339
- };
340
-
341
- client.request('show_folder_dialog', payload)
342
- .then((data: any) => promiseInfo.resolver(data))
343
- .catch(error => {
344
- errorLog(messages.showSelectFolderDialogFailed, error);
345
- promiseInfo.rejecter(generateErrorBody(messages.showSelectFolderDialogFailed, error));
346
- });
347
-
348
- return promiseInfo.promise;
349
- };
350
-
351
- /**
352
- * Opens the IBM Aspera preferences page.
353
- *
354
- * @returns a promise that resolves when the preferences page is opened.
355
- */
356
- export const showPreferences = (): Promise<any> => {
357
- if (!asperaSdk.isReady) {
358
- return throwError(messages.serverNotVerified);
359
- }
360
-
361
- const promiseInfo = generatePromiseObjects();
362
-
363
- client.request('open_preferences')
364
- .then((data: any) => promiseInfo.resolver(data))
365
- .catch(error => {
366
- errorLog(messages.showPreferencesFailed, error);
367
- promiseInfo.rejecter(generateErrorBody(messages.showPreferencesFailed, error));
368
- });
369
-
370
- return promiseInfo.promise;
371
- };
372
-
373
- /**
374
- * Get all transfers associated with the current application.
375
- *
376
- * @returns a promise that resolves with an array of transfers.
377
- */
378
- export const getAllTransfers = (): Promise<AsperaSdkTransfer[]> => {
379
- if (!asperaSdk.isReady) {
380
- return throwError(messages.serverNotVerified);
381
- }
382
-
383
- const promiseInfo = generatePromiseObjects();
384
-
385
- const payload = {
386
- app_id: asperaSdk.globals.appId,
387
- };
388
-
389
- client.request('get_all_transfers', payload)
390
- .then((data: AsperaSdkTransfer[]) => promiseInfo.resolver(data))
391
- .catch(error => {
392
- errorLog(messages.getAllTransfersFailed, error);
393
- promiseInfo.rejecter(generateErrorBody(messages.getAllTransfersFailed, error));
394
- });
395
-
396
- return promiseInfo.promise;
397
- };
398
-
399
- /**
400
- * Get a specific transfer by ID.
401
- *
402
- * @param id transfer uuid
403
- *
404
- * @returns a promise that resolves with the transfer.
405
- */
406
- export const getTransfer = (id: string): Promise<AsperaSdkTransfer> => {
407
- if (!asperaSdk.isReady) {
408
- return throwError(messages.serverNotVerified);
409
- }
410
-
411
- const promiseInfo = generatePromiseObjects();
412
-
413
- const payload = {
414
- transfer_id: id,
415
- };
416
-
417
- client.request('get_transfer', payload)
418
- .then((data: AsperaSdkTransfer) => promiseInfo.resolver(data))
419
- .catch(error => {
420
- errorLog(messages.getTransferFailed, error);
421
- promiseInfo.rejecter(generateErrorBody(messages.getTransferFailed, error));
422
- });
423
-
424
- return promiseInfo.promise;
425
- };
426
-
427
- /**
428
- * Opens and highlights the downloaded file in Finder or Windows Explorer. If multiple files,
429
- * then only the first file will be selected.
430
- *
431
- * @param id transfer uuid
432
- *
433
- * @returns a promise that resolves if the file can be shown and rejects if not
434
- */
435
- export const showDirectory = (id: string): Promise<any> => {
436
- if (!asperaSdk.isReady) {
437
- return throwError(messages.serverNotVerified);
438
- }
439
-
440
- const promiseInfo = generatePromiseObjects();
441
-
442
- const payload = {
443
- transfer_id: id,
444
- };
445
-
446
- client.request('show_directory', payload)
447
- .then((data: any) => promiseInfo.resolver(data))
448
- .catch(error => {
449
- errorLog(messages.showDirectoryFailed, error);
450
- promiseInfo.rejecter(generateErrorBody(messages.showDirectoryFailed, error));
451
- });
452
-
453
- return promiseInfo.promise;
454
- };
455
-
456
- /**
457
- * Modify the speed of a running transfer.
458
- *
459
- * @param id transfer uuid
460
- * @param options transfer rate options
461
- *
462
- * @returns a promise that resolves if the transfer rate can be modified and rejects if not
463
- */
464
- export const modifyTransfer = (id: string, options: ModifyTransferOptions): Promise<AsperaSdkTransfer> => {
465
- if (!asperaSdk.isReady) {
466
- return throwError(messages.serverNotVerified);
467
- }
468
-
469
- const promiseInfo = generatePromiseObjects();
470
-
471
- const payload = {
472
- transfer_id: id,
473
- transfer_spec: options,
474
- };
475
-
476
- client.request('modify_transfer', payload)
477
- .then((data: any) => promiseInfo.resolver(data))
478
- .catch(error => {
479
- errorLog(messages.modifyTransferFailed, error);
480
- promiseInfo.rejecter(generateErrorBody(messages.modifyTransferFailed, error));
481
- });
482
-
483
- return promiseInfo.promise;
484
- };
485
-
486
- /**
487
- * Set the custom branding template to be used by IBM Aspera. If the app is already
488
- * configured to use a different branding, then the branding template you specify will be
489
- * stored by the app, allowing the end user to switch at any point.
490
- *
491
- * @param id custom branding template id. This should be consistent across page loads.
492
- * @param options custom branding options
493
- *
494
- * @returns a promise that resolves if the branding was properly set.
495
- */
496
- export const setBranding = (id: string, options: CustomBrandingOptions): Promise<any> => {
497
- if (!asperaSdk.isReady) {
498
- return throwError(messages.serverNotVerified);
499
- }
500
-
501
- const promiseInfo = generatePromiseObjects();
502
-
503
- const branding = {
504
- id,
505
- name: options.name,
506
- theme: options.theme,
507
- };
508
-
509
- const payload = {
510
- branding,
511
- };
512
-
513
- client.request('update_branding', payload)
514
- .then((data: any) => promiseInfo.resolver(data))
515
- .catch(error => {
516
- errorLog(messages.setBrandingFailed, error);
517
- promiseInfo.rejecter(generateErrorBody(messages.setBrandingFailed, error));
518
- });
519
-
520
- return promiseInfo.promise;
521
- };
522
-
523
- /**
524
- * Create a dropzone for the given element selector.
525
- *
526
- * @param callback the function to call once the files are dropped
527
- * @param elementSelector the selector of the element on the page that should watch for drop events
528
- */
529
- export const createDropzone = (
530
- callback: (data: {event: any; files: DataTransferResponse}) => void,
531
- elementSelector: string,
532
- ): void => {
533
- const elements = document.querySelectorAll(elementSelector);
534
- if (!elements || !elements.length) {
535
- errorLog(messages.unableToFindElementOnPage);
536
- return;
537
- }
538
-
539
- const dragEvent = (event: any) => {
540
- event.preventDefault();
541
- };
542
-
543
- const dropEvent = (event: any) => {
544
- event.preventDefault();
545
- const files: BrowserStyleFile[] = [];
546
- if (event.dataTransfer && event.dataTransfer.files && event.dataTransfer.files.length && event.dataTransfer.files[0]) {
547
- for (let i = 0; i < event.dataTransfer.files.length; i++) {
548
- const file = event.dataTransfer.files[i];
549
- files.push({
550
- lastModified: file.lastModified,
551
- name: file.name,
552
- size: file.size,
553
- type: file.type
554
- });
555
- }
556
-
557
- const payload = {
558
- files,
559
- app_id: asperaSdk.globals.appId,
560
- };
561
-
562
- client.request('dropped_files', payload)
563
- .then((data: any) => callback({event, files: data}))
564
- .catch(error => {
565
- errorLog(messages.unableToReadDropped, error);
566
- });
567
- }
568
- };
569
-
570
- elements.forEach(element => {
571
- element.addEventListener('dragover', dragEvent);
572
- element.addEventListener('drop', dropEvent);
573
- asperaSdk.globals.dropZonesCreated.set(elementSelector, [{event: 'dragover', callback: dragEvent}, {event: 'drop', callback: dropEvent}]);
574
- });
575
- };
576
-
577
- /**
578
- * Remove dropzone.
579
- *
580
- * @param elementSelector the selector of the element on the page that should remove
581
- */
582
- export const removeDropzone = (elementSelector: string): void => {
583
- const foundDropzone = asperaSdk.globals.dropZonesCreated.get(elementSelector);
584
-
585
- if (foundDropzone) {
586
- foundDropzone.forEach(data => {
587
- const elements = document.querySelectorAll(elementSelector);
588
-
589
- if (elements && elements.length) {
590
- elements.forEach(element => {
591
- element.removeEventListener(data.event, data.callback);
592
- });
593
- }
594
- });
595
- }
596
- };
597
-
598
- /**
599
- * Get metadata about the IBM Aspera installation.
600
- *
601
- * @returns a promise that returns information about the user's IBM Aspera installation.
602
- */
603
- export const getInfo = (): Promise<AsperaSdkInfo> => {
604
- if (!asperaSdk.isReady) {
605
- return throwError(messages.serverNotVerified);
606
- }
607
-
608
- return new Promise((resolve, _) => {
609
- resolve(asperaSdk.globals.AsperaSdkInfo);
610
- });
611
- };
@@ -1,53 +0,0 @@
1
- import {asperaSdk} from '../index';
2
- import {errorLog, generateErrorBody, generatePromiseObjects, getCurrentPlatform, isValidURL, throwError} from '../helpers/helpers';
3
- import {apiGet} from '../helpers/http';
4
- import {messages} from '../constants/messages';
5
- import {InstallerInfoResponse, InstallerOptions} from '../models/models';
6
-
7
- /**
8
- * Get the latest Aspera SDK installer information such as download URL and version.
9
- *
10
- * @param options Installer info options
11
- *
12
- * @returns a promise that resolves with the installer info and rejects if there is an error
13
- */
14
- export const getInstallerInfo = (options: InstallerOptions = {}): Promise<InstallerInfoResponse> => {
15
- let url = options.endpoint || asperaSdk.globals.installerUrl;
16
-
17
- if (url.endsWith('/latest.json')) {
18
- url = url.replace('/latest.json', '');
19
- }
20
-
21
- if (!isValidURL(url)) {
22
- return throwError(messages.invalidEndpoint, {url});
23
- }
24
-
25
- const promiseInfo = generatePromiseObjects();
26
-
27
- apiGet(`${url}/latest.json`).then(response => {
28
- response.json().then((data: InstallerInfoResponse) => {
29
- if (options.endpoint) {
30
- for (const entry of data.entries) {
31
- if (!isValidURL(entry.url)) {
32
- entry.url = `${options.endpoint}/${entry.url}`;
33
- }
34
- }
35
- }
36
-
37
- if (options.all) {
38
- promiseInfo.resolver(data);
39
- } else {
40
- const platform = getCurrentPlatform();
41
- data.entries = data.entries.filter(entry => entry.platform === platform);
42
-
43
- promiseInfo.resolver(data);
44
- }
45
- });
46
- }).catch(error => {
47
- errorLog(messages.getInstallerError, error);
48
-
49
- promiseInfo.rejecter(generateErrorBody(messages.getInstallerError, error));
50
- });
51
-
52
- return promiseInfo.promise;
53
- };
@@ -1,19 +0,0 @@
1
- /** @ignore */
2
- export const hiddenStyleList = `
3
- display: none !important;
4
- width: 1px !important;
5
- height: 1px !important;
6
- position: fixed !important;
7
- z-index: -99 !important;
8
- bottom: 0px !important;
9
- right: 0px !important;
10
- `;
11
-
12
- /** @ignore */
13
- export const protocol = 'aspera://';
14
-
15
- /** @ignore */
16
- export const baseInstallerUrl = 'https://downloads.ibmaspera.com/downloads/desktop';
17
-
18
- /** @ignore */
19
- export const installerUrl = `${baseInstallerUrl}/latest/stable`;
@@ -1,29 +0,0 @@
1
- /** @ignore */
2
- export const messages = {
3
- callbackIsNotFunction: 'The provided callback is not a function',
4
- dragDropInitFailed: 'Unable to initialize drag-drop',
5
- failedToGenerateIframe: 'Unable to generate IFRAME for download. Using new window',
6
- getInstallerError: 'Unable to get latest installers',
7
- getAllTransfersFailed: 'Unable to get all transfers',
8
- getTransferFailed: 'Unable to get transfer',
9
- invalidEndpoint: 'The specified endpoint is not a valid URL',
10
- loadingProtocol: 'Launching IBM Aspera for Desktop',
11
- modifyTransferFailed: 'Unable to modify transfer',
12
- notValidTransferSpec: 'The supplied transferSpec is not valid',
13
- removeTransferFailed: 'Unable to remove transfer',
14
- resumeTransferFailed: 'Unable to resume transfer',
15
- serverError: 'Unable to connect to IBM Aspera for Desktop server',
16
- serverNotVerified: 'IBM Aspera SDK has not been verified. Run test or init first',
17
- setBrandingFailed: 'Unable to set custom branding',
18
- showDirectoryFailed: 'Unable to show transfer directory',
19
- showSelectFileDialogFailed: 'Unable to show select file dialog',
20
- showSelectFolderDialogFailed: 'Unable to show select folder dialog',
21
- showPreferencesFailed: 'Unable to show preferences',
22
- stopTransferFailed: 'Unable to stop transfer',
23
- transferFailed: 'The transfer failed to initiate',
24
- unableToFindElementOnPage: 'Unable to find the element on the current page',
25
- unableToReadDropped: 'The dropped item could not be parsed. Please try selecting via the select file/folder option',
26
- websocketClosedError: 'The websocket was closed due to an error',
27
- websocketClosedUnexpect: 'The websocket was closed unexpectedly',
28
- websocketNotReady: 'The websocket is not ready. Run init first',
29
- };