A music player that connects to your cloud/distributed storage.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

chore: clean up some small todos

+48 -24
+11
src/common/cid.js
··· 1 + import { equals } from "iso-base/utils"; 1 2 import { CID } from "multiformats/cid"; 2 3 import { sha256 } from "multiformats/hashes/sha2"; 3 4 ··· 11 12 12 13 return cid.toString(); 13 14 } 15 + 16 + /** 17 + * @param {Uint8Array} data 18 + * @param {string} expected 19 + */ 20 + export async function verify(data, expected) { 21 + const expectedCid = CID.parse(expected); 22 + const hash = await sha256.digest(data); 23 + return equals(expectedCid.multihash.bytes, hash.bytes); 24 + }
-1
src/common/utils.js
··· 1 1 import { Temporal } from "@js-temporal/polyfill"; 2 - import { base64url } from "iso-base/rfc4648"; 3 2 import { xxh32r } from "xxh32/dist/raw.js"; 4 3 5 4 /**
-5
src/components/processor/search/constants.js
··· 23 23 no: /** @type {const} */ ("number"), 24 24 }, 25 25 }, 26 - 27 - // TODO: 28 - // isFavorite: "boolean" as const, 29 - // inPlaylists: [ ... ], 30 - 31 26 embeddings: /** @type {const} */ ("vector[512]"), 32 27 };
+1 -11
src/components/processor/search/worker.js
··· 1 1 import * as Orama from "@orama/orama"; 2 2 import { xxh32 } from "xxh32"; 3 - // import { pluginQPS } from "@orama/plugin-qps"; 4 3 5 4 import { SCHEMA } from "./constants.js"; 6 5 import { announce, ostiary, rpc } from "~/common/worker.js"; ··· 30 29 // DATABASE 31 30 //////////////////////////////////////////// 32 31 33 - // TODO: 34 - // * pluginEmbeddings 35 - // * pluginQPS 36 - 37 32 /** 38 33 * @type {Orama.OramaPlugin[]} 39 34 */ ··· 42 37 const db = Orama.create({ 43 38 schema: SCHEMA, 44 39 plugins: PLUGINS, 45 - // components: { 46 - // TODO: 47 - // https://docs.orama.com/open-source/usage/insert#remote-document-storing 48 - // documentStore: { ... } 49 - // }, 50 40 }); 51 41 52 42 //////////////////////////////////////////// ··· 122 112 }); 123 113 124 114 // Effects 115 + // ------- 125 116 126 117 // Communicate state 127 118 effect(() => ··· 142 133 // @ts-ignore: No clue what the correct type is for this one 143 134 sortBy, 144 135 ...params, 145 - // mode: "hybrid", 146 136 threshold: 0, // AND operator: all search terms must match in at least one property 147 137 limit: 10000, 148 138 offset: tracks.length,
-1
src/components/transformer/output/bytes/dasl-sync/element.js
··· 286 286 }; 287 287 288 288 return { 289 - // TODO: Do we need this? Too big of a perf penalty? 290 289 cid: await CID.create(0x71, encode(newInventory)), 291 290 data: collection, 292 291 inventory: newInventory,
+18 -3
src/facets/l/index.js
··· 1 1 import foundation from "~/common/facets/foundation.js"; 2 - import { createLoader } from "~/common/loader.js"; 2 + import * as CID from "~/common/cid.js"; 3 + import { createLoader, renderError } from "~/common/loader.js"; 3 4 4 5 createLoader({ 5 6 $type: "sh.diffuse.output.facet", ··· 8 9 const output = foundation.orchestrator.output(); 9 10 return output.facets; 10 11 }, 11 - render(facet) { 12 - // TODO: Validate if CID matches HTML 12 + async render(facet) { 13 13 const container = /** @type {HTMLDivElement} */ ( 14 14 document.querySelector("#container") 15 15 ); 16 + 17 + if (facet.cid) { 18 + const valid = await CID.verify( 19 + new TextEncoder().encode(facet.html ?? ""), 20 + facet.cid, 21 + ); 22 + 23 + if (!valid) { 24 + renderError( 25 + container, 26 + "CID mismatch: HTML content does not match the CID", 27 + ); 28 + return; 29 + } 30 + } 16 31 17 32 const range = document.createRange(); 18 33 range.selectNode(container);
+18 -3
src/themes/l/index.js
··· 1 1 import foundation from "~/common/facets/foundation.js"; 2 - import { createLoader } from "~/common/loader.js"; 2 + import * as CID from "~/common/cid.js"; 3 + import { createLoader, renderError } from "~/common/loader.js"; 3 4 4 5 createLoader({ 5 6 $type: "sh.diffuse.output.theme", ··· 8 9 const output = foundation.orchestrator.output(); 9 10 return output.themes; 10 11 }, 11 - render(theme) { 12 - // TODO: Validate if CID matches HTML 12 + async render(theme) { 13 + if (theme.cid) { 14 + const valid = await CID.verify( 15 + new TextEncoder().encode(theme.html ?? ""), 16 + theme.cid, 17 + ); 18 + 19 + if (!valid) { 20 + renderError( 21 + document.body, 22 + "CID mismatch: HTML content does not match the CID", 23 + ); 24 + return; 25 + } 26 + } 27 + 13 28 const iframe = document.createElement("iframe"); 14 29 iframe.srcdoc = theme.html ?? ""; 15 30