@ibm-aspera/sdk 0.16.0 → 0.19.1

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 CHANGED
@@ -20,6 +20,7 @@ To include this SDK via `script` tag directly in your web application's HTML, re
20
20
  ```html
21
21
  <script src="https://cdn.jsdelivr.net/npm/@ibm-aspera/sdk@0.2.30/dist/js/aspera-sdk.js"></script>
22
22
  ```
23
+ Check npmjs.com for the latest version (https://www.npmjs.com/package/@ibm-aspera/sdk).
23
24
 
24
25
  ## Usage
25
26
 
@@ -1,5 +1,5 @@
1
1
  import { AsperaSdkInfo, TransferResponse } from '../models/aspera-sdk.model';
2
- import { CustomBrandingOptions, DataTransferResponse, DropzoneEventData, DropzoneOptions, AsperaSdkSpec, AsperaSdkTransfer, FileDialogOptions, FolderDialogOptions, SaveFileDialogOptions, InitOptions, ModifyTransferOptions, Pagination, PaginatedFilesResponse, ResumeTransferOptions, TransferSpec, WebsocketEvent, ReadChunkAsArrayBufferResponse, ReadAsArrayBufferResponse, SdkCapabilities, GetChecksumOptions, ChecksumFileResponse, ReadDirectoryOptions, ReadDirectoryResponse, ShowPreferencesPageOptions, TestSshPortsOptions } from '../models/models';
2
+ import { CustomBrandingOptions, DataTransferResponse, DropzoneEventData, DropzoneOptions, AsperaSdkSpec, AsperaSdkTransfer, FileDialogOptions, FolderDialogOptions, SaveFileDialogOptions, InitOptions, ModifyTransferOptions, Pagination, PaginatedFilesResponse, ResumeTransferOptions, TransferSpec, ReadChunkAsArrayBufferResponse, ReadAsArrayBufferResponse, SdkCapabilities, SdkStatus, GetChecksumOptions, ChecksumFileResponse, ReadDirectoryOptions, ReadDirectoryResponse, ShowPreferencesPageOptions, TestSshPortsOptions } from '../models/models';
3
3
  /**
4
4
  * Check if IBM Aspera for Desktop connection works. This function is called by init
5
5
  * when initializing the SDK. This function can be used at any point for checking.
@@ -16,24 +16,129 @@ export declare const testConnection: () => Promise<any>;
16
16
  */
17
17
  export declare const initDragDrop: (initCall?: boolean) => Promise<boolean>;
18
18
  /**
19
- * Initialize IBM Aspera client. If client cannot (reject/catch), then
20
- * client should attempt fixing server URL or trying again. If still fails disable UI elements.
19
+ * Get the current SDK lifecycle status synchronously.
21
20
  *
22
- * @param options initialization options:
21
+ * @returns the current status, or undefined if no init has been called yet
22
+ */
23
+ export declare const getStatus: () => SdkStatus | undefined;
24
+ /**
25
+ * Initialize the SDK and connect to a transfer client. Returns a promise that resolves
26
+ * when the transfer client is ready, or rejects if it cannot be reached.
27
+ *
28
+ * By default, the SDK connects to IBM Aspera for desktop. Set `connectSettings.useConnect`
29
+ * to use IBM Aspera Connect instead. If `httpGatewaySettings` is provided, the gateway is
30
+ * set up first — when `forceGateway` is true it becomes the sole transport; when false it
31
+ * is set up as a supplementary transport and the primary client (Desktop or Connect) is
32
+ * still initialized afterward.
23
33
  *
24
- * - `appId` the unique ID for the website. Transfers initiated during this session
25
- * will be associated with this ID. It is recommended to use a unique ID to keep transfer
26
- * information private from other websites.
34
+ * Note that the promise behavior varies by transfer client. For Desktop, the promise
35
+ * remains pending until the application is detected. For Connect, the promise resolves
36
+ * immediately after initialization begins — use {@link registerStatusCallback} to track
37
+ * when Connect is actually ready. For a non-blocking alternative that provides consistent
38
+ * lifecycle status events across all transfer clients, see {@link initSession}.
27
39
  *
28
- * - `supportMultipleUsers` when enabled (defaults to false), the SDK will iterate over a port
29
- * range and generate a session id to determine the running instance of the desktop app for the
30
- * current user. This is needed when multiple users may be logged into the same machine
31
- * simultaneously, for example on a Windows Server.
40
+ * @param options - Initialization options. See {@link InitOptions}.
32
41
  *
33
- * @returns a promise that resolves if IBM Aspera Desktop is running properly or
34
- * rejects if unable to connect
42
+ * @returns a promise that resolves with SDK metadata when the transfer client is ready
43
+ *
44
+ * @example
45
+ * init({ appId: 'my-app' })
46
+ * .then(() => {
47
+ * // Transfer client is ready — enable UI
48
+ * })
49
+ * .catch(error => {
50
+ * // Could not connect — prompt user to install or launch
51
+ * });
35
52
  */
36
53
  export declare const init: (options?: InitOptions) => Promise<any>;
54
+ /**
55
+ * Initialize the SDK and begin detecting a transfer client. This function returns
56
+ * immediately — lifecycle status is communicated asynchronously via {@link registerStatusCallback}.
57
+ *
58
+ * The SDK supports three transfer clients. By default, IBM Aspera for desktop is used.
59
+ * Set `connectSettings.useConnect` to use IBM Aspera Connect instead. Desktop and Connect
60
+ * are mutually exclusive — one or the other is detected, not both.
61
+ *
62
+ * ## HTTP Gateway
63
+ *
64
+ * HTTP Gateway is a server-side component that enables browser-based transfers without
65
+ * a desktop application. It can be used in two modes:
66
+ *
67
+ * - **Sole transport** (`forceGateway: true`): HTTP Gateway is the only transport.
68
+ * No Desktop or Connect detection occurs. Status transitions to `RUNNING` when the
69
+ * gateway responds successfully, or `FAILED` if it does not.
70
+ *
71
+ * - **Supplementary transport** (`forceGateway: false`): HTTP Gateway is set up first
72
+ * as an additional transport for browser-based uploads and downloads. The primary
73
+ * transfer client (Desktop or Connect) is then detected separately. If HTTP Gateway
74
+ * setup fails, the primary client is still detected. Features that require a desktop
75
+ * application (native file dialogs, drag and drop, etc.) are only available when the
76
+ * primary client is running.
77
+ *
78
+ * ## Status lifecycle
79
+ *
80
+ * Use {@link registerStatusCallback} to receive status updates. Use {@link getStatus} to
81
+ * read the current status synchronously at any time.
82
+ *
83
+ * **Desktop path**: `INITIALIZING` → `RUNNING` (app detected), `DEGRADED` (timeout but
84
+ * HTTP Gateway is available as a supplementary transport), or `FAILED` (timeout, no
85
+ * fallback). Detection continues in the background after `DEGRADED` or `FAILED` — if the
86
+ * user launches the app later, the status transitions to `RUNNING`.
87
+ *
88
+ * **Connect path**: `INITIALIZING` → `RUNNING`, `FAILED`, `OUTDATED`, or
89
+ * `EXTENSION_INSTALL` depending on the state of the Connect browser extension
90
+ * and application.
91
+ *
92
+ * **HTTP Gateway path** (`forceGateway: true`): `INITIALIZING` → `RUNNING` or `FAILED`.
93
+ *
94
+ * @param options - Initialization options. See {@link InitOptions}.
95
+ *
96
+ * @example
97
+ * // Detect IBM Aspera for desktop (default)
98
+ * initSession({ appId: 'my-app' });
99
+ *
100
+ * @example
101
+ * // Detect IBM Aspera for desktop with status handling
102
+ * registerStatusCallback(status => {
103
+ * if (status === 'RUNNING') {
104
+ * // Transfer client is ready — enable UI
105
+ * } else if (status === 'FAILED') {
106
+ * // Not detected — prompt user to install or launch
107
+ * }
108
+ * });
109
+ *
110
+ * initSession({ appId: 'my-app' });
111
+ *
112
+ * @example
113
+ * // Use IBM Aspera Connect
114
+ * initSession({
115
+ * appId: 'my-app',
116
+ * connectSettings: {
117
+ * useConnect: true,
118
+ * },
119
+ * });
120
+ *
121
+ * @example
122
+ * // Use HTTP Gateway as the sole transport (no desktop app needed)
123
+ * initSession({
124
+ * appId: 'my-app',
125
+ * httpGatewaySettings: {
126
+ * url: 'https://example.com/aspera/http-gwy',
127
+ * forceGateway: true,
128
+ * },
129
+ * });
130
+ *
131
+ * @example
132
+ * // HTTP Gateway as supplementary transport with Desktop as primary
133
+ * initSession({
134
+ * appId: 'my-app',
135
+ * httpGatewaySettings: {
136
+ * url: 'https://example.com/aspera/http-gwy',
137
+ * forceGateway: false,
138
+ * },
139
+ * });
140
+ */
141
+ export declare const initSession: (options?: InitOptions) => void;
37
142
  /**
38
143
  * Tests SSH port connectivity to a transfer server.
39
144
  *
@@ -78,17 +183,45 @@ export declare const registerActivityCallback: (callback: (transfers: TransferRe
78
183
  */
79
184
  export declare const deregisterActivityCallback: (id: string) => void;
80
185
  /**
81
- * Register a callback for getting updates about the connection status of IBM Aspera SDK.
186
+ * Register a callback for SDK lifecycle status changes. The callback fires immediately
187
+ * with the current status (if one exists) and again whenever the status changes.
188
+ *
189
+ * Status values:
190
+ *
191
+ * - `INITIALIZING` — The SDK is detecting a transfer client.
192
+ * - `RUNNING` — A transfer client is ready. Full functionality is available.
193
+ * - `DEGRADED` — The primary transfer client (IBM Aspera for desktop) was not detected, but HTTP
194
+ * Gateway is available as a fallback. This is only available if XXX...
195
+ * - `FAILED` — No transfer client could be reached. This could be because the user does
196
+ * not have a transfer client installed, it is not running, or in the case of HTTP Gateway,
197
+ * it was not reachable.
198
+ * - `DISCONNECTED` — The transfer client was previously running but lost connection. This is specific
199
+ * to IBM Aspera for desktop. For example, if the user quits the app this status will trigger.
200
+ * - `OUTDATED` — (Connect only) The Connect installation needs updating.
201
+ * - `EXTENSION_INSTALL` — (Connect only) The browser extension needs to be installed.
82
202
  *
83
- * For example, to be notified of when the SDK loses connection with the application or connection
84
- * is re-established. This can be useful if you want to handle the case where the user quits IBM Aspera
85
- * after `init` has already been called, and want to prompt the user to relaunch the application.
203
+ * For IBM Aspera for desktop, detection continues in the background after `FAILED` or `DEGRADED`.
204
+ * If the user launches the application later, the status transitions to `RUNNING`.
86
205
  *
87
- * @param callback callback function to receive events
206
+ * @param callback callback function to receive status events
88
207
  *
89
208
  * @returns ID representing the callback for deregistration purposes
209
+ *
210
+ * @example
211
+ * const id = registerStatusCallback(status => {
212
+ * if (status === 'RUNNING') {
213
+ * // Full functionality — enable all UI
214
+ * } else if (status === 'DEGRADED') {
215
+ * // Transfers work via HTTP Gateway
216
+ * } else if (status === 'FAILED') {
217
+ * // Nothing available — prompt user to install
218
+ * }
219
+ * });
220
+ *
221
+ * // Later, to stop listening:
222
+ * deregisterStatusCallback(id);
90
223
  */
91
- export declare const registerStatusCallback: (callback: (status: WebsocketEvent) => void) => string;
224
+ export declare const registerStatusCallback: (callback: (status: SdkStatus) => void) => string;
92
225
  /**
93
226
  * Remove a callback from getting connection status events.
94
227
  *
@@ -304,11 +437,12 @@ export declare const readDirectory: (options: ReadDirectoryOptions) => Promise<R
304
437
  * Returns an object describing the high-level capabilities supported by the user's
305
438
  * transfer client (e.g. IBM Aspera for desktop, Connect, or HTTP Gateway).
306
439
  *
307
- * Use this for feature detection at a semantic level rather than checking individual RPC methods.
308
- * Capabitilies may depend on multiple underlying RPC methods and also may vary by transfer client.
440
+ * Use this for feature detection at a semantic level as capabilities may change depending on the
441
+ * transfer client.
309
442
  *
310
- * Some capabitilies may depend on newer versions of the transfer client. This function may be useful
311
- * if you want to conditionally perform certain actions rather than potentially getting an error.
443
+ * Rather than caching the return value of this function, it's recommended to call it on the fly as
444
+ * capabilities may change if your application supports multiple transfer clients. As a result, it's
445
+ * recommend to use the slightly more ergonomic {@link hasCapability}.
312
446
  *
313
447
  * @returns an object with boolean flags for each capability.
314
448
  *
@@ -322,10 +456,18 @@ export declare const readDirectory: (options: ReadDirectoryOptions) => Promise<R
322
456
  */
323
457
  export declare const getCapabilities: () => SdkCapabilities;
324
458
  /**
325
- * Check if the SDK and underlying transfer client supports a specific capability.
459
+ * Check if the SDK and underlying transfer client supports a specific capability or feature.
326
460
  *
327
461
  * Capabilities depend on the transfer client being used (HTTP Gateway, Connect, or IBM Aspera for desktop).
328
- * Use this function to conditionally enable/disable features in your application.
462
+ *
463
+ * This function may be useful if you want to conditionally perform certain actions rather than
464
+ * potentially getting an error.
465
+ *
466
+ * For example, only IBM Aspera for desktop supports traversing a folder's contents. An application can
467
+ * check `hasCapability('readDirectory')` to optionally show a folder browser only when the feature is available.
468
+ * For example, when a user does not have IBM Aspera for desktop installed and is using HTTP Gateway, your
469
+ * application can disable this feature. Later, if that same user installs IBM Aspera for desktop, your application
470
+ * will show the feature as enabled without any additional changes.
329
471
  *
330
472
  * @param capability the capability to check.
331
473
  *
@@ -335,7 +477,7 @@ export declare const getCapabilities: () => SdkCapabilities;
335
477
  * ```typescript
336
478
  * // Determine if your web application can render image previews for user selected files
337
479
  * if (asperaSdk.hasCapability('imagePreview')) {
338
- * asperaSdk.readAsArrayBuffer(path);
480
+ * const response = await asperaSdk.readAsArrayBuffer(path);
339
481
  * }
340
482
  * ```
341
483
  */