endojs / endo

Endo is a distributed secure JavaScript sandbox, based on SES
Apache License 2.0
768 stars 68 forks source link

feat(daemon): Invitations #2219

Closed kriskowal closed 2 months ago

kriskowal commented 2 months ago

This change introduces a user workflow for connecting daemons.

alice> endo invite bob > invitation.link
*alice sends bob invitation.link*
bob> endo accept alice < invitation.link

The two parties can now exchange mail.

alice> endo send bob 'Hi, here is @power'
bob> endo inbox
0. alice sent “Hi, here is @power”
bob> endo adopt 0 power 

Here's a transcript for testing this in packages/cli/demo:

> endo make counter.js --name counter
Object [Alleged: Counter] {}

> endo mkhost other other-agent
Object [Alleged: EndoHost] {}

> endo invite bob > invitation.link

> endo accept alice --as other-agent < invitation.link

> endo send bob 'Hi, here is @counter'

> endo show counter
Object [Alleged: Counter] {}

> endo show counter --as other-agent
CapTP cli exception: (RemoteTypeError(error:captp:Endo#20001)#1)
RemoteTypeError(error:captp:Endo#20001)#1: Unknown pet name: "counter"
...

> endo adopt 0 counter --as other-agent

> endo show counter --as other-agent
Object [Alleged: Counter] {}
rekmarks commented 2 months ago

I'm not sure if the demo is missing some steps or if I'm doing something incorrectly. When I do endo send bob 'Hi, here is @power' (@counter in my case), I get the following error:

CapTP cli exception: (RemoteTypeError(error:captp:Endo#20001)#1)
RemoteTypeError(error:captp:Endo#20001)#1: target has no method "receive", has ["__getInterfaceGuard__","__getMethodNames__","accept","locate"]
...

Because bob is at that point an invitation:

endo show bob
Object [Alleged: Invitation] {}

I first made a guest / host named bob / bob-agent. endo invite bob > invitation.link overwrites bob with the invitation, and bob still refers to the invitation after endo accept alice --as bob < invitation.link.

Two questions:

  1. Is endo invite bob supposed to overwrite bob? Shouldn't there be a different pet name for the invitation?
  2. Am I doing something wrong?
kriskowal commented 2 months ago
  1. Is endo invite bob supposed to overwrite bob? Shouldn't there be a different pet name for the invitation?
  2. Am I doing something wrong?

endo invite bob is supposed to create the invitation named bob.

endo accept alice is supposed to cause alice to overwrite the bob name with alice’s handle.

I don’t think you’re doing something wrong, except perhaps waiting for the acceptance.

We could conceivably cause invitations to queue up messages destined for the to-be-identified recipient.

rekmarks commented 2 months ago

My problem turned out to be completely endogenous. The example does work, I will edit for clarity.