https://github.com/web3-storage/ucanto-name-system
https://github.com/web3-storage/ucanto-name-system
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/web3-storage/ucanto-name-system
- Owner: web3-storage
- Archived: true
- Created: 2022-05-02T18:35:30.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2022-05-24T06:47:58.000Z (about 4 years ago)
- Last Synced: 2025-03-12T22:42:35.998Z (over 1 year ago)
- Language: TypeScript
- Size: 685 KB
- Stars: 3
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# ucanto-name-service
A networked service that maintains a mapping of [DID](https://www.w3.org/TR/did-core/)s to [CID](https://github.com/multiformats/cid)s.
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 [UCAN](https://github.com/ucan-wg/spec)s 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](https://glitch.com/edit/#!/cypress-fluttering-koala) accessible at:
* http-name-resolver: https://cypress-fluttering-koala.glitch.me
* ucanto HTTP transport control plane: https://cypress-fluttering-koala.glitch.me/control
```bash
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
```js
interface Publish {
can: "name/publish"
with: DID
content: Link
origin: null|Link
}
interface Resolve {
can: "name/resolve",
with: DID
}
interface NameService {
publish(request: Invocation): Promise<
Result<
Link>,
PermissionError | OriginError
>
>
resolve(request: Invocation): Promise<
Result<
Publish,
PermissionError | NotFoundError
>
>
}
```