Compare commits

...

3 Commits

Author SHA1 Message Date
semantic-release-bot 6515702372 chore(release): 0.2.0-develop.55 [skip ci]
# [0.2.0-develop.55](https://git.lumeweb.com/LumeWeb/libweb/compare/v0.2.0-develop.54...v0.2.0-develop.55) (2023-09-08)

### Bug Fixes

* need to use CID.decode ([ab1ad68](ab1ad68fcb))
2023-09-08 17:24:14 +00:00
Derrick Hammer 390a57376f
Merge remote-tracking branch 'origin/develop' into develop 2023-09-08 13:23:11 -04:00
Derrick Hammer ab1ad68fcb
fix: need to use CID.decode 2023-09-08 13:22:58 -04:00
4 changed files with 18 additions and 7 deletions

View File

@ -1,3 +1,10 @@
# [0.2.0-develop.55](https://git.lumeweb.com/LumeWeb/libweb/compare/v0.2.0-develop.54...v0.2.0-develop.55) (2023-09-08)
### Bug Fixes
* need to use CID.decode ([ab1ad68](https://git.lumeweb.com/LumeWeb/libweb/commit/ab1ad68fcb7b2d08842a04ed4c411970f93cfbb4))
# [0.2.0-develop.54](https://git.lumeweb.com/LumeWeb/libweb/compare/v0.2.0-develop.53...v0.2.0-develop.54) (2023-09-08)
# [0.2.0-develop.53](https://git.lumeweb.com/LumeWeb/libweb/compare/v0.2.0-develop.52...v0.2.0-develop.53) (2023-09-08)

4
npm-shrinkwrap.json generated
View File

@ -1,12 +1,12 @@
{
"name": "@lumeweb/libweb",
"version": "0.2.0-develop.54",
"version": "0.2.0-develop.55",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@lumeweb/libweb",
"version": "0.2.0-develop.54",
"version": "0.2.0-develop.55",
"dependencies": {
"@lumeweb/community-portals": "^0.1.0-develop.6",
"@lumeweb/libportal": "0.2.0-develop.34",

View File

@ -1,6 +1,6 @@
{
"name": "@lumeweb/libweb",
"version": "0.2.0-develop.54",
"version": "0.2.0-develop.55",
"main": "lib/index.js",
"type": "module",
"repository": {

View File

@ -1,5 +1,5 @@
import { getActivePortals } from "#portal.js";
import { decodeCid, getVerifiableStream } from "@lumeweb/libportal";
import { getVerifiableStream } from "@lumeweb/libportal";
import {
readableStreamToUint8Array,
uint8ArrayToReadableStream,
@ -7,6 +7,7 @@ import {
import { equalBytes } from "@noble/curves/abstract/utils";
import { blake3 } from "@noble/hashes/blake3";
import { NO_PORTALS_ERROR } from "#types.js";
import { CID } from "@lumeweb/libs5";
export async function downloadObject(cid: string): Promise<ReadableStream> {
const activePortals = getActivePortals();
@ -33,7 +34,11 @@ export async function downloadObject(cid: string): Promise<ReadableStream> {
continue;
}
return await getVerifiableStream(decodeCid(cid).hash, proof, stream);
return await getVerifiableStream(
CID.decode(cid).hash.hashBytes,
proof,
stream,
);
}
throw NO_PORTALS_ERROR;
@ -65,10 +70,9 @@ export async function downloadSmallObject(
continue;
}
const CID = decodeCid(cid);
const data = await readableStreamToUint8Array(stream);
if (!equalBytes(blake3(data), CID.hash)) {
if (!equalBytes(blake3(data), CID.decode(cid).hash.hashBytes)) {
throw new Error("cid verification failed");
}