Skip to content
This repository has been archived by the owner on Apr 18, 2024. It is now read-only.

web3-storage/ucanto-name-system

Repository files navigation

ucanto-name-service

A networked service that maintains a mapping of DIDs to CIDs.

Controllers of a DID can invoke the name/publish capability to change the CID corresponding to their DID.

Controllers can also delegate the name/publish capability using UCANs so that other people can publish on their behalf.

Anyone can resolve the CID for a DID using the name/resolve capability.

Usage

There is a hosted instance on glitch accessible at:

secret="$(npx --yes @web3-storage/ucanto-name-system request-secret)"
echo "secret=$secret"

did="$(npx --yes @web3-storage/ucanto-name-system whoami $secret)"
echo "did=$did"

glitch_data_uri="https://cypress-fluttering-koala.glitch.me"
glitch_control_uri="$glitch_data_uri/control"

echo "resolving before publish, expecting 404 response"
curl "$glitch_data_uri/$did" -i

echo "publishing new cid"
npx --yes @web3-storage/ucanto-name-system publish --uri="$glitch_control_uri" --secret="$secret" --cid="bafkreigh2akiscaildcqabsyg3dfr6chu3fgpregiymsck7e7aqa4s52zy"

echo "resolving after publish"
curl "$glitch_data_uri/$did" -i | grep location

echo "opening in browser"; sleep 2;
open "$glitch_data_uri/$did"

Interface

interface Publish {
  can: "name/publish"
  with: DID
  content: Link<any>
  origin: null|Link<Publish>
}

interface Resolve {
  can: "name/resolve",
  with: DID
}

interface NameService {
  publish(request: Invocation<Publish>): Promise<
    Result<
      Link<Publish>>,
      PermissionError | OriginError
    >
  >
  resolve(request: Invocation<Resolve>): Promise<
    Result<
      Publish,
      PermissionError | NotFoundError
    >
  >
}