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

Patchwork integration #54

Open
wants to merge 53 commits into
base: master
Choose a base branch
from
Open

Patchwork integration #54

wants to merge 53 commits into from

Conversation

ameba23
Copy link
Member

@ameba23 ameba23 commented Apr 7, 2019

the branch has the features needed to add SSB identity recovery to patchwork;

  • requests for forwarding shards
  • attached encrypted blobs allowing for bigger secrets

both these features should be useful for other things outside this specific use case, but for testing its useful right now to have them in one branch

@ameba23 ameba23 added the WIP Work in Progress label Apr 7, 2019
return pull(
shardsFromOthers(),
// This query is specific to recovering SSB identities
pull.filter(shard => get(shard, 'value.content.attachment.name') === 'gossip.json'),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wondering if we can't dynamically pass in filter functions, that way we don't have make this so restrictive...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahh i like that idea

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@KGibb8 so i just changed it that it takes a filter function as an argument.

probably it would be neater if this was a property of the opts object. but i wasn't sure if opts has a standardised form and this would meddle with it.

shardsFromOthers(),
// This query is specific to recovering SSB identities
pull.filter(shard => get(shard, 'value.content.attachment.name') === 'gossip.json'),
pull.unique(s => get(s, 'value.author')),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what exactly this is this doing?

const { isFeedId } = require('ssb-ref')

module.exports = function (server) {
return function bySecretOwner (secretOwner, opts = {}) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is forSecretOwner rather than bySecretOwner, because we're looking for all requests that have been created by person A, who may or may not be person B, and as person C, its a big semantic difference.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

im happy to change it. i was imaging its short for 'indexed by secret owner', like we've got a query for shards indexed 'by root'. but if you are seeing it as 'forward requests authored by secret owner' then thats not what we want.

@m4gpi
Copy link
Member

m4gpi commented Apr 8, 2019

I'm feeling a strong opinion cropping up re the use of the branch field.

I've encountered a situation where a forward could possibly have two branch attributes, but there would be no way to determine the message type of those messages. Which makes for messy querying.

e.g. the branch attribute of a forward message could reference the forward-request or it could reference the shard message.

This far, we haven't implemented having the shard key / id in the branch section. However if we were to do it in future, we'd be looking at significant code changes (more server.get / pull streams as queries) to determine the message type of the branch ID in question.

I'd propose instead of using the branch field, we go with SQL based convention, i.e. a forward schema changes from using the branch attribute to looking something like this:

{ 
  type: 'dark-crystal/forward',
  requestId: '%.........',
  shardId: '%.........',
  ...
}

So at this stage, rather than committing to insert the forward-request ID into the forward branch, we add a field to forward called requestId, and write it to that.

@ameba23
Copy link
Member Author

ameba23 commented Apr 8, 2019

so i've ditched the branch field (we never used it anyway) and added shardId and requestId.

one thing im not sure of is how to handle multiple forward requests (as forward requests dont contain specific information about what they are requesting). so as i've implemented it here, we will just take the first forward request the query gives as. but thinking about it probably the most recent one is more relevant.

does it actually matter? i guess the only thing we are using this for is to determine if we have an outstanding forward request that we didn't already respond to. so maybe we should have a forward-request query for a given secret owner which pairs them with your responses and only tells you about unanswered ones. we could call it outstanding which makes it sound rather great.

})
pull(
pullForwardRequestsSecretOwner(get(shards[0], 'value.author')),
pull.collect((err, forwardRequests) => {
Copy link
Member

@m4gpi m4gpi Apr 15, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change doesn't belong here, since its being used here in patchbay-darl-crystal - https://github.com/blockades/patchbay-dark-crystal/blob/master/views/forward/new.js#L99 - where we're not dealing with forward-requests. We either want to do this in a separate action i.e. forward.async.publishRequestReply (ew) or something like that. Or we make this forward publish function not care about getting data beforehand. I.e. it just simply formats the data (build) and publishes.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ameba23 unless this accounts for its use elsewhere?

Copy link
Member

@m4gpi m4gpi Apr 15, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've changed the Patchwork code to pass in only the rootId of the shard, so this should work for the moment. However, this is restricting as any forward responding to a request will always reference the first one that was returned from the query. See https://github.com/blockades/scuttle-dark-crystal/pull/54/files#r275383477

var requestId = null
if (err) return callback(err)
if (forwardRequests.length > 0) {
requestId = forwardRequests[0]
Copy link
Member

@m4gpi m4gpi Apr 15, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥

If Bob has got a forward-request from Alice2 and Claire, both claiming to be Alice, and Claire's arrived first, we send it to Alice2 (by passing in recp as an argument), but Claire's requestId gets attached instead of Alice2's. When Alice2 receives a forward and tries to cross-reference it with requests sent, the ID's don't match, and Alice2's client gets confused.

Copy link
Member

@m4gpi m4gpi Apr 15, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should instead be passing in the requestId, but that then buggers up the code in patchbay-dark-crystal. I'm much more in favour of a refactor, having an agnostic forward.async.publish method that just takes params (much like root.async.publish), and then either getting the front-end to do the work, or having separate publish actions for the two different contexts we're now dealing with (with requests - Patchwork / without requests - Patchbay)


module.exports = function (server) {
const pullShardsByRoot = PullShardsByRoot(server)
const pullForwardRequestsSecretOwner = PullForwardRequestsSecretOwner(server)
return function publishForward (root, recp, callback) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be noted too that this breaks the pattern we use in the other publish functions, which expect a single params object, rather than two individual arguments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WIP Work in Progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants