Compare commits

..

No commits in common. "v0.2.0-develop.55" and "v0.2.0-develop.54" have entirely different histories.

4 changed files with 7 additions and 18 deletions

View File

@ -1,10 +1,3 @@
# [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.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) # [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", "name": "@lumeweb/libweb",
"version": "0.2.0-develop.55", "version": "0.2.0-develop.54",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@lumeweb/libweb", "name": "@lumeweb/libweb",
"version": "0.2.0-develop.55", "version": "0.2.0-develop.54",
"dependencies": { "dependencies": {
"@lumeweb/community-portals": "^0.1.0-develop.6", "@lumeweb/community-portals": "^0.1.0-develop.6",
"@lumeweb/libportal": "0.2.0-develop.34", "@lumeweb/libportal": "0.2.0-develop.34",

View File

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

View File

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