@ibm-aspera/sdk 0.19.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.
@@ -437,11 +437,12 @@ export declare const readDirectory: (options: ReadDirectoryOptions) => Promise<R
437
437
  * Returns an object describing the high-level capabilities supported by the user's
438
438
  * transfer client (e.g. IBM Aspera for desktop, Connect, or HTTP Gateway).
439
439
  *
440
- * Use this for feature detection at a semantic level rather than checking individual RPC methods.
441
- * 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.
442
442
  *
443
- * Some capabitilies may depend on newer versions of the transfer client. This function may be useful
444
- * 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}.
445
446
  *
446
447
  * @returns an object with boolean flags for each capability.
447
448
  *
@@ -455,10 +456,18 @@ export declare const readDirectory: (options: ReadDirectoryOptions) => Promise<R
455
456
  */
456
457
  export declare const getCapabilities: () => SdkCapabilities;
457
458
  /**
458
- * 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.
459
460
  *
460
461
  * Capabilities depend on the transfer client being used (HTTP Gateway, Connect, or IBM Aspera for desktop).
461
- * 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.
462
471
  *
463
472
  * @param capability the capability to check.
464
473
  *
@@ -468,7 +477,7 @@ export declare const getCapabilities: () => SdkCapabilities;
468
477
  * ```typescript
469
478
  * // Determine if your web application can render image previews for user selected files
470
479
  * if (asperaSdk.hasCapability('imagePreview')) {
471
- * asperaSdk.readAsArrayBuffer(path);
480
+ * const response = await asperaSdk.readAsArrayBuffer(path);
472
481
  * }
473
482
  * ```
474
483
  */
@@ -1342,6 +1342,10 @@ var readDirectory = function (options) {
1342
1342
  };
1343
1343
  exports.readDirectory = readDirectory;
1344
1344
  var supportsMethod = function (method) {
1345
+ // HTTP Gateway v2 specific overrides
1346
+ if (index_1.asperaSdk.useOldHttpGateway && (method === 'read_as_array_buffer' || method === 'read_chunk_as_array_buffer')) {
1347
+ return false;
1348
+ }
1345
1349
  // We currently do not support calculating file checksums when using HTTP Gateway. In theory it should be possible
1346
1350
  // to calculate this directly in the browser similar to how `readAsArrayBuffer()` is implemented.
1347
1351
  // HTTP Gateway also does not support showing native transfer client UI (about, preferences, etc.).
@@ -1362,11 +1366,12 @@ var supportsMethod = function (method) {
1362
1366
  * Returns an object describing the high-level capabilities supported by the user's
1363
1367
  * transfer client (e.g. IBM Aspera for desktop, Connect, or HTTP Gateway).
1364
1368
  *
1365
- * Use this for feature detection at a semantic level rather than checking individual RPC methods.
1366
- * Capabitilies may depend on multiple underlying RPC methods and also may vary by transfer client.
1369
+ * Use this for feature detection at a semantic level as capabilities may change depending on the
1370
+ * transfer client.
1367
1371
  *
1368
- * Some capabitilies may depend on newer versions of the transfer client. This function may be useful
1369
- * if you want to conditionally perform certain actions rather than potentially getting an error.
1372
+ * Rather than caching the return value of this function, it's recommended to call it on the fly as
1373
+ * capabilities may change if your application supports multiple transfer clients. As a result, it's
1374
+ * recommend to use the slightly more ergonomic {@link hasCapability}.
1370
1375
  *
1371
1376
  * @returns an object with boolean flags for each capability.
1372
1377
  *
@@ -1394,10 +1399,18 @@ var getCapabilities = function () {
1394
1399
  };
1395
1400
  exports.getCapabilities = getCapabilities;
1396
1401
  /**
1397
- * Check if the SDK and underlying transfer client supports a specific capability.
1402
+ * Check if the SDK and underlying transfer client supports a specific capability or feature.
1398
1403
  *
1399
1404
  * Capabilities depend on the transfer client being used (HTTP Gateway, Connect, or IBM Aspera for desktop).
1400
- * Use this function to conditionally enable/disable features in your application.
1405
+ *
1406
+ * This function may be useful if you want to conditionally perform certain actions rather than
1407
+ * potentially getting an error.
1408
+ *
1409
+ * For example, only IBM Aspera for desktop supports traversing a folder's contents. An application can
1410
+ * check `hasCapability('readDirectory')` to optionally show a folder browser only when the feature is available.
1411
+ * For example, when a user does not have IBM Aspera for desktop installed and is using HTTP Gateway, your
1412
+ * application can disable this feature. Later, if that same user installs IBM Aspera for desktop, your application
1413
+ * will show the feature as enabled without any additional changes.
1401
1414
  *
1402
1415
  * @param capability the capability to check.
1403
1416
  *
@@ -1407,7 +1420,7 @@ exports.getCapabilities = getCapabilities;
1407
1420
  * ```typescript
1408
1421
  * // Determine if your web application can render image previews for user selected files
1409
1422
  * if (asperaSdk.hasCapability('imagePreview')) {
1410
- * asperaSdk.readAsArrayBuffer(path);
1423
+ * const response = await asperaSdk.readAsArrayBuffer(path);
1411
1424
  * }
1412
1425
  * ```
1413
1426
  */
@@ -53,6 +53,11 @@ export declare class WebsocketService {
53
53
  */
54
54
  init(): Promise<unknown>;
55
55
  private connect;
56
+ /**
57
+ * Detach event handlers from the current socket so it cannot fire
58
+ * stale CLOSED/RECONNECT events after being replaced.
59
+ */
60
+ private detachSocket;
56
61
  private reconnect;
57
62
  private getWebSocketConnection;
58
63
  private notifyEvent;
@@ -109,6 +109,7 @@ var WebsocketService = /** @class */ (function () {
109
109
  };
110
110
  WebsocketService.prototype.connect = function () {
111
111
  var _this = this;
112
+ this.detachSocket();
112
113
  this.getWebSocketConnection(index_1.asperaSdk.globals.rpcPort)
113
114
  .then(function (webSocket) {
114
115
  _this.globalSocket = webSocket;
@@ -121,8 +122,21 @@ var WebsocketService = /** @class */ (function () {
121
122
  _this.reconnect();
122
123
  });
123
124
  };
125
+ /**
126
+ * Detach event handlers from the current socket so it cannot fire
127
+ * stale CLOSED/RECONNECT events after being replaced.
128
+ */
129
+ WebsocketService.prototype.detachSocket = function () {
130
+ if (this.globalSocket) {
131
+ this.globalSocket.onopen = null;
132
+ this.globalSocket.onclose = null;
133
+ this.globalSocket.onerror = null;
134
+ this.globalSocket.onmessage = null;
135
+ }
136
+ };
124
137
  WebsocketService.prototype.reconnect = function () {
125
138
  var _this = this;
139
+ this.detachSocket();
126
140
  if (this.globalSocket) {
127
141
  this.globalSocket.close();
128
142
  }