Decentralized web fetch library (@1001-digital/dweb-fetch) — fetch content from IPFS, IPNS, Arweave, HTTPS, and EIP-155 NFT references.
- TypeScript
- Single quotes, no semicolons
src/— Source codesrc/index.ts— Factory (createDwebFetch) + barrel exportssrc/types.ts— Public typessrc/errors.ts— Error classessrc/utils/parse-url.ts— URL scheme extraction + EIP-155 URI parsingsrc/utils/abi.ts— Minimal ABI encode/decode for ERC-721/1155 tokenURI callssrc/protocols/— Protocol handlers (ipfs, arweave, https, eip155)test/— Vitest tests (mirrors src structure)
- Vite build step — outputs JS +
.d.tstodist/, source TS published alongside for editor navigation - Lazy backend init —
createDwebFetch()is synchronous; backends initialize on firstfetch()call - Dynamic imports —
@helia/verified-fetchand@ar.io/wayfinder-coreimported at runtime for tree-shaking - Cached promise pattern for concurrent-safe lazy init
- EIP-155 handler is opt-in — only active when
eip155config withrpcUrlsis provided; usesstartsWith('eip155:')routing (likedata:) since the URI format has no:// - EIP-155 handler delegates resolved tokenURIs back to the parent
DwebClientvia a() => clientclosure
pnpm test # run once
pnpm test:watch # watch modeTests mock all external dependencies (@helia/verified-fetch, @ar.io/wayfinder-core, globalThis.fetch).