@beam-network/sdk 0.2.6 → 0.2.8
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/dist/client.d.ts +8 -0
- package/dist/client.js +1 -1
- package/dist/provider-signing.js +12 -1
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -37,3 +37,11 @@ export declare class BeamClient {
|
|
|
37
37
|
private request;
|
|
38
38
|
}
|
|
39
39
|
export declare function calculateOptimalChunkSize(totalSize: number): number;
|
|
40
|
+
export declare function buildStagingObjectKey(input: {
|
|
41
|
+
finalObjectKey: string;
|
|
42
|
+
transferId: string;
|
|
43
|
+
sourceId: string;
|
|
44
|
+
destinationId: string;
|
|
45
|
+
chunkIndex: number;
|
|
46
|
+
partNumber: number;
|
|
47
|
+
}): string;
|
package/dist/client.js
CHANGED
|
@@ -313,7 +313,7 @@ function normalizeBaseUrl(value) {
|
|
|
313
313
|
function compact(input) {
|
|
314
314
|
return Object.fromEntries(Object.entries(input).filter(([, value]) => value !== undefined));
|
|
315
315
|
}
|
|
316
|
-
function buildStagingObjectKey(input) {
|
|
316
|
+
export function buildStagingObjectKey(input) {
|
|
317
317
|
const base = input.finalObjectKey.replace(/\/+$/, "") || "object";
|
|
318
318
|
return [
|
|
319
319
|
`${base}.beam-staging`,
|
package/dist/provider-signing.js
CHANGED
|
@@ -107,6 +107,17 @@ export async function signUploadPartCopy(destination, finalObjectKey, stagingObj
|
|
|
107
107
|
if (isS3CompatibleProvider(destination)) {
|
|
108
108
|
const client = createS3CompatibleClient(destination);
|
|
109
109
|
const copySource = copySourceHeader(destination, stagingObjectKey);
|
|
110
|
+
// Keep x-amz-copy-source (and x-amz-copy-source-range when present) in
|
|
111
|
+
// X-Amz-SignedHeaders rather than hoisting them to URL query params.
|
|
112
|
+
// The JS AWS SDK default hoists all x-amz-* headers to query params for
|
|
113
|
+
// presigned URLs; R2 ignores copy-source from query params (zero-byte copy)
|
|
114
|
+
// and returns SignatureDoesNotMatch when they are sent as unsigned headers
|
|
115
|
+
// alongside the signed query value. Keeping them as signed headers matches
|
|
116
|
+
// boto3 behavior and the copySourceHeaders replay contract in core-server.
|
|
117
|
+
const unhoistableHeaders = new Set(["x-amz-copy-source"]);
|
|
118
|
+
if (copySourceRange) {
|
|
119
|
+
unhoistableHeaders.add("x-amz-copy-source-range");
|
|
120
|
+
}
|
|
110
121
|
return {
|
|
111
122
|
copySource,
|
|
112
123
|
copyUrl: await getSignedUrl(client, new UploadPartCopyCommand({
|
|
@@ -116,7 +127,7 @@ export async function signUploadPartCopy(destination, finalObjectKey, stagingObj
|
|
|
116
127
|
PartNumber: partNumber,
|
|
117
128
|
CopySource: copySource,
|
|
118
129
|
CopySourceRange: copySourceRange
|
|
119
|
-
}), { expiresIn })
|
|
130
|
+
}), { expiresIn, unhoistableHeaders })
|
|
120
131
|
};
|
|
121
132
|
}
|
|
122
133
|
throw new Error(`multipart copy is not supported for ${destination.provider}`);
|