functionland / docs

docs.fx.land
https://docs.fx.land/functionyard
5 stars 8 forks source link

DID Provider P2P APIs #131

Open ruffiano89 opened 2 years ago

ruffiano89 commented 2 years ago

Required:

  1. Create

  2. Resolve

  3. Update

  4. 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
  5. 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
  6. 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
farhoud commented 2 years ago

@ruffiano89 How to secure Update API? anybody on the internet can connect to my Blox and update my DID document. and because you use IPNS there is no validation by hash.

farhoud commented 2 years ago

@ruffiano89 any suggestions for namespace fula.diddoc: import {create, update, resolve} from "fula.diddoc" ?

farhoud commented 2 years ago

@ruffiano89 for testing can you please provide a sample Content: object? or instruction how i can generate it?

ruffiano89 commented 2 years ago

@ruffiano89 any suggestions for namespace fula.diddoc: import {create, update, resolve} from "fula.diddoc" ?

import fulaProvider from 'fula-provider' const didProvider = fulaProvider(ipfs) didProvider.create() didProvider.resolve() didProvider.update()

ruffiano89 commented 2 years ago

@ruffiano89 for testing can you please provide a sample Content: object? or instruction how i can generate it?

I will add source code into fula-sec with test case and you can use as reference. Pls, feel free to ask any question.

ruffiano89 commented 2 years ago

@ruffiano89 How to secure Update API? anybody on the internet can connect to my Blox and update my DID document. and because you use IPNS there is no validation by hash.

await ipfs.name.publish(path, {key: keyName,}) we will add here pem key which is temporarily key after publishing we will remove it. key is only belongs to specific user which is owner.

farhoud commented 2 years ago

@ruffiano89 How to secure Update API? anybody on the internet can connect to my Blox and update my DID document. and because you use IPNS there is no validation by hash. await ipfs.name.publish(path, {key: keyName,}) we will add here pem key which is temporarily key after publishing we will remove it. key is only belongs to specific user which is owner.

How the owner get the pem key?

ruffiano89 commented 2 years ago

@ruffiano89 How to secure Update API? anybody on the internet can connect to my Blox and update my DID document. and because you use IPNS there is no validation by hash. await ipfs.name.publish(path, {key: keyName,}) we will add here pem key which is temporarily key after publishing we will remove it. key is only belongs to specific user which is owner.

How the owner get the pem key?

Each time when we publish new content or update user will use encrypted pem key. after all process should be removed, because its temp pem key. we dont need keep always

farhoud commented 2 years ago

@ruffiano89 How the client (fula) generate pem key? Is it coming from blox ? How the blox know this is owner? How owner can access other to use this API?