@beam-network/sdk 0.5.8 → 0.5.10
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.js +10 -0
- package/package.json +1 -1
package/dist/client.js
CHANGED
|
@@ -511,6 +511,7 @@ export class BeamClient {
|
|
|
511
511
|
expectedObjectSize: upload.manifest.expected_object_size,
|
|
512
512
|
expectedPartCount: upload.manifest.expected_part_count,
|
|
513
513
|
maxPartNumber: upload.manifest.max_part_number,
|
|
514
|
+
multipartGroupId: upload.manifest.multipart_group_id,
|
|
514
515
|
completeUrl: upload.manifest.complete_url,
|
|
515
516
|
abortUrl: upload.manifest.abort_url,
|
|
516
517
|
listPageUrl: upload.manifest.list_page_urls[multipartListPageIndex(input.partNumber)],
|
|
@@ -1192,9 +1193,15 @@ function multipartListPageIndex(partNumber) {
|
|
|
1192
1193
|
function validateSignedRouteManifestContract(routes, manifest) {
|
|
1193
1194
|
const groups = new Map(manifest.map((group) => [group.multipart_group_id, group]));
|
|
1194
1195
|
for (const route of routes) {
|
|
1196
|
+
const uploadId = typeof route.metadata?.upload_id === "string"
|
|
1197
|
+
? route.metadata.upload_id
|
|
1198
|
+
: undefined;
|
|
1195
1199
|
const groupId = typeof route.metadata?.multipart_group_id === "string"
|
|
1196
1200
|
? route.metadata.multipart_group_id
|
|
1197
1201
|
: undefined;
|
|
1202
|
+
if (uploadId && !groupId) {
|
|
1203
|
+
throw new Error(`signed multipart route ${route.source_id}:${route.destination_id}:${route.chunk_index} is missing multipart_group_id`);
|
|
1204
|
+
}
|
|
1198
1205
|
if (!groupId)
|
|
1199
1206
|
continue;
|
|
1200
1207
|
const group = groups.get(groupId);
|
|
@@ -1203,6 +1210,9 @@ function validateSignedRouteManifestContract(routes, manifest) {
|
|
|
1203
1210
|
if (route.source_id !== group.source_id || route.destination_id !== group.destination_id) {
|
|
1204
1211
|
throw new Error(`signed route identity does not match multipart group ${groupId}`);
|
|
1205
1212
|
}
|
|
1213
|
+
if (uploadId !== group.upload_id || route.metadata?.final_object_key !== group.final_object_key) {
|
|
1214
|
+
throw new Error(`signed route upload identity does not match multipart group ${groupId}`);
|
|
1215
|
+
}
|
|
1206
1216
|
const partNumber = route.metadata?.part_number;
|
|
1207
1217
|
if (typeof partNumber !== "number") {
|
|
1208
1218
|
throw new Error(`signed route for multipart group ${groupId} is missing part_number`);
|