Skip to content
This repository has been archived by the owner on May 28, 2024. It is now read-only.

Commit

Permalink
Merge pull request #515 from findy-network/dynamic-invitation
Browse files Browse the repository at this point in the history
public DID as URL
  • Loading branch information
lainio authored Mar 7, 2024
2 parents 51232ee + bc5e086 commit 1bc3596
Show file tree
Hide file tree
Showing 27 changed files with 129 additions and 69 deletions.
1 change: 1 addition & 0 deletions agent/agency/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ func Backup() {
func ResetRegistered(filename string) error {
utils.Settings.SetRegisterName(filename)
fmt.Println("Note! Resetting handshake register, on-boarding starts over.")
Ready.RegisteringComplete()
return Register.Reset(filename)
}

Expand Down
2 changes: 1 addition & 1 deletion agent/async/future_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func TestFuture_GetValue_And_SetChan(t *testing.T) {

func TestFuture_TestWithErrorResult(t *testing.T) {
readValue := func(f *Future) {
defer err2.Catch(err2.Err(func(err error) {
defer err2.Catch(err2.Err(func(error) {
// eat the error
}))
f.value()
Expand Down
2 changes: 1 addition & 1 deletion agent/ssi/cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func TestCache_lazyAdd(t *testing.T) {
{"2nd", fields{nil}, args{"DID_STRING2", NewDid("DID_STRING2", "VER_KEY2")}},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Run(tt.name, func(*testing.T) {
c := &Cache{
cache: tt.fields.cache,
}
Expand Down
12 changes: 6 additions & 6 deletions cmd/agency.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ var AgencyCmd = &cobra.Command{
Long: `
Parent command for starting and pinging agency
`,
Run: func(cmd *cobra.Command, args []string) {
Run: func(cmd *cobra.Command, _ []string) {
SubCmdNeeded(cmd)
},
}
Expand Down Expand Up @@ -71,10 +71,10 @@ Example
--steward-wallet-key 6cih1cVgRH8...dv67o8QbufxaTHot3Qxp \
--steward-did Th7MpTaRZVRYnPiabds81Y
`,
PreRunE: func(cmd *cobra.Command, args []string) (err error) {
PreRunE: func(*cobra.Command, []string) (err error) {
return BindEnvs(agencyStartEnvs, "AGENCY")
},
RunE: func(cmd *cobra.Command, args []string) (err error) {
RunE: func(*cobra.Command, []string) (err error) {
defer err2.Handle(&err)

try.To(aCmd.Validate())
Expand All @@ -101,10 +101,10 @@ Example
findy-agent agency ping \
--base-address http://localhost:8080
`,
PreRunE: func(cmd *cobra.Command, args []string) (err error) {
PreRunE: func(_ *cobra.Command, _ []string) (err error) {
return BindEnvs(agencyPingEnvs, "AGENCY")
},
RunE: func(cmd *cobra.Command, args []string) (err error) {
RunE: func(_ *cobra.Command, _ []string) (err error) {
defer err2.Handle(&err)
try.To(paCmd.Validate())
if !rootFlags.dryRun {
Expand All @@ -125,7 +125,7 @@ at the start up.
Example
findy-agent agency migrate <old-reg> <new-reg> [enclave-key]
`,
RunE: func(cmd *cobra.Command, args []string) (err error) {
RunE: func(_ *cobra.Command, args []string) (err error) {
defer err2.Handle(&err)

migrateCmd.InputReg = args[0]
Expand Down
2 changes: 1 addition & 1 deletion cmd/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ above to your shell configuration script (e.g. .bash_profile/.zshrc).
`,
ValidArgs: []string{"bash", "zsh"},
Args: cobra.MatchAll(cobra.ExactArgs(1), cobra.OnlyValidArgs),
Run: func(cmd *cobra.Command, args []string) {
Run: func(_ *cobra.Command, args []string) {
switch args[0] {
case "bash":
_ = rootCmd.GenBashCompletion(os.Stdout)
Expand Down
4 changes: 2 additions & 2 deletions cmd/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ Example
--key walletExportKey \
--file path/to/my-export-wallet
`,
PreRunE: func(cmd *cobra.Command, args []string) (err error) {
PreRunE: func(cmd *cobra.Command, _ []string) (err error) {
return BindEnvs(exportEnvs, cmd.Name())
},
RunE: func(cmd *cobra.Command, args []string) (err error) {
RunE: func(_ *cobra.Command, _ []string) (err error) {
defer err2.Handle(&err)
try.To(expCmd.Validate())
if !rootFlags.dryRun {
Expand Down
4 changes: 2 additions & 2 deletions cmd/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ Example
--key walletImportKey \
--file /path/to/my-import-wallet
`,
PreRunE: func(cmd *cobra.Command, args []string) (err error) {
PreRunE: func(cmd *cobra.Command, _ []string) (err error) {
return BindEnvs(importEnvs, cmd.Name())
},
RunE: func(cmd *cobra.Command, args []string) (err error) {
RunE: func(_ *cobra.Command, _ []string) (err error) {
defer err2.Handle(&err)
try.To(impCmd.Validate())
if !rootFlags.dryRun {
Expand Down
6 changes: 3 additions & 3 deletions cmd/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var keyCmd = &cobra.Command{
Long: `
Parent command for handling keys
`,
Run: func(cmd *cobra.Command, args []string) {
Run: func(cmd *cobra.Command, _ []string) {
SubCmdNeeded(cmd)
},
}
Expand All @@ -37,10 +37,10 @@ Example
findy-agent tools key create \
--seed 00000000000000000000thisisa_test
`,
PreRunE: func(cmd *cobra.Command, args []string) (err error) {
PreRunE: func(_ *cobra.Command, _ []string) (err error) {
return BindEnvs(keyEnvs, "KEY")
},
RunE: func(cmd *cobra.Command, args []string) (err error) {
RunE: func(_ *cobra.Command, _ []string) (err error) {
defer err2.Handle(&err)
try.To(keyCreateCmd.Validate())
if !rootFlags.dryRun {
Expand Down
2 changes: 1 addition & 1 deletion cmd/ledger.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ var ledgerCmd = &cobra.Command{
Long: `
Parent command for ledger specific actions
`,
Run: func(cmd *cobra.Command, args []string) {
Run: func(cmd *cobra.Command, _ []string) {
SubCmdNeeded(cmd)
},
}
Expand Down
10 changes: 5 additions & 5 deletions cmd/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var poolCmd = &cobra.Command{
Long: `
Parent command for pool commands
`,
Run: func(cmd *cobra.Command, args []string) {
Run: func(cmd *cobra.Command, _ []string) {
SubCmdNeeded(cmd)
},
}
Expand All @@ -39,11 +39,11 @@ Example
--name findy-pool \
--genesis-txn-file my-genesis-txn-file
`,
PreRunE: func(cmd *cobra.Command, args []string) (err error) {
PreRunE: func(*cobra.Command, []string) (err error) {
return BindEnvs(poolCreateEnvs, "POOL")

},
RunE: func(cmd *cobra.Command, args []string) (err error) {
RunE: func(_ *cobra.Command, _ []string) (err error) {
defer err2.Handle(&err)
Cmd := pool.CreateCmd{
Name: poolName,
Expand Down Expand Up @@ -72,10 +72,10 @@ Example
findy-agent ledger pool ping \
--name findy-pool
`,
PreRunE: func(cmd *cobra.Command, args []string) (err error) {
PreRunE: func(_ *cobra.Command, _ []string) (err error) {
return BindEnvs(poolPingEnvs, "POOL")
},
RunE: func(cmd *cobra.Command, args []string) (err error) {
RunE: func(_ *cobra.Command, _ []string) (err error) {
defer err2.Handle(&err)
Cmd := pool.PingCmd{
Name: poolName,
Expand Down
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var rootCmd = &cobra.Command{
Long: `
Findy agent cli tool
`,
PersistentPreRunE: func(cmd *cobra.Command, args []string) (err error) {
PersistentPreRunE: func(cmd *cobra.Command, _ []string) (err error) {
defer err2.Handle(&err)

// NOTE! Very important. Adds support for std flag pkg users: glog, err2
Expand Down
6 changes: 3 additions & 3 deletions cmd/steward.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var stewardCmd = &cobra.Command{
Long: `
Parent command for steward wallet actions
`,
Run: func(cmd *cobra.Command, args []string) {
Run: func(cmd *cobra.Command, _ []string) {
SubCmdNeeded(cmd)
},
}
Expand All @@ -43,10 +43,10 @@ Example
--wallet-name sovrin_steward_wallet \
--wallet-key 9C5qFG3grXfU9LodHdMop7CNVb3HtKddjgRc7oK5KhWY
`,
PreRunE: func(cmd *cobra.Command, args []string) (err error) {
PreRunE: func(_ *cobra.Command, _ []string) (err error) {
return BindEnvs(stewardCreateEnvs, "STEWARD")
},
RunE: func(cmd *cobra.Command, args []string) (err error) {
RunE: func(_ *cobra.Command, _ []string) (err error) {
defer err2.Handle(&err)
try.To(createStewardCmd.Validate())
if !rootFlags.dryRun {
Expand Down
2 changes: 1 addition & 1 deletion cmd/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ var toolsCmd = &cobra.Command{
Long: `
Parent command for all generic findy-agent tools
`,
Run: func(cmd *cobra.Command, args []string) {
Run: func(cmd *cobra.Command, _ []string) {
SubCmdNeeded(cmd)
},
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var treeCmd = &cobra.Command{
Short: "Prints the findy-agent command structure",
Long: treeDoc,
Args: cobra.MaximumNArgs(1),
RunE: func(cmd *cobra.Command, args []string) (err error) {
RunE: func(_ *cobra.Command, args []string) (err error) {
defer err2.Handle(&err)
if len(args) == 0 {
printStructure(rootCmd, "", 0, true)
Expand Down
2 changes: 1 addition & 1 deletion cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var versionCmd = &cobra.Command{
Use: "version",
Short: "Prints the version and build information of the CLI tool",
Long: versionDoc,
RunE: func(c *cobra.Command, args []string) (err error) {
RunE: func(_ *cobra.Command, _ []string) (err error) {
defer err2.Handle(&err)

try.To1(fmt.Println(utils.Version))
Expand Down
23 changes: 18 additions & 5 deletions grpc/server/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"time"

"github.com/findy-network/findy-agent/agent/bus"
"github.com/findy-network/findy-agent/agent/comm"
"github.com/findy-network/findy-agent/agent/endp"
"github.com/findy-network/findy-agent/agent/pltype"
"github.com/findy-network/findy-agent/agent/prot"
Expand Down Expand Up @@ -222,8 +223,8 @@ func (a *agentServer) GetCredDef(
return &pb.CredDefData{ID: cd.ID, Data: def}, nil
}

func (a *agentServer) CreateInvitation(
ctx context.Context,
func CreateInvitation(
receiver comm.Receiver,
base *pb.InvitationBase,
) (
i *pb.Invitation,
Expand All @@ -239,7 +240,7 @@ func (a *agentServer) CreateInvitation(
glog.V(4).Infoln("generating connection id:", id)
}

addr := try.To1(preallocatePWDID(ctx, id))
addr := try.To1(preallocatePWDID(receiver, id))

label := base.Label
if base.Label == "" {
Expand Down Expand Up @@ -270,13 +271,25 @@ func (a *agentServer) CreateInvitation(
}, nil
}

func preallocatePWDID(ctx context.Context, id string) (ep *endp.Addr, err error) {
func (a *agentServer) CreateInvitation(
ctx context.Context,
base *pb.InvitationBase,
) (
i *pb.Invitation,
err error,
) {
defer err2.Handle(&err, "create invitation")

_, receiver := try.To2(ca(ctx))
return CreateInvitation(receiver, base)
}

func preallocatePWDID(receiver comm.Receiver, id string) (ep *endp.Addr, err error) {
defer err2.Handle(&err)

glog.V(5).Infoln("========== start pre-alloc:", id)
defDIDMethod := utils.Settings.DIDMethod()

_, receiver := try.To2(ca(ctx))
ep = receiver.CAEndp(id)

wa := receiver.WorkerEA()
Expand Down
2 changes: 1 addition & 1 deletion protocol/basicmessage/basic_message_protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func startBasicMessage(ca comm.Receiver, t comm.Task) {
}

func handleBasicMessage(packet comm.Packet) (err error) {
tHandler := func(connID string, im, om didcomm.MessageHdr) (ack bool, err error) {
tHandler := func(connID string, im, _ didcomm.MessageHdr) (ack bool, err error) {
defer err2.Handle(&err, "basic message")

pw := try.To1(packet.Receiver.FindPWByID(connID))
Expand Down
4 changes: 2 additions & 2 deletions protocol/issuecredential/holder/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func HandleCredentialOffer(packet comm.Packet) (err error) {
SendNext: sendNext,
WaitingNext: waitingNext,
TaskHeader: &comm.TaskHeader{UserActionPLType: pltype.CANotifyUserAction},
InOut: func(connID string, im, om didcomm.MessageHdr) (ack bool, err error) {
InOut: func(_ string, im, om didcomm.MessageHdr) (ack bool, err error) {
defer err2.Handle(&err, "cred offer ask user (%v)",
packet.Receiver.RootDid().Did())

Expand Down Expand Up @@ -146,7 +146,7 @@ func HandleCredentialIssue(packet comm.Packet) (err error) {
SendNext: pltype.IssueCredentialACK,
WaitingNext: pltype.Terminate, // no next state, we are fine

InOut: func(connID string, im, om didcomm.MessageHdr) (ack bool, err error) {
InOut: func(_ string, im, om didcomm.MessageHdr) (ack bool, err error) {
defer err2.Handle(&err, "cred issue")

issue := im.FieldObj().(*issuecredential.Issue)
Expand Down
8 changes: 4 additions & 4 deletions protocol/issuecredential/issuer/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func HandleCredentialPropose(packet comm.Packet) (err error) {
WaitingNext: waitingNext,
SendOnNACK: pltype.IssueCredentialNACK,
TaskHeader: &comm.TaskHeader{UserActionPLType: pltype.SAIssueCredentialAcceptPropose},
InOut: func(connID string, im, om didcomm.MessageHdr) (ack bool, err error) {
InOut: func(_ string, im, om didcomm.MessageHdr) (ack bool, err error) {
defer err2.Handle(&err, "credential propose handler")

wa := packet.Receiver
Expand Down Expand Up @@ -95,7 +95,7 @@ func ContinueCredentialPropose(ca comm.Receiver, im didcomm.Msg) {
SendNext: pltype.IssueCredentialOffer,
WaitingNext: pltype.IssueCredentialRequest,
SendOnNACK: pltype.IssueCredentialNACK,
Transfer: func(wa comm.Receiver, im, om didcomm.MessageHdr) (ack bool, err error) {
Transfer: func(_ comm.Receiver, im, om didcomm.MessageHdr) (ack bool, err error) {
defer err2.Handle(&err, "credential propose user action handler")

iMsg := im.(didcomm.Msg)
Expand Down Expand Up @@ -129,7 +129,7 @@ func HandleCredentialRequest(packet comm.Packet) (err error) {
Packet: packet,
SendNext: pltype.IssueCredentialIssue,
WaitingNext: pltype.IssueCredentialACK,
InOut: func(connID string, im, om didcomm.MessageHdr) (ack bool, err error) {
InOut: func(_ string, im, om didcomm.MessageHdr) (ack bool, err error) {
defer err2.Handle(&err, "cred req")

req := im.FieldObj().(*issuecredential.Request)
Expand Down Expand Up @@ -158,7 +158,7 @@ func HandleCredentialACK(packet comm.Packet) (err error) {
Packet: packet,
SendNext: pltype.Terminate, // this ends here
WaitingNext: pltype.Terminate, // no next state
InOut: func(connID string, im, om didcomm.MessageHdr) (ack bool, err error) {
InOut: func(_ string, _, _ didcomm.MessageHdr) (ack bool, err error) {
defer err2.Handle(&err, "cred ACK")
return true, nil
},
Expand Down
2 changes: 1 addition & 1 deletion protocol/issuecredential/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ func handleCredentialNACK(packet comm.Packet) (err error) {
Packet: packet,
SendNext: pltype.Terminate, // this ends here
WaitingNext: pltype.Terminate, // no next state
InOut: func(connID string, im, om didcomm.MessageHdr) (ack bool, err error) {
InOut: func(_ string, _, _ didcomm.MessageHdr) (ack bool, err error) {
defer err2.Handle(&err, "cred NACK")
// return false to mark this PSM to NACK!
return false, nil
Expand Down
4 changes: 2 additions & 2 deletions protocol/notification/problem_report.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ func startProtocol(ca comm.Receiver, t comm.Task) {
WaitingNext: pltype.Terminate,
Ca: ca,
T: t,
Setup: func(key psm.StateKey, om didcomm.MessageHdr) error {
Setup: func(psm.StateKey, didcomm.MessageHdr) error {
// todo: fill the report data here
return nil
},
}))
}

func handleProblemReport(packet comm.Packet) (err error) {
tHandler := func(connID string, im, om didcomm.MessageHdr) (ack bool, err error) {
tHandler := func(_ string, im, _ didcomm.MessageHdr) (ack bool, err error) {
defer err2.Handle(&err, "basic message")

problemReport := im.FieldObj().(*common.ProblemReport)
Expand Down
4 changes: 2 additions & 2 deletions protocol/presentproof/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ func handleProofACK(packet comm.Packet) (err error) {
Packet: packet,
SendNext: pltype.Terminate,
WaitingNext: pltype.Terminate,
InOut: func(connID string, im, om didcomm.MessageHdr) (ack bool, err error) {
InOut: func(_ string, _, _ didcomm.MessageHdr) (ack bool, err error) {
defer err2.Handle(&err, "proof ACK handler")
return true, nil
},
Expand All @@ -289,7 +289,7 @@ func handleProofNACK(packet comm.Packet) (err error) {
Packet: packet,
SendNext: pltype.Terminate,
WaitingNext: pltype.Terminate,
InOut: func(connID string, im, om didcomm.MessageHdr) (ack bool, err error) {
InOut: func(_ string, _, _ didcomm.MessageHdr) (ack bool, err error) {
defer err2.Handle(&err, "proof NACK handler")
return false, nil
},
Expand Down
Loading

0 comments on commit 1bc3596

Please sign in to comment.