diff --git a/_config.ts b/_config.ts index 61e0b996..ccfd96db 100644 --- a/_config.ts +++ b/_config.ts @@ -1,4 +1,6 @@ import type { RequestHandler } from "lume/core/server.ts"; + +import { builtinModules } from "node:module"; import { dotenvRun } from "@dotenv-run/esbuild"; import lume from "lume/mod.ts"; @@ -43,6 +45,7 @@ site.use(esbuild({ external: ["./file-tree.json"], platform: "browser", plugins: [ + // @ts-ignore dotenvRun({ files: [".env"], }), @@ -99,10 +102,12 @@ site.use(esbuild({ }, }, nodeModulesPolyfillPlugin({ + fallback: "empty", globals: { process: true, Buffer: true, }, + modules: builtinModules.filter((a) => !["crypto", "fs"].includes(a)), }), wasmLoader(), ], diff --git a/deno.jsonc b/deno.jsonc index 3640e376..375d8055 100644 --- a/deno.jsonc +++ b/deno.jsonc @@ -4,21 +4,23 @@ "vendor": true, "imports": { "98.css": "npm:98.css@^0.1.21", - "@atcute/cbor": "npm:@atcute/cbor@^2.3.0", - "@atcute/tid": "npm:@atcute/tid@^1.0.0", + "@atcute/cbor": "npm:@atcute/cbor@^2.3.2", + "@atcute/cid": "npm:@atcute/cid@^2.4.1", + "@atcute/tid": "npm:@atcute/tid@^1.1.2", "@atcute/client": "npm:@atcute/client@^4.2.1", "@atcute/identity-resolver": "npm:@atcute/identity-resolver@^1.2.2", - "@atcute/lexicons": "npm:@atcute/lexicons@^1.2.7", + "@atcute/lexicons": "npm:@atcute/lexicons@^1.2.9", "@atcute/oauth-browser-client": "npm:@atcute/oauth-browser-client@^3.0.0", - "@automerge/automerge": "npm:@automerge/automerge@^3.2.3", - "@awesome.me/webawesome": "npm:@awesome.me/webawesome@^3.2.1", + "@atcute/uint8array": "npm:@atcute/uint8array@^1.1.1", + "@automerge/automerge": "npm:@automerge/automerge@^3.2.4", + "@awesome.me/webawesome": "npm:@awesome.me/webawesome@^3.3.1", "@bradenmacdonald/s3-lite-client": "jsr:@bradenmacdonald/s3-lite-client@^0.9.5", "@cloudradio/icy-parser": "jsr:@cloudradio/icy-parser@^1.0.2", "@char/cbor": "jsr:@char/cbor@^0.1.4", - "@codemirror/autocomplete": "npm:@codemirror/autocomplete@^6.20.0", + "@codemirror/autocomplete": "npm:@codemirror/autocomplete@^6.20.1", "@codemirror/lang-css": "npm:@codemirror/lang-css@^6.3.1", "@codemirror/lang-html": "npm:@codemirror/lang-html@^6.4.11", - "@codemirror/lang-javascript": "npm:@codemirror/lang-javascript@^6.2.4", + "@codemirror/lang-javascript": "npm:@codemirror/lang-javascript@^6.2.5", "@fcrozatier/htmlcrunch": "jsr:@fcrozatier/htmlcrunch@^1.5.1", "@fry69/deep-diff": "jsr:@fry69/deep-diff@^0.1.10", "@js-temporal/polyfill": "npm:@js-temporal/polyfill@^0.5.1", @@ -37,9 +39,8 @@ "fast-uri": "npm:fast-uri@^3.1.0", "idb-keyval": "npm:idb-keyval@^6.2.2", "iso-base": "npm:iso-base@^4.3.0", - "lit-html": "npm:lit-html@^3.3.1", - "marked": "npm:marked@^17.0.3", - "multiformats": "npm:multiformats@^13.4.2", + "lit-html": "npm:lit-html@^3.3.2", + "marked": "npm:marked@^17.0.4", "query-string": "npm:query-string@^9.3.1", "subsonic-api": "npm:subsonic-api@^3.2.0", "throttle-debounce": "npm:throttle-debounce@^5.0.2", @@ -48,29 +49,28 @@ // music-metadata "@tokenizer/http": "npm:@tokenizer/http@^0.9.2", - "@tokenizer/range": "npm:@tokenizer/range@^0.13.0", - "music-metadata": "npm:music-metadata@^11.10.6", + "@tokenizer/range": "npm:@tokenizer/range@^0.13.1", + "music-metadata": "npm:music-metadata@^11.12.2", // Build "@atcute/lex-cli": "npm:@atcute/lex-cli@^2.5.3", "@dotenv-run/esbuild": "npm:@dotenv-run/esbuild@^1.5.1", - "@std/fs": "jsr:@std/fs@^1.0.19", - "@std/path": "jsr:@std/path@^1.1.2", + "@std/fs": "jsr:@std/fs@^1.0.23", + "@std/path": "jsr:@std/path@^1.1.4", "@types/wicg-file-system-access": "npm:@types/wicg-file-system-access@^2023.10.7", "esbuild-plugins-node-modules-polyfill": "npm:esbuild-plugins-node-modules-polyfill@^1.8.1", "esbuild-plugin-wasm": "npm:esbuild-plugin-wasm@^1.1.0", - "lume/": "https://cdn.jsdelivr.net/gh/lumeland/lume@3.1.4/", + "lume/": "https://cdn.jsdelivr.net/gh/lumeland/lume@3.2.2/", "lume/jsx-runtime": "https://cdn.jsdelivr.net/gh/oscarotero/ssx@0.1.14/jsx-runtime.ts", // Tests - "@astral/astral": "jsr:@astral/astral", - "@std/expect": "jsr:@std/expect", - "@std/testing/bdd": "jsr:@std/testing/bdd", + "@astral/astral": "jsr:@astral/astral@0.5.5", + "@std/expect": "jsr:@std/expect@1.0.18", + "@std/testing/bdd": "jsr:@std/testing@1.0.17/bdd", // Paths "~/": "./src/", - "@testing/": "./src/testing/", "@tests/": "./tests/", }, "exports": { diff --git a/src/common/cid.js b/src/common/cid.js index 0ed28e41..931736ad 100644 --- a/src/common/cid.js +++ b/src/common/cid.js @@ -1,24 +1,22 @@ -import { equals } from "iso-base/utils"; -import { CID } from "multiformats/cid"; -import { sha256 } from "multiformats/hashes/sha2"; +import * as CID from "@atcute/cid"; +import { equals, toSha256 } from "@atcute/uint8array"; /** - * @param {number} code - * @param {Uint8Array} data + * @param {0x55 | 0x71} code + * @param {Uint8Array} data */ export async function create(code, data) { - const hash = await sha256.digest(data); - const cid = CID.create(1, code, hash); - - return cid.toString(); + const cid = await CID.create(code, data); + return CID.toString(cid); } /** - * @param {Uint8Array} data + * @param {Uint8Array} data * @param {string} expected */ export async function verify(data, expected) { - const expectedCid = CID.parse(expected); - const hash = await sha256.digest(data); - return equals(expectedCid.multihash.bytes, hash.bytes); + const expectedCid = CID.fromString(expected); + const digest = await toSha256(data); + + return equals(digest, expectedCid.digest.contents); }