@storacha/encrypt-upload-client 1.1.74 → 1.1.76
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 -0
- package/dist/handlers/decrypt-handler.js +10 -5
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -111,7 +111,7 @@ export const getCarFileFromPublicGateway = async (gatewayURL, cid) => {
|
|
|
111
111
|
const url = new URL(`/ipfs/${cid}?format=car`, gatewayURL);
|
|
112
112
|
const response = await fetch(url);
|
|
113
113
|
if (!response.ok) {
|
|
114
|
-
throw new Error(`Failed to fetch: ${response.status} ${response.statusText}`);
|
|
114
|
+
throw new Error(`Failed to fetch CAR file for CID ${cid} from gateway ${gatewayURL.origin}: ${response.status} ${response.statusText}`);
|
|
115
115
|
}
|
|
116
116
|
const car = new Uint8Array(await response.arrayBuffer());
|
|
117
117
|
// SECURITY: Verify the CAR's root CID matches what we requested
|
|
@@ -141,11 +141,16 @@ const getEncryptedDataFromCar = async (car, encryptedDataCID) => {
|
|
|
141
141
|
blockIndex.set(cid.toString(), { blockOffset, blockLength });
|
|
142
142
|
}
|
|
143
143
|
// Step 2: Use the index to extract the encrypted data block bytes as needed
|
|
144
|
-
const
|
|
145
|
-
|
|
146
|
-
|
|
144
|
+
const blockInfo = blockIndex.get(encryptedDataCID);
|
|
145
|
+
if (!blockInfo) {
|
|
146
|
+
throw new Error(`Encrypted data CID ${encryptedDataCID} not found in CAR file. Available CIDs: ${Array.from(blockIndex.keys()).join(', ')}`);
|
|
147
|
+
}
|
|
148
|
+
// Step 3: Put ALL blocks from CAR into blockstore (not just root)
|
|
147
149
|
const blockstore = new MemoryBlockstore();
|
|
148
|
-
|
|
150
|
+
for (const [cidStr, { blockOffset, blockLength }] of blockIndex.entries()) {
|
|
151
|
+
const bytes = car.subarray(blockOffset, blockOffset + blockLength);
|
|
152
|
+
await blockstore.put(CID.parse(cidStr), bytes);
|
|
153
|
+
}
|
|
149
154
|
// Step 4: Get the encrypted data from the CAR file
|
|
150
155
|
const encryptedDataEntry = await exporter(CID.parse(encryptedDataCID), blockstore);
|
|
151
156
|
// Step 5: Return the async iterable for streaming
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storacha/encrypt-upload-client",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.76",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
6
|
"description": "Client for upload and download encrypted files",
|
|
7
7
|
"author": "Storacha",
|
|
@@ -82,9 +82,9 @@
|
|
|
82
82
|
"p-queue": "^9.0.1",
|
|
83
83
|
"p-retry": "^5.1.2",
|
|
84
84
|
"viem": "^2.39.0",
|
|
85
|
-
"@storacha/
|
|
86
|
-
"@storacha/client": "^
|
|
87
|
-
"@storacha/
|
|
85
|
+
"@storacha/client": "^2.0.5",
|
|
86
|
+
"@storacha/upload-client": "^1.3.9",
|
|
87
|
+
"@storacha/capabilities": "^2.2.0"
|
|
88
88
|
},
|
|
89
89
|
"devDependencies": {
|
|
90
90
|
"@lit-protocol/schemas": "^8.0.2",
|