Skip to content

docs: Fix outdated READMEs for @ucanto/client and @ucanto/transport#388

Open
Dhruv-Varshney-developer wants to merge 7 commits intostoracha:mainfrom
Dhruv-Varshney-developer:main
Open

docs: Fix outdated READMEs for @ucanto/client and @ucanto/transport#388
Dhruv-Varshney-developer wants to merge 7 commits intostoracha:mainfrom
Dhruv-Varshney-developer:main

Conversation

@Dhruv-Varshney-developer
Copy link
Contributor

Partially completes work for #387 - Addresses user report of broken imports and wrong function calls in documentation.

Changes:

  1. @ucanto/transport:
    The old README had imports that don't exist (@ucanto/transport/cbor) and showed wrong function calls. Rewrote it with actual working code that matches what's in the package. Also updated the descriptions to accurately reflect what the package actually does instead of generic text. Now developers can copy-paste and run examples instead of getting import errors.

  2. @ucanto/client:
    The old README used outdated API calls (ed25519.Verifier.parse()) and had incomplete examples with undefined variables. Fixed all the function calls to match current API and added the missing connection setup code. Now the examples actually work when you run them.

Both packages:

Before: Developers tried the README examples and got errors because the code was wrong.
After: Examples run successfully and show how to actually use these packages.


const invocation = await Client.invoke({
// Mock fetch that simulates a UCAN service
const mockFetch = async (url, input) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if it's a good idea for a mock to be in the README, perhaps in a runnable code example in the repo. IMHO the README should shown how to use the library against an already running server - i.e. just the code you'd need to use the client. I'd link to the server README for actually setting up and running a server component.

const issuer = ed25519.parse(process.env.CLIENT_KEYPAIR)

// Mock fetch that simulates a UCAN service
const mockFetch = async (url, init) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, I'd save this for a runnable example in the repo, or better yet a runnable example with an actual server. Mocking the server like this is not great even for tests as it bypasses all delegation chain validation.

Note: in tests, you don't even need a HTTP server running - a Ucanto server is a channel, so you can pass it to the client as the channel to use.

const issuer = ed25519.Signer.parse(process.env.CLIENT_KEYPAIR);
// Parse the service DID (public key)
// SERVICE_DID should be a DID like: did:key:z6Mkk89bC3JrVqKie71YEcc5M1SMVxuCgNx6zLZ8SYJsxALi
const service = ed25519.Verifier.parse(process.env.SERVICE_DID)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const service = ed25519.Verifier.parse(process.env.SERVICE_DID)
const service = DID.parse(process.env.SERVICE_DID)

NiKrause added a commit to NiKrause/ucanto that referenced this pull request Nov 18, 2025
- Remove mock fetch from READMEs, show real server usage
- Use DID.parse() instead of ed25519.Verifier.parse() for service DIDs
- Convert client tests to use server-as-channel pattern
- Add @ucanto/server and @ucanto/validator to client devDependencies
@NiKrause NiKrause mentioned this pull request Nov 18, 2025
hannahhoward pushed a commit that referenced this pull request Feb 16, 2026
**Addresses @alanshaw recommendations from PR #388**

This branch combines PRs #388 and #392 and addresses all review comments
from @alanshaw.

### Changes

**README updates:**
- Removed mock fetch functions from `@ucanto/client` and
`@ucanto/transport` READMEs
- Updated examples to show real server usage (via environment variables)
- Changed `ed25519.Verifier.parse()` to `DID.parse()` for service DIDs
(as suggested)
- Added notes about using server-as-channel for testing, with links to
server README

**Test improvements:**
- Converted `packages/client/test/client.spec.js` from mock fetch to
server-as-channel pattern
- Tests now validate delegation chains (no bypass)
- Added `@ucanto/server` and `@ucanto/validator` to client
devDependencies

### Benefits

- Examples work with real servers (no mocks)
- Tests properly validate UCAN delegation chains
- Follows recommended patterns from the server package
- All tests passing with 100% coverage maintained

### Related

- Addresses review comments from:
#388
- Should complete work for: #387 (which was respected in #392)

---------

Co-authored-by: Dhruv-Varshney-developer <dhruvvarshney77@gmail.com>
Co-authored-by: ash <alan138@gmail.com>
@NiKrause
Copy link
Contributor

i think this PR can be closed since of merged: #407 (which includes that PR)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants