ssbc / ssb-blobs

blob gossiping ssb-subprotocol
MIT License
12 stars 11 forks source link

calling blobs.add remotely #27

Closed austinfrey closed 4 years ago

austinfrey commented 4 years ago

i have a use case where i'd like to call the add method on a remote node. how can i expose this functionality? it's not exposed in the permissions by default, so i tried two options, exposing add directly in the permissions, and also adding my local id to the remote nodes list of master id's. neither seemed to do the trick.

here is some pseudo code to illustrate what i see

const create = CreateStack()

const alice = create(Config('alice', opts))

const bob = create(Config('bob', {
    master: [alice.id]
})

// add blob locally
// works as expected
pull(
    file('some-file-path'),
    alice.blobs.add((err, hash) => {
        console.log(err) // null
        console.log(hash) // &somehashvalues=.sha256
    })
)

// attempt adding a file remotely
// as expected but would like to know
// if this is possible
alice.connect(bob.id, (err, rpc) => {
    pull(
        file('some-file-path'),
        rpc.blobs.add((err, hash) => {
            console.log(err) // null
            console.log(hash) // undefined
        })
    )
})

is there some way to expose add over the network? As another item, when attempting to use this, should it return sone kind of permissions error, rather than (null, undefined)? i think that's how it works in other plugins when a method is not exposed.