Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DID provider p2p API #132

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions docs/RFCs/did-provider-p2p-api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
Required:
1. Create
2. Resolve
3. Update


1. Create:
Param (content: object)
Returns Content: object
```
const cid = await ipfs.dag.put(content, { storeCodec: 'dag-cbor', hashAlg: 'sha2-512' });
const path = `/ipfs/${cid}`;
await ipfs.name.publish(path, {
lifetime: lifetime,
ttl: lifetime,
key: keyName, // optional
});
return content
```
2. Resolve:
Param (peerId: string)
Returns (Content: Object)
```
const path:any = await all(ipfs.name.resolve(peerId));
console.log('path: ', path)
if(!path) return false
const cidStr = path[0].replace(/^\/ipfs\//, '');
const cid = CID.parse(cidStr)
const { value: content } = await ipfs.dag.get(cid);
return content
```
3. Update:
Call Resolve function and get Content with peerID
Update previous content with new Content
```
const cid = await ipfs.dag.put(new_content, { storeCodec: 'dag-cbor', hashAlg: 'sha2-512' });
const path = `/ipfs/${cid}`;
await ipfs.name.publish(path, {
lifetime: lifetime,
ttl: lifetime,
key: keyName, // optional
});
return new_content
```