@beam-network/sdk 0.5.17 → 0.5.19
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 +1 -1
- package/dist/client.d.ts +1 -0
- package/dist/client.js +24 -14
- package/package.json +1 -1
package/README.md
CHANGED
package/dist/client.d.ts
CHANGED
|
@@ -56,6 +56,7 @@ export declare class BeamClient {
|
|
|
56
56
|
resumeProviderTransfer(input: ProviderTransferResumeInput): Promise<TransferPrepareResponse>;
|
|
57
57
|
transferStatus(transferId: string): Promise<TransferStatusInfo>;
|
|
58
58
|
distributeTransfer(transferId: string): Promise<DistributeResponse>;
|
|
59
|
+
private requestTransferCancellation;
|
|
59
60
|
cancelTransfer(transferId: string): Promise<TransferCancelResponse>;
|
|
60
61
|
planTransfer(input: {
|
|
61
62
|
sources: PlanningHttpSource[];
|
package/dist/client.js
CHANGED
|
@@ -134,12 +134,15 @@ export class BeamClient {
|
|
|
134
134
|
idempotencyKey: `transfer:${transferId}:distribute`
|
|
135
135
|
});
|
|
136
136
|
}
|
|
137
|
-
|
|
137
|
+
requestTransferCancellation(transferId) {
|
|
138
138
|
validateId(transferId, "transferId");
|
|
139
|
-
|
|
139
|
+
return this.control.request("transfer.cancel", { transfer_id: transferId }, {
|
|
140
140
|
transferId,
|
|
141
141
|
idempotencyKey: `transfer:${transferId}:cancel`
|
|
142
142
|
});
|
|
143
|
+
}
|
|
144
|
+
async cancelTransfer(transferId) {
|
|
145
|
+
const result = await this.requestTransferCancellation(transferId);
|
|
143
146
|
this.control.releaseRecoveryLease(transferId);
|
|
144
147
|
this.stopRecoverySigner(transferId);
|
|
145
148
|
return result;
|
|
@@ -486,15 +489,22 @@ export class BeamClient {
|
|
|
486
489
|
throw new BeamRouteRecoveryPendingError(prepared.transfer_id, error);
|
|
487
490
|
}
|
|
488
491
|
else {
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
492
|
+
try {
|
|
493
|
+
await cancelAndAbortProviderFailure({
|
|
494
|
+
cancelTransfer: () => this.requestTransferCancellation(prepared.transfer_id),
|
|
495
|
+
transferId: prepared.transfer_id,
|
|
496
|
+
cause: error,
|
|
497
|
+
uploads: multipartUploads,
|
|
498
|
+
abortBeforeCancel: !routeStreamBeginAttempted,
|
|
499
|
+
cleanupConcurrency: this.multipartControlConcurrency
|
|
500
|
+
});
|
|
501
|
+
}
|
|
502
|
+
finally {
|
|
503
|
+
// The retained recovery input owns the same destination objects used by
|
|
504
|
+
// multipart cleanup. Releasing it earlier scrubs their scoped credentials
|
|
505
|
+
// before abortMultipartUpload can clean up already-created uploads.
|
|
506
|
+
this.control.releaseRecoveryLease(prepared.transfer_id);
|
|
507
|
+
}
|
|
498
508
|
}
|
|
499
509
|
}
|
|
500
510
|
throw error;
|
|
@@ -1393,9 +1403,9 @@ async function sha256Bytes(value) {
|
|
|
1393
1403
|
function hex(bytes) {
|
|
1394
1404
|
return [...bytes].map((byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
1395
1405
|
}
|
|
1396
|
-
async function cancelTransferAfterProviderFailure(
|
|
1406
|
+
async function cancelTransferAfterProviderFailure(cancelTransfer, transferId, cause) {
|
|
1397
1407
|
try {
|
|
1398
|
-
const result = await
|
|
1408
|
+
const result = await cancelTransfer();
|
|
1399
1409
|
if (!result.success) {
|
|
1400
1410
|
throw new Error(result.message ?? `Beam rejected cancellation for ${transferId}`);
|
|
1401
1411
|
}
|
|
@@ -1418,7 +1428,7 @@ async function cancelAndAbortProviderFailure(input) {
|
|
|
1418
1428
|
}
|
|
1419
1429
|
}
|
|
1420
1430
|
try {
|
|
1421
|
-
await cancelTransferAfterProviderFailure(input.
|
|
1431
|
+
await cancelTransferAfterProviderFailure(input.cancelTransfer, input.transferId, input.cause);
|
|
1422
1432
|
}
|
|
1423
1433
|
catch (error) {
|
|
1424
1434
|
cancelError = error;
|