Compare commits
3 Commits
v0.2.0-dev
...
v0.2.0-dev
Author | SHA1 | Date |
---|---|---|
semantic-release-bot | 6515702372 | |
Derrick Hammer | 390a57376f | |
Derrick Hammer | ab1ad68fcb |
|
@ -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.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)
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "@lumeweb/libweb",
|
"name": "@lumeweb/libweb",
|
||||||
"version": "0.2.0-develop.54",
|
"version": "0.2.0-develop.55",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@lumeweb/libweb",
|
"name": "@lumeweb/libweb",
|
||||||
"version": "0.2.0-develop.54",
|
"version": "0.2.0-develop.55",
|
||||||
"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",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@lumeweb/libweb",
|
"name": "@lumeweb/libweb",
|
||||||
"version": "0.2.0-develop.54",
|
"version": "0.2.0-develop.55",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { getActivePortals } from "#portal.js";
|
import { getActivePortals } from "#portal.js";
|
||||||
import { decodeCid, getVerifiableStream } from "@lumeweb/libportal";
|
import { getVerifiableStream } from "@lumeweb/libportal";
|
||||||
import {
|
import {
|
||||||
readableStreamToUint8Array,
|
readableStreamToUint8Array,
|
||||||
uint8ArrayToReadableStream,
|
uint8ArrayToReadableStream,
|
||||||
|
@ -7,6 +7,7 @@ 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();
|
||||||
|
@ -33,7 +34,11 @@ export async function downloadObject(cid: string): Promise<ReadableStream> {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
return await getVerifiableStream(decodeCid(cid).hash, proof, stream);
|
return await getVerifiableStream(
|
||||||
|
CID.decode(cid).hash.hashBytes,
|
||||||
|
proof,
|
||||||
|
stream,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw NO_PORTALS_ERROR;
|
throw NO_PORTALS_ERROR;
|
||||||
|
@ -65,10 +70,9 @@ 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.hash)) {
|
if (!equalBytes(blake3(data), CID.decode(cid).hash.hashBytes)) {
|
||||||
throw new Error("cid verification failed");
|
throw new Error("cid verification failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue