@ibm-aspera/sdk 0.2.12 → 0.2.29
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/.editorconfig +13 -0
- package/.github/CODEOWNERS +1 -0
- package/.github/CODE_OF_CONDUCT.md +128 -0
- package/.github/CONTRIBUTING.md +147 -0
- package/.github/dependabot.yml +10 -0
- package/.github/workflows/ci.yml +39 -0
- package/.github/workflows/documentation.yml +44 -0
- package/.github/workflows/publish.yml +23 -0
- package/.github/workflows/version.yml +32 -0
- package/CHANGELOG.md +204 -0
- package/docs/DEVELOPMENT.md +38 -0
- package/eslint.config.js +104 -0
- package/example/README.md +7 -0
- package/example/index.html +14 -0
- package/example/package-lock.json +2989 -0
- package/example/package.json +30 -0
- package/example/public/404.html +5 -0
- package/example/public/sdk-code.js +326 -0
- package/example/src/App/App.scss +40 -0
- package/example/src/App/index.tsx +196 -0
- package/example/src/Views/AllTogether.tsx +26 -0
- package/example/src/Views/DragDrop.tsx +23 -0
- package/example/src/Views/Home.tsx +10 -0
- package/example/src/Views/Initialize.tsx +31 -0
- package/example/src/Views/Installer.tsx +154 -0
- package/example/src/Views/MonitorTransfers.tsx +88 -0
- package/example/src/Views/Other.tsx +24 -0
- package/example/src/Views/SelectItems.tsx +46 -0
- package/example/src/Views/StartTransfer.tsx +37 -0
- package/example/src/Views/Test.tsx +20 -0
- package/example/src/Views/Views.scss +111 -0
- package/example/src/helpers/index.ts +19 -0
- package/example/src/index.scss +47 -0
- package/example/src/main.tsx +17 -0
- package/example/src/vite-env.d.ts +2 -0
- package/example/tsconfig.json +30 -0
- package/example/vite.config.ts +23 -0
- package/jest.config.js +19 -0
- package/jest.setup.js +0 -0
- package/package.json +4 -4
- package/renovate.json +12 -0
- package/src/app/core.ts +765 -0
- package/src/app/installer.ts +53 -0
- package/src/connect/core.ts +83 -0
- package/src/constants/constants.ts +19 -0
- package/src/constants/messages.ts +35 -0
- package/src/helpers/client/client.ts +11 -0
- package/src/helpers/client/http-client.ts +92 -0
- package/src/helpers/client/safari-client.ts +334 -0
- package/src/helpers/helpers.ts +253 -0
- package/src/helpers/http.ts +39 -0
- package/src/helpers/ws.ts +191 -0
- package/src/http-gateway/core.ts +273 -0
- package/src/http-gateway/download.ts +217 -0
- package/src/http-gateway/index.ts +19 -0
- package/src/http-gateway/models.ts +20 -0
- package/src/http-gateway/upload.ts +148 -0
- package/src/index.ts +72 -0
- package/src/models/aspera-sdk.model.ts +446 -0
- package/src/models/models.ts +740 -0
- package/tests/client.spec.ts +52 -0
- package/tests/core.spec.ts +13 -0
- package/tests/helpers.spec.ts +127 -0
- package/tests/http.spec.ts +14 -0
- package/tests/installer.spec.ts +135 -0
- package/tests/mocks.ts +11 -0
- package/tsconfig.json +14 -0
- package/tsconfig.module.json +16 -0
- package/typedoc.js +7 -0
- package/webpack.config.js +35 -0
- package/dist/commonjs/app/core.d.ts +0 -191
- package/dist/commonjs/app/core.js +0 -682
- package/dist/commonjs/app/installer.d.ts +0 -9
- package/dist/commonjs/app/installer.js +0 -50
- package/dist/commonjs/connect/core.d.ts +0 -11
- package/dist/commonjs/connect/core.js +0 -73
- package/dist/commonjs/constants/constants.d.ts +0 -8
- package/dist/commonjs/constants/constants.js +0 -11
- package/dist/commonjs/constants/messages.d.ts +0 -35
- package/dist/commonjs/constants/messages.js +0 -38
- package/dist/commonjs/helpers/client/client.d.ts +0 -5
- package/dist/commonjs/helpers/client/client.js +0 -7
- package/dist/commonjs/helpers/client/http-client.d.ts +0 -42
- package/dist/commonjs/helpers/client/http-client.js +0 -84
- package/dist/commonjs/helpers/client/safari-client.d.ts +0 -101
- package/dist/commonjs/helpers/client/safari-client.js +0 -264
- package/dist/commonjs/helpers/helpers.d.ts +0 -109
- package/dist/commonjs/helpers/helpers.js +0 -249
- package/dist/commonjs/helpers/http.d.ts +0 -16
- package/dist/commonjs/helpers/http.js +0 -42
- package/dist/commonjs/helpers/ws.d.ts +0 -62
- package/dist/commonjs/helpers/ws.js +0 -176
- package/dist/commonjs/http-gateway/core.d.ts +0 -76
- package/dist/commonjs/http-gateway/core.js +0 -254
- package/dist/commonjs/http-gateway/download.d.ts +0 -14
- package/dist/commonjs/http-gateway/download.js +0 -186
- package/dist/commonjs/http-gateway/index.d.ts +0 -11
- package/dist/commonjs/http-gateway/index.js +0 -11
- package/dist/commonjs/http-gateway/models.d.ts +0 -16
- package/dist/commonjs/http-gateway/models.js +0 -2
- package/dist/commonjs/http-gateway/upload.d.ts +0 -14
- package/dist/commonjs/http-gateway/upload.js +0 -124
- package/dist/commonjs/index.d.ts +0 -8
- package/dist/commonjs/index.js +0 -100
- package/dist/commonjs/models/aspera-sdk.model.d.ts +0 -245
- package/dist/commonjs/models/aspera-sdk.model.js +0 -312
- package/dist/commonjs/models/models.d.ts +0 -712
- package/dist/commonjs/models/models.js +0 -2
- package/dist/js/aspera-sdk.js +0 -3
- package/dist/js/aspera-sdk.js.LICENSE.txt +0 -15
- package/dist/js/aspera-sdk.js.map +0 -1
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getInstallerInfo = void 0;
|
|
4
|
-
var index_1 = require("../index");
|
|
5
|
-
var helpers_1 = require("../helpers/helpers");
|
|
6
|
-
var http_1 = require("../helpers/http");
|
|
7
|
-
var messages_1 = require("../constants/messages");
|
|
8
|
-
/**
|
|
9
|
-
* Get the latest Aspera SDK installer information such as download URL and version.
|
|
10
|
-
*
|
|
11
|
-
* @param options Installer info options
|
|
12
|
-
*
|
|
13
|
-
* @returns a promise that resolves with the installer info and rejects if there is an error
|
|
14
|
-
*/
|
|
15
|
-
var getInstallerInfo = function (options) {
|
|
16
|
-
if (options === void 0) { options = {}; }
|
|
17
|
-
var url = options.endpoint || index_1.asperaSdk.globals.installerUrl;
|
|
18
|
-
if (url.endsWith('/latest.json')) {
|
|
19
|
-
url = url.replace('/latest.json', '');
|
|
20
|
-
}
|
|
21
|
-
if (!(0, helpers_1.isValidURL)(url)) {
|
|
22
|
-
return (0, helpers_1.throwError)(messages_1.messages.invalidEndpoint, { url: url });
|
|
23
|
-
}
|
|
24
|
-
var promiseInfo = (0, helpers_1.generatePromiseObjects)();
|
|
25
|
-
(0, http_1.apiGet)("".concat(url, "/latest.json")).then(function (response) {
|
|
26
|
-
response.json().then(function (data) {
|
|
27
|
-
if (options.endpoint) {
|
|
28
|
-
for (var _i = 0, _a = data.entries; _i < _a.length; _i++) {
|
|
29
|
-
var entry = _a[_i];
|
|
30
|
-
if (!(0, helpers_1.isValidURL)(entry.url)) {
|
|
31
|
-
entry.url = "".concat(options.endpoint, "/").concat(entry.url);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
if (options.all) {
|
|
36
|
-
promiseInfo.resolver(data);
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
var platform_1 = (0, helpers_1.getCurrentPlatform)();
|
|
40
|
-
data.entries = data.entries.filter(function (entry) { return entry.platform === platform_1; });
|
|
41
|
-
promiseInfo.resolver(data);
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
}).catch(function (error) {
|
|
45
|
-
(0, helpers_1.errorLog)(messages_1.messages.getInstallerError, error);
|
|
46
|
-
promiseInfo.rejecter((0, helpers_1.generateErrorBody)(messages_1.messages.getInstallerError, error));
|
|
47
|
-
});
|
|
48
|
-
return promiseInfo.promise;
|
|
49
|
-
};
|
|
50
|
-
exports.getInstallerInfo = getInstallerInfo;
|
|
@@ -1,11 +0,0 @@
|
|
|
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>;
|
|
@@ -1,73 +0,0 @@
|
|
|
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;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/** @ignore */
|
|
2
|
-
export declare const hiddenStyleList = "\n display: none !important;\n width: 1px !important;\n height: 1px !important;\n position: fixed !important;\n z-index: -99 !important;\n bottom: 0px !important;\n right: 0px !important;\n";
|
|
3
|
-
/** @ignore */
|
|
4
|
-
export declare const protocol = "aspera://";
|
|
5
|
-
/** @ignore */
|
|
6
|
-
export declare const baseInstallerUrl = "https://downloads.ibmaspera.com/downloads/desktop";
|
|
7
|
-
/** @ignore */
|
|
8
|
-
export declare const installerUrl = "https://downloads.ibmaspera.com/downloads/desktop/latest/stable";
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.installerUrl = exports.baseInstallerUrl = exports.protocol = exports.hiddenStyleList = void 0;
|
|
4
|
-
/** @ignore */
|
|
5
|
-
exports.hiddenStyleList = "\n display: none !important;\n width: 1px !important;\n height: 1px !important;\n position: fixed !important;\n z-index: -99 !important;\n bottom: 0px !important;\n right: 0px !important;\n";
|
|
6
|
-
/** @ignore */
|
|
7
|
-
exports.protocol = 'aspera://';
|
|
8
|
-
/** @ignore */
|
|
9
|
-
exports.baseInstallerUrl = 'https://downloads.ibmaspera.com/downloads/desktop';
|
|
10
|
-
/** @ignore */
|
|
11
|
-
exports.installerUrl = "".concat(exports.baseInstallerUrl, "/latest/stable");
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/** @ignore */
|
|
2
|
-
export declare const messages: {
|
|
3
|
-
callbackIsNotFunction: string;
|
|
4
|
-
dragDropInitFailed: string;
|
|
5
|
-
dragDropInitFailedInit: string;
|
|
6
|
-
failedToGenerateIframe: string;
|
|
7
|
-
getInstallerError: string;
|
|
8
|
-
getAllTransfersFailed: string;
|
|
9
|
-
getTransferFailed: string;
|
|
10
|
-
invalidEndpoint: string;
|
|
11
|
-
loadingProtocol: string;
|
|
12
|
-
modifyTransferFailed: string;
|
|
13
|
-
notValidTransferSpec: string;
|
|
14
|
-
removeTransferFailed: string;
|
|
15
|
-
resumeTransferFailed: string;
|
|
16
|
-
serverError: string;
|
|
17
|
-
serverNotVerified: string;
|
|
18
|
-
setBrandingFailed: string;
|
|
19
|
-
showDirectoryFailed: string;
|
|
20
|
-
showSelectFileDialogFailed: string;
|
|
21
|
-
showSelectFolderDialogFailed: string;
|
|
22
|
-
showPreferencesFailed: string;
|
|
23
|
-
stopTransferFailed: string;
|
|
24
|
-
transferFailed: string;
|
|
25
|
-
unableToFindElementOnPage: string;
|
|
26
|
-
unableToReadDropped: string;
|
|
27
|
-
websocketClosedError: string;
|
|
28
|
-
websocketClosedUnexpect: string;
|
|
29
|
-
websocketNotReady: string;
|
|
30
|
-
httpNotAvailable: string;
|
|
31
|
-
httpInitFail: string;
|
|
32
|
-
filePickerCancel: string;
|
|
33
|
-
fileNotAllowed: string;
|
|
34
|
-
httpNetworkFail: string;
|
|
35
|
-
};
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.messages = void 0;
|
|
4
|
-
/** @ignore */
|
|
5
|
-
exports.messages = {
|
|
6
|
-
callbackIsNotFunction: 'The provided callback is not a function',
|
|
7
|
-
dragDropInitFailed: 'Unable to initialize drag-drop',
|
|
8
|
-
dragDropInitFailedInit: 'Unable to initialize drag-drop as part of init flow',
|
|
9
|
-
failedToGenerateIframe: 'Unable to generate IFRAME for download. Using new window',
|
|
10
|
-
getInstallerError: 'Unable to get latest installers',
|
|
11
|
-
getAllTransfersFailed: 'Unable to get all transfers',
|
|
12
|
-
getTransferFailed: 'Unable to get transfer',
|
|
13
|
-
invalidEndpoint: 'The specified endpoint is not a valid URL',
|
|
14
|
-
loadingProtocol: 'Launching IBM Aspera for Desktop',
|
|
15
|
-
modifyTransferFailed: 'Unable to modify transfer',
|
|
16
|
-
notValidTransferSpec: 'The supplied transferSpec is not valid',
|
|
17
|
-
removeTransferFailed: 'Unable to remove transfer',
|
|
18
|
-
resumeTransferFailed: 'Unable to resume transfer',
|
|
19
|
-
serverError: 'Unable to connect to IBM Aspera for Desktop server',
|
|
20
|
-
serverNotVerified: 'IBM Aspera SDK has not been verified. Run test or init first',
|
|
21
|
-
setBrandingFailed: 'Unable to set custom branding',
|
|
22
|
-
showDirectoryFailed: 'Unable to show transfer directory',
|
|
23
|
-
showSelectFileDialogFailed: 'Unable to show select file dialog',
|
|
24
|
-
showSelectFolderDialogFailed: 'Unable to show select folder dialog',
|
|
25
|
-
showPreferencesFailed: 'Unable to show preferences',
|
|
26
|
-
stopTransferFailed: 'Unable to stop transfer',
|
|
27
|
-
transferFailed: 'The transfer failed to initiate',
|
|
28
|
-
unableToFindElementOnPage: 'Unable to find the element on the current page',
|
|
29
|
-
unableToReadDropped: 'The dropped item could not be parsed. Please try selecting via the select file/folder option',
|
|
30
|
-
websocketClosedError: 'The websocket was closed due to an error',
|
|
31
|
-
websocketClosedUnexpect: 'The websocket was closed unexpectedly',
|
|
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.',
|
|
38
|
-
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.client = void 0;
|
|
4
|
-
var http_client_1 = require("./http-client");
|
|
5
|
-
var safari_client_1 = require("./safari-client");
|
|
6
|
-
var helpers_1 = require("../helpers");
|
|
7
|
-
exports.client = (0, helpers_1.isSafari)() ? safari_client_1.safariClient : http_client_1.httpClient;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { JSONRPCClient } from 'json-rpc-2.0';
|
|
2
|
-
import Client from './client';
|
|
3
|
-
export declare const getRpcServerUrl: () => string;
|
|
4
|
-
/**
|
|
5
|
-
* Wraps a promise like object and returns a promise that supports catch.
|
|
6
|
-
*
|
|
7
|
-
* @param promise the HTTP promise like to wrap
|
|
8
|
-
*
|
|
9
|
-
* @returns promise for the HTTP connection with catch supporting error
|
|
10
|
-
*/
|
|
11
|
-
export declare const handlePromiseLikeErrors: (promise: PromiseLike<any>) => Promise<any>;
|
|
12
|
-
/**
|
|
13
|
-
* JSON RPC client using HTTP (fetch) as transport.
|
|
14
|
-
*/
|
|
15
|
-
declare class JSONRPCHttpClient {
|
|
16
|
-
/** JSON-RPC client used to make requests */
|
|
17
|
-
client: JSONRPCClient;
|
|
18
|
-
constructor();
|
|
19
|
-
/**
|
|
20
|
-
* Request handler for the JSON-RPC client. This function is called by the JSON-RPC library
|
|
21
|
-
* after forming the RPC request.
|
|
22
|
-
*
|
|
23
|
-
* @param request JSON-RPC request to send to the server
|
|
24
|
-
*/
|
|
25
|
-
private handleRequest;
|
|
26
|
-
request: (method: string, data: any) => PromiseLike<any>;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Client used for making requests to Aspera.
|
|
30
|
-
*/
|
|
31
|
-
declare class HttpClient implements Client {
|
|
32
|
-
/** HTTP client used to make requests */
|
|
33
|
-
httpClient: JSONRPCHttpClient;
|
|
34
|
-
constructor();
|
|
35
|
-
request: (method: string, payload?: any) => Promise<any>;
|
|
36
|
-
}
|
|
37
|
-
export declare const httpClient: HttpClient;
|
|
38
|
-
declare const _default: {
|
|
39
|
-
httpClient: HttpClient;
|
|
40
|
-
handlePromiseLikeErrors: (promise: PromiseLike<any>) => Promise<any>;
|
|
41
|
-
};
|
|
42
|
-
export default _default;
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.httpClient = exports.handlePromiseLikeErrors = exports.getRpcServerUrl = void 0;
|
|
4
|
-
var json_rpc_2_0_1 = require("json-rpc-2.0");
|
|
5
|
-
var helpers_1 = require("../helpers");
|
|
6
|
-
var index_1 = require("../../index");
|
|
7
|
-
var getRpcServerUrl = function () {
|
|
8
|
-
return "".concat(index_1.asperaSdk.globals.asperaAppUrl, ":").concat(index_1.asperaSdk.globals.rpcPort);
|
|
9
|
-
};
|
|
10
|
-
exports.getRpcServerUrl = getRpcServerUrl;
|
|
11
|
-
/**
|
|
12
|
-
* Wraps a promise like object and returns a promise that supports catch.
|
|
13
|
-
*
|
|
14
|
-
* @param promise the HTTP promise like to wrap
|
|
15
|
-
*
|
|
16
|
-
* @returns promise for the HTTP connection with catch supporting error
|
|
17
|
-
*/
|
|
18
|
-
var handlePromiseLikeErrors = function (promise) {
|
|
19
|
-
var promiseInfo = (0, helpers_1.generatePromiseObjects)();
|
|
20
|
-
promise.then(function (response) {
|
|
21
|
-
promiseInfo.resolver(response);
|
|
22
|
-
}, function (error) {
|
|
23
|
-
promiseInfo.rejecter(error);
|
|
24
|
-
});
|
|
25
|
-
return promiseInfo.promise;
|
|
26
|
-
};
|
|
27
|
-
exports.handlePromiseLikeErrors = handlePromiseLikeErrors;
|
|
28
|
-
/**
|
|
29
|
-
* JSON RPC client using HTTP (fetch) as transport.
|
|
30
|
-
*/
|
|
31
|
-
var JSONRPCHttpClient = /** @class */ (function () {
|
|
32
|
-
function JSONRPCHttpClient() {
|
|
33
|
-
var _this = this;
|
|
34
|
-
/**
|
|
35
|
-
* Request handler for the JSON-RPC client. This function is called by the JSON-RPC library
|
|
36
|
-
* after forming the RPC request.
|
|
37
|
-
*
|
|
38
|
-
* @param request JSON-RPC request to send to the server
|
|
39
|
-
*/
|
|
40
|
-
this.handleRequest = function (request) {
|
|
41
|
-
var options = {
|
|
42
|
-
method: 'POST',
|
|
43
|
-
headers: {
|
|
44
|
-
'content-type': 'application/json',
|
|
45
|
-
},
|
|
46
|
-
body: (0, helpers_1.safeJsonString)(request),
|
|
47
|
-
};
|
|
48
|
-
var rpcServerURL = (0, exports.getRpcServerUrl)();
|
|
49
|
-
return fetch(rpcServerURL, options).then(function (response) {
|
|
50
|
-
if (response.ok) {
|
|
51
|
-
return response.json().then(function (rpcResponse) { return _this.client.receive(rpcResponse); });
|
|
52
|
-
}
|
|
53
|
-
else if (request.id !== undefined) {
|
|
54
|
-
throw Promise.reject(response.statusText);
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
};
|
|
58
|
-
this.request = function (method, data) {
|
|
59
|
-
return _this.client.request(method, data);
|
|
60
|
-
};
|
|
61
|
-
this.client = new json_rpc_2_0_1.JSONRPCClient(this.handleRequest);
|
|
62
|
-
}
|
|
63
|
-
return JSONRPCHttpClient;
|
|
64
|
-
}());
|
|
65
|
-
/**
|
|
66
|
-
* Client used for making requests to Aspera.
|
|
67
|
-
*/
|
|
68
|
-
var HttpClient = /** @class */ (function () {
|
|
69
|
-
function HttpClient() {
|
|
70
|
-
var _this = this;
|
|
71
|
-
this.request = function (method, payload) {
|
|
72
|
-
if (payload === void 0) { payload = {}; }
|
|
73
|
-
return (0, exports.handlePromiseLikeErrors)(_this.httpClient.request(method, payload));
|
|
74
|
-
};
|
|
75
|
-
this.httpClient = new JSONRPCHttpClient();
|
|
76
|
-
}
|
|
77
|
-
;
|
|
78
|
-
return HttpClient;
|
|
79
|
-
}());
|
|
80
|
-
exports.httpClient = new HttpClient();
|
|
81
|
-
exports.default = {
|
|
82
|
-
httpClient: exports.httpClient,
|
|
83
|
-
handlePromiseLikeErrors: exports.handlePromiseLikeErrors,
|
|
84
|
-
};
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import Client from './client';
|
|
2
|
-
/**
|
|
3
|
-
* Interface representing a promise executor used in a promise.
|
|
4
|
-
*/
|
|
5
|
-
export interface PromiseExecutor {
|
|
6
|
-
resolve: (value: any) => void;
|
|
7
|
-
reject: (error: any) => void;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Handles communication with the Safari extension using JSON-RPC over custom events.
|
|
11
|
-
*/
|
|
12
|
-
export declare class SafariClient implements Client {
|
|
13
|
-
private keepAliveInterval;
|
|
14
|
-
private promiseExecutors;
|
|
15
|
-
private lastPing;
|
|
16
|
-
private lastPong;
|
|
17
|
-
private safariExtensionEnabled;
|
|
18
|
-
private subscribedTransferActivity;
|
|
19
|
-
/**
|
|
20
|
-
* Initializes the SafariExtensionHandler instance.
|
|
21
|
-
* Sets up the promise executor map and starts listening to extension events.
|
|
22
|
-
*/
|
|
23
|
-
constructor();
|
|
24
|
-
/**
|
|
25
|
-
* Sends a JSON-RPC request to the Safari extension.
|
|
26
|
-
* @param method The method name to invoke on the extension.
|
|
27
|
-
* @param payload Optional payload for the request.
|
|
28
|
-
* @returns A Promise that resolves with the response from the extension.
|
|
29
|
-
*/
|
|
30
|
-
request: (method: string, payload?: any) => Promise<any>;
|
|
31
|
-
/**
|
|
32
|
-
* Monitors transfer activity.
|
|
33
|
-
* @returns A Promise that resolves with the response from the extension.
|
|
34
|
-
*/
|
|
35
|
-
monitorTransferActivity(): Promise<unknown>;
|
|
36
|
-
/**
|
|
37
|
-
* Builds a JSON-RPC request object with a unique identifier.
|
|
38
|
-
* @param method The method name to invoke on the extension.
|
|
39
|
-
* @param payload Optional parameters for the method.
|
|
40
|
-
* @returns The constructed JSON-RPC request object.
|
|
41
|
-
*/
|
|
42
|
-
private buildRPCRequest;
|
|
43
|
-
/**
|
|
44
|
-
* Dispatches a custom event to the document to communicate with the Safari extension.
|
|
45
|
-
* @param type The type of Safari extension event to dispatch.
|
|
46
|
-
* @param request Optional JSON-RPC request payload to send with the event.
|
|
47
|
-
*/
|
|
48
|
-
private dispatchEvent;
|
|
49
|
-
/**
|
|
50
|
-
* Dispatches a custom event to the document to communicate with the Safari extension.
|
|
51
|
-
* @param type The type of Safari extension event to dispatch.
|
|
52
|
-
* @param method The method name to invoke on the extension.
|
|
53
|
-
* @param payload Optional parameters for the method.
|
|
54
|
-
*/
|
|
55
|
-
private dispatchPromiseEvent;
|
|
56
|
-
/**
|
|
57
|
-
* Handles incoming JSON-RPC responses from the Safari extension.
|
|
58
|
-
* Resolves or rejects promises based on the response.
|
|
59
|
-
* @param response The JSON-RPC response object received from the extension.
|
|
60
|
-
*/
|
|
61
|
-
private handleResponse;
|
|
62
|
-
/**
|
|
63
|
-
* Listens for 'AsperaDesktop.Response' events.
|
|
64
|
-
*/
|
|
65
|
-
private listenResponseEvents;
|
|
66
|
-
/**
|
|
67
|
-
* Listens for 'AsperaDesktop.TransferActivity' events.
|
|
68
|
-
*/
|
|
69
|
-
private listenTransferActivityEvents;
|
|
70
|
-
/**
|
|
71
|
-
* Listens for 'AsperaDesktop.Status' events.
|
|
72
|
-
*/
|
|
73
|
-
private listenStatusEvents;
|
|
74
|
-
/**
|
|
75
|
-
* Listens for 'isAppAlive' events. This was introduced in version 1.0.9.
|
|
76
|
-
*/
|
|
77
|
-
private listenClientStatusEvents;
|
|
78
|
-
/**
|
|
79
|
-
* Listens for 'AsperaDesktop.Pong' events.
|
|
80
|
-
*/
|
|
81
|
-
private listenPongEvents;
|
|
82
|
-
/**
|
|
83
|
-
* Sends a keep alive ping according to the defined interval.
|
|
84
|
-
*/
|
|
85
|
-
private keepAlive;
|
|
86
|
-
/**
|
|
87
|
-
* Listens for Safari extension status changes.
|
|
88
|
-
* If the extension was disabled and enabled again after initializing the SDK, it
|
|
89
|
-
* will call 'monitorTransferActivity' to resume transfer activities.
|
|
90
|
-
*/
|
|
91
|
-
private safariExtensionStatusChanged;
|
|
92
|
-
/**
|
|
93
|
-
* Checks if the last pong received was longer than the max interval.
|
|
94
|
-
*/
|
|
95
|
-
private checkSafariExtensionStatus;
|
|
96
|
-
}
|
|
97
|
-
export declare const safariClient: SafariClient;
|
|
98
|
-
declare const _default: {
|
|
99
|
-
safariClient: SafariClient;
|
|
100
|
-
};
|
|
101
|
-
export default _default;
|