This repository has been archived by the owner on May 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
receiver.go
71 lines (62 loc) · 1.9 KB
/
receiver.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package comm
import (
"sync"
"github.com/findy-network/findy-agent/agent/endp"
"github.com/findy-network/findy-agent/agent/managed"
"github.com/findy-network/findy-agent/agent/sec"
"github.com/findy-network/findy-agent/agent/ssi"
storage "github.com/findy-network/findy-agent/agent/storage/api"
"github.com/findy-network/findy-agent/core"
)
type Receiver interface {
MyDID() core.DID
MyCA() Receiver
WorkerEA() Receiver
ExportWallet(key string, exportPath string) (url string)
RootDid() core.DID
SendNYM(targetDid *ssi.DID, submitterDid, alias, role string) (err error)
LoadDID(did string) core.DID
LoadTheirDID(connection storage.Connection) core.DID
WDID() string
PwPipe(pw string) (cp sec.Pipe, err error)
NewOutDID(didInfo ...string) (id core.DID, err error)
Wallet() int
ManagedWallet() (managed.Wallet, managed.Wallet)
Pool() int
FindPWByID(id string) (pw *storage.Connection, err error)
AttachSAImpl(implID string)
AddToPWMap(me, you core.DID, name string) sec.Pipe
SaveTheirDID(did, vk string) (err error)
CAEndp(connID string) (endP *endp.Addr)
AddPipeToPWMap(p sec.Pipe, name string)
MasterSecret() (string, error)
AutoPermission() bool
ID() string
}
type Receivers struct {
Rcvrs map[string]Receiver
Lk sync.Mutex
}
var ActiveRcvrs = Receivers{
Rcvrs: make(map[string]Receiver),
}
func (rs *Receivers) Add(DID string, r Receiver) {
rs.Lk.Lock()
defer rs.Lk.Unlock()
rs.Rcvrs[DID] = r
}
func (rs *Receivers) Get(DID string) Receiver {
rs.Lk.Lock()
defer rs.Lk.Unlock()
return rs.Rcvrs[DID]
}
// Handler can be Agency or Agent. They can input Payloads.
type Handler interface {
// TODO: lapi, should we consider something else for handler after
// refactoring
//InOutPL(addr *endp.Addr, payload didcomm.Payload) (response didcomm.Payload, nonce string)
}
// SeedHandler is preloaded cloud agent which is not initialized yet.
type SeedHandler interface {
Prepare() (Handler, error)
}