@beam-network/sdk 0.5.19 → 0.5.21
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.js +31 -3
- package/dist/models.d.ts +2 -0
- package/dist/provider-signing.d.ts +1 -0
- package/dist/provider-signing.js +5 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -161,7 +161,7 @@ Create and resume accept an ownership `signal`. Aborting it stops initial routes
|
|
|
161
161
|
|
|
162
162
|
The stream ID derives from the transfer, selected flow, and immutable plan identity, and each ordered batch ID includes its route-coordinate checksum. Manual multi-destination attachment requires `delivery_index` on every route. Lifecycle mutations retry transient failures up to three times with the same request identity. A non-recoverable provider setup or route failure raises `BeamProviderTransferError`, whose `errors`, `transferCancelled`, and `multipartCleanupComplete` fields retain the original provider, cancellation, and cleanup outcomes. `waitForTransfer` subscribes to the API-key-owned, at-most-once terminal signal before its first status read and reconciles every signal through authoritative status; subscription failure degrades to the same jittered 15-to-30-second status fallback. Call `close()` when the client is no longer needed; it also closes outstanding terminal waiters.
|
|
163
163
|
|
|
164
|
-
|
|
164
|
+
During the pre-completion `integrity_check` phase, Runtime may include an `integrity_audit_challenge` in status. The TypeScript client signs exact read-only source and final-destination GET ranges and submits `transfer.integrity_audit_grants`. S3-compatible source and destination grants use the prepared source ETag and Runtime-verified final-object ETag as `If-Match` conditions. Submission failures retry on the next status poll and appear as a URL-safe `integrity_audit_submission_error` on that status response; the transfer completes with a warning if the check cannot finish by its deadline.
|
|
165
165
|
|
|
166
166
|
Hippius uses canonical non-multipart `signed_url` routes, so its manifest is empty and group-level final HEAD verification is not available from that provider flow.
|
|
167
167
|
|
package/dist/client.js
CHANGED
|
@@ -120,8 +120,15 @@ export class BeamClient {
|
|
|
120
120
|
async transferStatus(transferId) {
|
|
121
121
|
validateId(transferId, "transferId");
|
|
122
122
|
const status = await this.control.request("transfer.status", { transfer_id: transferId }, { transferId });
|
|
123
|
+
if (status.integrity_audit_challenge) {
|
|
124
|
+
try {
|
|
125
|
+
await this.submitIntegrityAuditGrantsIfPresent(status);
|
|
126
|
+
}
|
|
127
|
+
catch (error) {
|
|
128
|
+
status.integrity_audit_submission_error = integrityAuditErrorSummary(error);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
123
131
|
if (["completed", "failed", "cancelled"].includes(status.status)) {
|
|
124
|
-
await this.submitIntegrityAuditGrantsIfPresent(status).catch(() => undefined);
|
|
125
132
|
this.control.releaseRecoveryLease(transferId);
|
|
126
133
|
this.stopRecoverySigner(transferId);
|
|
127
134
|
}
|
|
@@ -927,7 +934,7 @@ export class BeamClient {
|
|
|
927
934
|
return;
|
|
928
935
|
const signer = this.integrityAuditSigners.get(challenge.transfer_id);
|
|
929
936
|
if (!signer)
|
|
930
|
-
|
|
937
|
+
throw new Error("integrity audit signer unavailable");
|
|
931
938
|
const existing = this.integrityAuditSubmissions.get(challenge.audit_id);
|
|
932
939
|
if (existing) {
|
|
933
940
|
await existing;
|
|
@@ -935,7 +942,13 @@ export class BeamClient {
|
|
|
935
942
|
}
|
|
936
943
|
const submission = signer(challenge);
|
|
937
944
|
this.integrityAuditSubmissions.set(challenge.audit_id, submission);
|
|
938
|
-
|
|
945
|
+
try {
|
|
946
|
+
await submission;
|
|
947
|
+
}
|
|
948
|
+
catch (error) {
|
|
949
|
+
this.integrityAuditSubmissions.delete(challenge.audit_id);
|
|
950
|
+
throw error;
|
|
951
|
+
}
|
|
939
952
|
}
|
|
940
953
|
async submitProviderIntegrityAuditGrants(input) {
|
|
941
954
|
if (input.challenge.transfer_id !== input.prepared.transfer_id) {
|
|
@@ -958,12 +971,17 @@ export class BeamClient {
|
|
|
958
971
|
}
|
|
959
972
|
const source = input.sourcesById.get(chunk.source_id);
|
|
960
973
|
const destination = input.destinationsById.get(chunk.destination_id);
|
|
974
|
+
const plannedSource = input.prepared.plan_descriptor.sources.find((candidate) => candidate.source_id === chunk.source_id);
|
|
961
975
|
if (!source || !destination) {
|
|
962
976
|
throw new Error("integrity audit provider configuration is unavailable");
|
|
963
977
|
}
|
|
978
|
+
const sourceEtag = plannedSource?.metadata?.etag;
|
|
979
|
+
const sourceVersionId = plannedSource?.metadata?.version_id;
|
|
964
980
|
const [sourceGrant, destinationGrant] = await Promise.all([
|
|
965
981
|
signSourceReadRange({
|
|
966
982
|
source,
|
|
983
|
+
...(typeof sourceEtag === "string" ? { ifMatch: sourceEtag } : {}),
|
|
984
|
+
...(typeof sourceVersionId === "string" ? { versionId: sourceVersionId } : {}),
|
|
967
985
|
offset: chunk.source_offset,
|
|
968
986
|
length: chunk.range_length,
|
|
969
987
|
expiresIn: input.expiresIn,
|
|
@@ -972,6 +990,7 @@ export class BeamClient {
|
|
|
972
990
|
signDestinationReadRange({
|
|
973
991
|
destination,
|
|
974
992
|
objectKey: chunk.final_object_key,
|
|
993
|
+
...(chunk.final_object_etag ? { ifMatch: chunk.final_object_etag } : {}),
|
|
975
994
|
offset: chunk.destination_offset,
|
|
976
995
|
length: chunk.range_length,
|
|
977
996
|
expiresIn: input.expiresIn,
|
|
@@ -1343,6 +1362,15 @@ async function mapOrderedWithConcurrency(values, concurrency, map) {
|
|
|
1343
1362
|
await Promise.all(workers);
|
|
1344
1363
|
return results;
|
|
1345
1364
|
}
|
|
1365
|
+
function integrityAuditErrorSummary(error) {
|
|
1366
|
+
if (!(error instanceof Error))
|
|
1367
|
+
return "unknown_error";
|
|
1368
|
+
const message = error.message.trim();
|
|
1369
|
+
if (!message || /https?:\/\/|x-amz|password|secret|token|authorization|credential/i.test(message)) {
|
|
1370
|
+
return error.name || "unknown_error";
|
|
1371
|
+
}
|
|
1372
|
+
return message.slice(0, 200);
|
|
1373
|
+
}
|
|
1346
1374
|
function positiveInteger(value, label) {
|
|
1347
1375
|
if (!Number.isInteger(value) || value < 1)
|
|
1348
1376
|
throw new Error(`${label} must be a positive integer.`);
|
package/dist/models.d.ts
CHANGED
|
@@ -132,6 +132,7 @@ export interface IntegrityAuditChallengeChunk {
|
|
|
132
132
|
destination_offset: number;
|
|
133
133
|
range_length: number;
|
|
134
134
|
final_object_key: string;
|
|
135
|
+
final_object_etag: string | null;
|
|
135
136
|
}
|
|
136
137
|
export interface IntegrityAuditChallenge {
|
|
137
138
|
audit_id: string;
|
|
@@ -170,6 +171,7 @@ export interface TransferStatusInfo {
|
|
|
170
171
|
completedDestinationIds: string[];
|
|
171
172
|
};
|
|
172
173
|
integrity_audit_challenge?: IntegrityAuditChallenge;
|
|
174
|
+
integrity_audit_submission_error?: string;
|
|
173
175
|
}
|
|
174
176
|
export interface ProviderTransferResumeInput extends Omit<ProviderTransferCreateInput, "idempotencyKey" | "routeGenerationId"> {
|
|
175
177
|
transferId: string;
|
package/dist/provider-signing.js
CHANGED
|
@@ -337,11 +337,14 @@ export async function signDestinationReadRange(input) {
|
|
|
337
337
|
url: await getSignedUrl(client, new GetObjectCommand({
|
|
338
338
|
Bucket: input.destination.bucket,
|
|
339
339
|
Key: input.objectKey,
|
|
340
|
-
Range: range
|
|
340
|
+
Range: range,
|
|
341
|
+
IfMatch: input.ifMatch
|
|
341
342
|
}), { expiresIn: input.expiresIn }),
|
|
342
|
-
headers: { Range: range }
|
|
343
|
+
headers: { Range: range, ...(input.ifMatch ? { "If-Match": input.ifMatch } : {}) }
|
|
343
344
|
};
|
|
344
345
|
}
|
|
346
|
+
if (input.ifMatch)
|
|
347
|
+
throw new Error("conditional destination ranges require S3-compatible storage");
|
|
345
348
|
if (isHippiusProvider(input.destination)) {
|
|
346
349
|
return {
|
|
347
350
|
url: await hippiusPresign(input.fetchImpl ?? globalThis.fetch, input.destination.base_url ?? "https://api.hippius.com", input.destination.api_token, input.destination.bucket, input.objectKey, "get", input.expiresIn),
|