Skip to content

fix: skip local daemon when cloning repos owned by a different DID#177

Open
LiranCohen wants to merge 1 commit into
mainfrom
fix/clone-remote-did
Open

fix: skip local daemon when cloning repos owned by a different DID#177
LiranCohen wants to merge 1 commit into
mainfrom
fix/clone-remote-did

Conversation

@LiranCohen

Copy link
Copy Markdown
Contributor

Summary

Fixes cloning repos from another user's DID. Previously, resolveLocalDaemon() unconditionally routed all DID requests to localhost, so cloning did::did:dht:machineA/repo on machine B would hit machine B's own daemon (which doesn't have the repo) and fail with 404.

Root cause: The lockfile had no concept of which DID the daemon serves, so resolveLocalDaemon() had no way to distinguish "my DID" from "someone else's DID."

Changes:

  • Add ownerDid field to DaemonLock type and writeLockfile() (src/daemon/lockfile.ts)
  • Pass ctx.did from serve.ts so the lockfile records the daemon owner
  • In resolveLocalDaemon(), compare requested DID against lock.ownerDid — only use local daemon when they match; otherwise fall through to DID document resolution
  • Lockfiles without ownerDid (written by older versions) are treated as matching for backwards compatibility

Tests added:

  • Lockfile ownerDid write/read
  • resolveGitEndpoint uses local daemon when owner matches
  • resolveGitEndpoint skips local daemon when owner differs

Build, test, and lint all pass.

resolveLocalDaemon() unconditionally routed all DID requests to the
local daemon at localhost, regardless of which DID was being cloned.
When machine B tried to clone machine A's repo, the resolver hit
machine B's own daemon (which doesn't have the repo) and returned 404.

Changes:
- Add ownerDid field to DaemonLock type and writeLockfile()
- Pass ctx.did from serve.ts so the lockfile records the daemon owner
- In resolveLocalDaemon(), compare requested DID against lockfile
  ownerDid — only use local daemon when they match
- Lockfiles without ownerDid (from older versions) are treated as
  matching for backwards compatibility
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.

1 participant