@ibm-aspera/sdk 0.2.2

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 (68) hide show
  1. package/.editorconfig +13 -0
  2. package/.eslintrc.js +128 -0
  3. package/.github/CODE_OF_CONDUCT.md +128 -0
  4. package/.github/CONTRIBUTING.md +147 -0
  5. package/.github/workflows/ci.yml +36 -0
  6. package/.github/workflows/documentation.yml +43 -0
  7. package/.github/workflows/npm_upload.yml +30 -0
  8. package/.husky/pre-commit +4 -0
  9. package/CHANGELOG.md +124 -0
  10. package/LICENSE +201 -0
  11. package/README.md +25 -0
  12. package/dist/commonjs/app/core.d.ts +219 -0
  13. package/dist/commonjs/app/core.js +546 -0
  14. package/dist/commonjs/app/installer.d.ts +9 -0
  15. package/dist/commonjs/app/installer.js +50 -0
  16. package/dist/commonjs/constants/constants.d.ts +6 -0
  17. package/dist/commonjs/constants/constants.js +9 -0
  18. package/dist/commonjs/constants/messages.d.ts +29 -0
  19. package/dist/commonjs/constants/messages.js +32 -0
  20. package/dist/commonjs/helpers/client/client.d.ts +5 -0
  21. package/dist/commonjs/helpers/client/client.js +7 -0
  22. package/dist/commonjs/helpers/client/http-client.d.ts +42 -0
  23. package/dist/commonjs/helpers/client/http-client.js +84 -0
  24. package/dist/commonjs/helpers/client/safari-client.d.ts +99 -0
  25. package/dist/commonjs/helpers/client/safari-client.js +252 -0
  26. package/dist/commonjs/helpers/helpers.d.ts +84 -0
  27. package/dist/commonjs/helpers/helpers.js +197 -0
  28. package/dist/commonjs/helpers/http.d.ts +16 -0
  29. package/dist/commonjs/helpers/http.js +42 -0
  30. package/dist/commonjs/helpers/ws.d.ts +62 -0
  31. package/dist/commonjs/helpers/ws.js +182 -0
  32. package/dist/commonjs/index.d.ts +41 -0
  33. package/dist/commonjs/index.js +99 -0
  34. package/dist/commonjs/models/aspera-sdk.model.d.ts +213 -0
  35. package/dist/commonjs/models/aspera-sdk.model.js +288 -0
  36. package/dist/commonjs/models/models.d.ts +640 -0
  37. package/dist/commonjs/models/models.js +2 -0
  38. package/dist/js/aspera-sdk.js +3 -0
  39. package/dist/js/aspera-sdk.js.LICENSE.txt +7 -0
  40. package/dist/js/aspera-sdk.js.map +1 -0
  41. package/docs/DEVELOPMENT.md +38 -0
  42. package/jest.config.js +15 -0
  43. package/jest.setup.js +0 -0
  44. package/package.json +50 -0
  45. package/src/app/core.ts +610 -0
  46. package/src/app/installer.ts +53 -0
  47. package/src/constants/constants.ts +16 -0
  48. package/src/constants/messages.ts +29 -0
  49. package/src/helpers/client/client.ts +11 -0
  50. package/src/helpers/client/http-client.ts +92 -0
  51. package/src/helpers/client/safari-client.ts +318 -0
  52. package/src/helpers/helpers.ts +200 -0
  53. package/src/helpers/http.ts +39 -0
  54. package/src/helpers/ws.ts +215 -0
  55. package/src/index.html +404 -0
  56. package/src/index.ts +104 -0
  57. package/src/models/aspera-sdk.model.ts +360 -0
  58. package/src/models/models.ts +669 -0
  59. package/tests/client.spec.ts +52 -0
  60. package/tests/core.spec.ts +13 -0
  61. package/tests/helpers.spec.ts +124 -0
  62. package/tests/http.spec.ts +14 -0
  63. package/tests/installer.spec.ts +135 -0
  64. package/tests/mocks.ts +11 -0
  65. package/tsconfig.json +10 -0
  66. package/tsconfig.module.json +15 -0
  67. package/typedoc.js +17 -0
  68. package/webpack.config.js +53 -0
@@ -0,0 +1,5 @@
1
+ interface Client {
2
+ request(method: String, payload?: any): Promise<any>;
3
+ }
4
+ export declare const client: Client;
5
+ export default Client;
@@ -0,0 +1,7 @@
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;
@@ -0,0 +1,42 @@
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;
@@ -0,0 +1,84 @@
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: JSON.stringify(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
+ };
@@ -0,0 +1,99 @@
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 statusInterval;
14
+ private keepAliveInterval;
15
+ private promiseExecutors;
16
+ private isFirstPing;
17
+ private lastPing;
18
+ private lastPong;
19
+ private safariExtensionEnabled;
20
+ private subscribedTransferActivity;
21
+ /**
22
+ * Initializes the SafariExtensionHandler instance.
23
+ * Sets up the promise executor map and starts listening to extension events.
24
+ */
25
+ constructor();
26
+ /**
27
+ * Sends a JSON-RPC request to the Safari extension.
28
+ * @param method The method name to invoke on the extension.
29
+ * @param payload Optional payload for the request.
30
+ * @returns A Promise that resolves with the response from the extension.
31
+ */
32
+ request: (method: string, payload?: any) => Promise<any>;
33
+ /**
34
+ * Monitors transfer activity.
35
+ * @returns A Promise that resolves with the response from the extension.
36
+ */
37
+ monitorTransferActivity(): Promise<unknown>;
38
+ /**
39
+ * Builds a JSON-RPC request object with a unique identifier.
40
+ * @param method The method name to invoke on the extension.
41
+ * @param payload Optional parameters for the method.
42
+ * @returns The constructed JSON-RPC request object.
43
+ */
44
+ private buildRPCRequest;
45
+ /**
46
+ * Dispatches a custom event to the document to communicate with the Safari extension.
47
+ * @param type The type of Safari extension event to dispatch.
48
+ * @param request Optional JSON-RPC request payload to send with the event.
49
+ */
50
+ private dispatchEvent;
51
+ /**
52
+ * Dispatches a custom event to the document to communicate with the Safari extension.
53
+ * @param type The type of Safari extension event to dispatch.
54
+ * @param method The method name to invoke on the extension.
55
+ * @param payload Optional parameters for the method.
56
+ */
57
+ private dispatchPromiseEvent;
58
+ /**
59
+ * Handles incoming JSON-RPC responses from the Safari extension.
60
+ * Resolves or rejects promises based on the response.
61
+ * @param response The JSON-RPC response object received from the extension.
62
+ */
63
+ private handleResponse;
64
+ /**
65
+ * Listens for 'AsperaDesktop.Response' events.
66
+ */
67
+ private listenResponseEvents;
68
+ /**
69
+ * Listens for 'AsperaDesktop.TransferActivity' events.
70
+ */
71
+ private listenTransferActivityEvents;
72
+ /**
73
+ * Listens for 'AsperaDesktop.Status' events.
74
+ */
75
+ private listenStatusEvents;
76
+ /**
77
+ * Listens for 'AsperaDesktop.Pong' events.
78
+ */
79
+ private listenPongEvents;
80
+ /**
81
+ * Sends a keep alive ping according to the defined interval.
82
+ */
83
+ private keepAlive;
84
+ /**
85
+ * Listens for Safari extension status changes.
86
+ * If the extension was disabled and enabled again after initializing the SDK, it
87
+ * will call 'monitorTransferActivity' to resume transfer activities.
88
+ */
89
+ private safariExtensionStatusChanged;
90
+ /**
91
+ * Checks if the last pong received was longer than the max interval.
92
+ */
93
+ private checkSafariExtensionStatus;
94
+ }
95
+ export declare const safariClient: SafariClient;
96
+ declare const _default: {
97
+ safariClient: SafariClient;
98
+ };
99
+ export default _default;
@@ -0,0 +1,252 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.safariClient = exports.SafariClient = void 0;
4
+ var helpers_1 = require("../helpers");
5
+ var index_1 = require("../../index");
6
+ /**
7
+ * Enum defining different types of Safari extension events.
8
+ */
9
+ var SafariExtensionEventType;
10
+ (function (SafariExtensionEventType) {
11
+ SafariExtensionEventType["Monitor"] = "Monitor";
12
+ SafariExtensionEventType["Ping"] = "Ping";
13
+ SafariExtensionEventType["Request"] = "Request";
14
+ })(SafariExtensionEventType || (SafariExtensionEventType = {}));
15
+ /**
16
+ * Global keep alive timeout to prevent recursion.
17
+ */
18
+ var keepAliveTimeout;
19
+ /**
20
+ * Handles communication with the Safari extension using JSON-RPC over custom events.
21
+ */
22
+ var SafariClient = /** @class */ (function () {
23
+ /**
24
+ * Initializes the SafariExtensionHandler instance.
25
+ * Sets up the promise executor map and starts listening to extension events.
26
+ */
27
+ function SafariClient() {
28
+ var _this = this;
29
+ this.statusInterval = 100;
30
+ this.keepAliveInterval = 1000;
31
+ this.isFirstPing = true;
32
+ this.lastPing = null;
33
+ this.lastPong = null;
34
+ this.safariExtensionEnabled = false;
35
+ this.subscribedTransferActivity = false;
36
+ /**
37
+ * Sends a JSON-RPC request to the Safari extension.
38
+ * @param method The method name to invoke on the extension.
39
+ * @param payload Optional payload for the request.
40
+ * @returns A Promise that resolves with the response from the extension.
41
+ */
42
+ this.request = function (method, payload) {
43
+ if (payload === void 0) { payload = {}; }
44
+ return _this.dispatchPromiseEvent(SafariExtensionEventType.Request, method, payload);
45
+ };
46
+ this.promiseExecutors = new Map();
47
+ this.listenResponseEvents();
48
+ this.listenTransferActivityEvents();
49
+ this.listenStatusEvents();
50
+ this.listenPongEvents();
51
+ if (keepAliveTimeout) {
52
+ clearTimeout(keepAliveTimeout);
53
+ }
54
+ this.keepAlive();
55
+ }
56
+ /**
57
+ * Monitors transfer activity.
58
+ * @returns A Promise that resolves with the response from the extension.
59
+ */
60
+ SafariClient.prototype.monitorTransferActivity = function () {
61
+ var _this = this;
62
+ var dispatchMonitorEvent = function () {
63
+ var promise = _this.dispatchPromiseEvent(SafariExtensionEventType.Monitor, 'subscribe_transfer_activity', [index_1.asperaSdk.globals.appId]);
64
+ return promise.then(function () {
65
+ _this.subscribedTransferActivity = true;
66
+ });
67
+ };
68
+ if (this.safariExtensionEnabled) {
69
+ return dispatchMonitorEvent();
70
+ }
71
+ return new Promise(function (resolve, reject) {
72
+ var extensionInterval = setInterval(function () {
73
+ if (!_this.safariExtensionEnabled) {
74
+ return;
75
+ }
76
+ dispatchMonitorEvent()
77
+ .then(resolve)
78
+ .catch(reject);
79
+ clearInterval(extensionInterval);
80
+ }, 1000);
81
+ });
82
+ };
83
+ /**
84
+ * Builds a JSON-RPC request object with a unique identifier.
85
+ * @param method The method name to invoke on the extension.
86
+ * @param payload Optional parameters for the method.
87
+ * @returns The constructed JSON-RPC request object.
88
+ */
89
+ SafariClient.prototype.buildRPCRequest = function (method, payload) {
90
+ return {
91
+ jsonrpc: '2.0',
92
+ method: method,
93
+ params: payload,
94
+ id: (0, helpers_1.randomUUID)()
95
+ };
96
+ };
97
+ /**
98
+ * Dispatches a custom event to the document to communicate with the Safari extension.
99
+ * @param type The type of Safari extension event to dispatch.
100
+ * @param request Optional JSON-RPC request payload to send with the event.
101
+ */
102
+ SafariClient.prototype.dispatchEvent = function (type, request) {
103
+ var payload = {
104
+ detail: request !== null && request !== void 0 ? request : {}
105
+ };
106
+ document.dispatchEvent(new CustomEvent("AsperaDesktop.".concat(type), payload));
107
+ };
108
+ /**
109
+ * Dispatches a custom event to the document to communicate with the Safari extension.
110
+ * @param type The type of Safari extension event to dispatch.
111
+ * @param method The method name to invoke on the extension.
112
+ * @param payload Optional parameters for the method.
113
+ */
114
+ SafariClient.prototype.dispatchPromiseEvent = function (type, method, payload) {
115
+ var _this = this;
116
+ var request = this.buildRPCRequest(method, payload);
117
+ return new Promise(function (resolve, reject) {
118
+ if (_this.safariExtensionEnabled) {
119
+ _this.promiseExecutors.set(request.id, { resolve: resolve, reject: reject });
120
+ _this.dispatchEvent(type, request);
121
+ }
122
+ else {
123
+ console.warn('The Safari extension is disabled or unresponsive (dispatch event)');
124
+ console.warn("Failed event: ".concat(JSON.stringify(request)));
125
+ reject('The Safari extension is disabled or unresponsive (dispatch event)');
126
+ }
127
+ });
128
+ };
129
+ /**
130
+ * Handles incoming JSON-RPC responses from the Safari extension.
131
+ * Resolves or rejects promises based on the response.
132
+ * @param response The JSON-RPC response object received from the extension.
133
+ */
134
+ SafariClient.prototype.handleResponse = function (response) {
135
+ var requestId = response.id;
136
+ var executor = this.promiseExecutors.get(requestId);
137
+ if (!executor) {
138
+ console.warn("Unable to find a promise executor for ".concat(requestId));
139
+ console.warn("Response: ".concat(response));
140
+ return;
141
+ }
142
+ this.promiseExecutors.delete(requestId);
143
+ if (response.error) {
144
+ executor.reject(response.error);
145
+ return;
146
+ }
147
+ executor.resolve(response.result);
148
+ };
149
+ /**
150
+ * Listens for 'AsperaDesktop.Response' events.
151
+ */
152
+ SafariClient.prototype.listenResponseEvents = function () {
153
+ var _this = this;
154
+ document.addEventListener('AsperaDesktop.Response', function (event) {
155
+ _this.handleResponse(event.detail);
156
+ });
157
+ };
158
+ /**
159
+ * Listens for 'AsperaDesktop.TransferActivity' events.
160
+ */
161
+ SafariClient.prototype.listenTransferActivityEvents = function () {
162
+ document.addEventListener('AsperaDesktop.TransferActivity', function (event) {
163
+ index_1.asperaSdk.activityTracking.handleTransferActivity(event.detail);
164
+ });
165
+ };
166
+ /**
167
+ * Listens for 'AsperaDesktop.Status' events.
168
+ */
169
+ SafariClient.prototype.listenStatusEvents = function () {
170
+ document.addEventListener('AsperaDesktop.Status', function (event) {
171
+ index_1.asperaSdk.activityTracking.handleWebSocketEvents(event.detail);
172
+ });
173
+ };
174
+ /**
175
+ * Listens for 'AsperaDesktop.Pong' events.
176
+ */
177
+ SafariClient.prototype.listenPongEvents = function () {
178
+ var _this = this;
179
+ document.addEventListener('AsperaDesktop.Pong', function () {
180
+ _this.lastPong = Date.now();
181
+ _this.safariExtensionStatusChanged(true);
182
+ });
183
+ };
184
+ /**
185
+ * Sends a keep alive ping according to the defined interval.
186
+ */
187
+ SafariClient.prototype.keepAlive = function () {
188
+ var _this = this;
189
+ this.lastPing = Date.now();
190
+ this.dispatchEvent(SafariExtensionEventType.Ping);
191
+ if (this.isFirstPing) {
192
+ this.isFirstPing = false;
193
+ }
194
+ else {
195
+ setTimeout(function () {
196
+ _this.checkSafariExtensionStatus();
197
+ }, this.statusInterval);
198
+ }
199
+ keepAliveTimeout = setTimeout(function () {
200
+ _this.keepAlive();
201
+ }, this.keepAliveInterval);
202
+ };
203
+ /**
204
+ * Listens for Safari extension status changes.
205
+ * If the extension was disabled and enabled again after initializing the SDK, it
206
+ * will call 'monitorTransferActivity' to resume transfer activities.
207
+ */
208
+ SafariClient.prototype.safariExtensionStatusChanged = function (isEnabled) {
209
+ var _this = this;
210
+ if (isEnabled === this.safariExtensionEnabled) {
211
+ return;
212
+ }
213
+ this.safariExtensionEnabled = isEnabled;
214
+ if (isEnabled) {
215
+ if (this.subscribedTransferActivity) {
216
+ var resumeTransferActivity_1 = function () {
217
+ _this.monitorTransferActivity()
218
+ .catch(function () {
219
+ console.error('Failed to resume transfer activity, will try again in 1s');
220
+ setTimeout(function () {
221
+ resumeTransferActivity_1();
222
+ }, 1000);
223
+ });
224
+ };
225
+ resumeTransferActivity_1();
226
+ }
227
+ }
228
+ else {
229
+ index_1.asperaSdk.activityTracking.handleWebSocketEvents('CLOSED');
230
+ this.promiseExecutors.forEach(function (promiseExecutor) {
231
+ promiseExecutor.reject('The Safari extension is disabled or unresponsive (extension status)');
232
+ });
233
+ this.promiseExecutors.clear();
234
+ }
235
+ index_1.asperaSdk.activityTracking.handleSafariExtensionEvents(this.safariExtensionEnabled ? 'ENABLED' : 'DISABLED');
236
+ };
237
+ /**
238
+ * Checks if the last pong received was longer than the max interval.
239
+ */
240
+ SafariClient.prototype.checkSafariExtensionStatus = function () {
241
+ var pingPongDiff = this.lastPong - this.lastPing;
242
+ if (this.lastPong == null || pingPongDiff < 0 || pingPongDiff > 500) {
243
+ this.safariExtensionStatusChanged(false);
244
+ }
245
+ };
246
+ return SafariClient;
247
+ }());
248
+ exports.SafariClient = SafariClient;
249
+ exports.safariClient = new SafariClient();
250
+ exports.default = {
251
+ safariClient: exports.safariClient
252
+ };
@@ -0,0 +1,84 @@
1
+ import { ErrorResponse, PromiseObject, TransferSpec } from '../models/models';
2
+ /**
3
+ * Generates promise object that can be resolved or rejected via functions
4
+ *
5
+ * @returns an object containing the promise, the resolver and rejecter
6
+ */
7
+ export declare const generatePromiseObjects: () => PromiseObject;
8
+ /**
9
+ * Log errors from Aspera SDK
10
+ *
11
+ * @param message the message indicating the error encountered
12
+ * @param debugData the data with useful debugging information
13
+ */
14
+ export declare const errorLog: (message: string, debugData?: any) => void;
15
+ /**
16
+ * Generate error object for rejecter responses
17
+ *
18
+ * @param message the message indicating the error encountered
19
+ * @param debugData the data with useful debugging information
20
+ *
21
+ * @returns object containing standardized error response
22
+ */
23
+ export declare const generateErrorBody: (message: string, debugData?: any) => ErrorResponse;
24
+ /**
25
+ * Validate if transferSpec is valid for server communication
26
+ *
27
+ * @param transferSpec the transferSpec to test
28
+ *
29
+ * @returns boolean indicating whether supplied transferSpec is valid
30
+ */
31
+ export declare const isValidTransferSpec: (transferSpec: TransferSpec) => boolean;
32
+ /**
33
+ * Returns a string indicating the websocket URL to use for talking to the server
34
+ *
35
+ * @returns a string of the full Websocket URL
36
+ */
37
+ export declare const getWebsocketUrl: (serverUrl: string) => string;
38
+ /**
39
+ * Simple function to get the current platform.
40
+ *
41
+ * @returns a string indicating the current platform
42
+ */
43
+ export declare const getCurrentPlatform: () => 'macos' | 'windows' | 'linux' | 'unknown';
44
+ /**
45
+ * Function used to create a random UUID
46
+ *
47
+ * @returns string
48
+ */
49
+ export declare const randomUUID: () => string;
50
+ /**
51
+ * Return a rejected promise
52
+ *
53
+ * @param message the message indicating the error encountered
54
+ * @param debugData the data with useful debugging information
55
+ *
56
+ * @returns a rejected promise
57
+ */
58
+ export declare const throwError: (message: string, debugData?: any) => Promise<any>;
59
+ /**
60
+ * Check if the given string is a valid URL
61
+ *
62
+ * @param url string to check if valid URL
63
+ *
64
+ * @returns boolean
65
+ */
66
+ export declare const isValidURL: (url: string) => boolean;
67
+ /**
68
+ * Checks if the current browser is Safari.
69
+ * @returns {boolean} Whether the browser is Safari.
70
+ */
71
+ export declare const isSafari: () => boolean;
72
+ declare const _default: {
73
+ errorLog: (message: string, debugData?: any) => void;
74
+ generateErrorBody: (message: string, debugData?: any) => ErrorResponse;
75
+ generatePromiseObjects: () => PromiseObject;
76
+ getCurrentPlatform: () => "unknown" | "macos" | "windows" | "linux";
77
+ getWebsocketUrl: (serverUrl: string) => string;
78
+ isSafari: () => boolean;
79
+ isValidURL: (url: string) => boolean;
80
+ isValidTransferSpec: (transferSpec: TransferSpec) => boolean;
81
+ randomUUID: () => string;
82
+ throwError: (message: string, debugData?: any) => Promise<any>;
83
+ };
84
+ export default _default;