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

public DID as URL #515

Merged
merged 9 commits into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
Long: `
Parent command for starting and pinging agency
`,
Run: func(cmd *cobra.Command, args []string) {
Run: func(cmd *cobra.Command, _ []string) {

Check warning on line 22 in cmd/agency.go

View check run for this annotation

Codecov / codecov/patch

cmd/agency.go#L22

Added line #L22 was not covered by tests
SubCmdNeeded(cmd)
},
}
Expand Down Expand Up @@ -71,10 +71,10 @@
--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 @@
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) {

Check warning on line 104 in cmd/agency.go

View check run for this annotation

Codecov / codecov/patch

cmd/agency.go#L104

Added line #L104 was not covered by tests
return BindEnvs(agencyPingEnvs, "AGENCY")
},
RunE: func(cmd *cobra.Command, args []string) (err error) {
RunE: func(_ *cobra.Command, _ []string) (err error) {

Check warning on line 107 in cmd/agency.go

View check run for this annotation

Codecov / codecov/patch

cmd/agency.go#L107

Added line #L107 was not covered by tests
defer err2.Handle(&err)
try.To(paCmd.Validate())
if !rootFlags.dryRun {
Expand All @@ -125,7 +125,7 @@
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) {

Check warning on line 128 in cmd/agency.go

View check run for this annotation

Codecov / codecov/patch

cmd/agency.go#L128

Added line #L128 was not covered by tests
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 @@
`,
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) {

Check warning on line 28 in cmd/completion.go

View check run for this annotation

Codecov / codecov/patch

cmd/completion.go#L28

Added line #L28 was not covered by tests
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 @@
--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) {

Check warning on line 35 in cmd/export.go

View check run for this annotation

Codecov / codecov/patch

cmd/export.go#L35

Added line #L35 was not covered by tests
return BindEnvs(exportEnvs, cmd.Name())
},
RunE: func(cmd *cobra.Command, args []string) (err error) {
RunE: func(_ *cobra.Command, _ []string) (err error) {

Check warning on line 38 in cmd/export.go

View check run for this annotation

Codecov / codecov/patch

cmd/export.go#L38

Added line #L38 was not covered by tests
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 @@
--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) {

Check warning on line 34 in cmd/import.go

View check run for this annotation

Codecov / codecov/patch

cmd/import.go#L34

Added line #L34 was not covered by tests
return BindEnvs(importEnvs, cmd.Name())
},
RunE: func(cmd *cobra.Command, args []string) (err error) {
RunE: func(_ *cobra.Command, _ []string) (err error) {

Check warning on line 37 in cmd/import.go

View check run for this annotation

Codecov / codecov/patch

cmd/import.go#L37

Added line #L37 was not covered by tests
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 @@
Long: `
Parent command for handling keys
`,
Run: func(cmd *cobra.Command, args []string) {
Run: func(cmd *cobra.Command, _ []string) {

Check warning on line 20 in cmd/key.go

View check run for this annotation

Codecov / codecov/patch

cmd/key.go#L20

Added line #L20 was not covered by tests
SubCmdNeeded(cmd)
},
}
Expand All @@ -37,10 +37,10 @@
findy-agent tools key create \
--seed 00000000000000000000thisisa_test
`,
PreRunE: func(cmd *cobra.Command, args []string) (err error) {
PreRunE: func(_ *cobra.Command, _ []string) (err error) {

Check warning on line 40 in cmd/key.go

View check run for this annotation

Codecov / codecov/patch

cmd/key.go#L40

Added line #L40 was not covered by tests
return BindEnvs(keyEnvs, "KEY")
},
RunE: func(cmd *cobra.Command, args []string) (err error) {
RunE: func(_ *cobra.Command, _ []string) (err error) {

Check warning on line 43 in cmd/key.go

View check run for this annotation

Codecov / codecov/patch

cmd/key.go#L43

Added line #L43 was not covered by tests
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 @@
Long: `
Parent command for ledger specific actions
`,
Run: func(cmd *cobra.Command, args []string) {
Run: func(cmd *cobra.Command, _ []string) {

Check warning on line 14 in cmd/ledger.go

View check run for this annotation

Codecov / codecov/patch

cmd/ledger.go#L14

Added line #L14 was not covered by tests
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 @@
Long: `
Parent command for pool commands
`,
Run: func(cmd *cobra.Command, args []string) {
Run: func(cmd *cobra.Command, _ []string) {

Check warning on line 20 in cmd/pool.go

View check run for this annotation

Codecov / codecov/patch

cmd/pool.go#L20

Added line #L20 was not covered by tests
SubCmdNeeded(cmd)
},
}
Expand All @@ -39,11 +39,11 @@
--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) {

Check warning on line 42 in cmd/pool.go

View check run for this annotation

Codecov / codecov/patch

cmd/pool.go#L42

Added line #L42 was not covered by tests
return BindEnvs(poolCreateEnvs, "POOL")

},
RunE: func(cmd *cobra.Command, args []string) (err error) {
RunE: func(_ *cobra.Command, _ []string) (err error) {

Check warning on line 46 in cmd/pool.go

View check run for this annotation

Codecov / codecov/patch

cmd/pool.go#L46

Added line #L46 was not covered by tests
defer err2.Handle(&err)
Cmd := pool.CreateCmd{
Name: poolName,
Expand Down Expand Up @@ -72,10 +72,10 @@
findy-agent ledger pool ping \
--name findy-pool
`,
PreRunE: func(cmd *cobra.Command, args []string) (err error) {
PreRunE: func(_ *cobra.Command, _ []string) (err error) {

Check warning on line 75 in cmd/pool.go

View check run for this annotation

Codecov / codecov/patch

cmd/pool.go#L75

Added line #L75 was not covered by tests
return BindEnvs(poolPingEnvs, "POOL")
},
RunE: func(cmd *cobra.Command, args []string) (err error) {
RunE: func(_ *cobra.Command, _ []string) (err error) {

Check warning on line 78 in cmd/pool.go

View check run for this annotation

Codecov / codecov/patch

cmd/pool.go#L78

Added line #L78 was not covered by tests
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 @@
Long: `
Parent command for steward wallet actions
`,
Run: func(cmd *cobra.Command, args []string) {
Run: func(cmd *cobra.Command, _ []string) {

Check warning on line 20 in cmd/steward.go

View check run for this annotation

Codecov / codecov/patch

cmd/steward.go#L20

Added line #L20 was not covered by tests
SubCmdNeeded(cmd)
},
}
Expand All @@ -43,10 +43,10 @@
--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 @@
Long: `
Parent command for all generic findy-agent tools
`,
Run: func(cmd *cobra.Command, args []string) {
Run: func(cmd *cobra.Command, _ []string) {

Check warning on line 14 in cmd/tools.go

View check run for this annotation

Codecov / codecov/patch

cmd/tools.go#L14

Added line #L14 was not covered by tests
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 @@
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) {

Check warning on line 23 in cmd/tree.go

View check run for this annotation

Codecov / codecov/patch

cmd/tree.go#L23

Added line #L23 was not covered by tests
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 @@
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) {

Check warning on line 18 in cmd/version.go

View check run for this annotation

Codecov / codecov/patch

cmd/version.go#L18

Added line #L18 was not covered by tests
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 @@
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 @@
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) {

Check warning on line 98 in protocol/issuecredential/issuer/handlers.go

View check run for this annotation

Codecov / codecov/patch

protocol/issuecredential/issuer/handlers.go#L98

Added line #L98 was not covered by tests
defer err2.Handle(&err, "credential propose user action handler")

iMsg := im.(didcomm.Msg)
Expand Down Expand Up @@ -129,7 +129,7 @@
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 @@
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 @@
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) {

Check warning on line 191 in protocol/issuecredential/processor.go

View check run for this annotation

Codecov / codecov/patch

protocol/issuecredential/processor.go#L191

Added line #L191 was not covered by tests
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 @@
WaitingNext: pltype.Terminate,
Ca: ca,
T: t,
Setup: func(key psm.StateKey, om didcomm.MessageHdr) error {
Setup: func(psm.StateKey, didcomm.MessageHdr) error {

Check warning on line 33 in protocol/notification/problem_report.go

View check run for this annotation

Codecov / codecov/patch

protocol/notification/problem_report.go#L33

Added line #L33 was not covered by tests
// 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) {

Check warning on line 41 in protocol/notification/problem_report.go

View check run for this annotation

Codecov / codecov/patch

protocol/notification/problem_report.go#L41

Added line #L41 was not covered by tests
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 @@
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 @@
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) {

Check warning on line 292 in protocol/presentproof/processor.go

View check run for this annotation

Codecov / codecov/patch

protocol/presentproof/processor.go#L292

Added line #L292 was not covered by tests
defer err2.Handle(&err, "proof NACK handler")
return false, nil
},
Expand Down
Loading
Loading