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 1
/
v0.go
93 lines (71 loc) · 2.2 KB
/
v0.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package invitation
import (
"encoding/base64"
"encoding/json"
"github.com/lainio/err2"
"github.com/lainio/err2/try"
)
type V0 struct {
// the Image URL of the connection invitation
ImageURL string `json:"imageUrl,omitempty"`
// the Service endpoint of the connection invitation
ServiceEndpoint string `json:"serviceEndpoint,omitempty"`
// the RecipientKeys for the connection invitation
RecipientKeys []string `json:"recipientKeys,omitempty"`
// the ID of the connection invitation
ID string `json:"@id,omitempty"`
// the Label of the connection invitation
Label string `json:"label,omitempty"`
// the RoutingKeys of the connection invitation
RoutingKeys []string `json:"routingKeys,omitempty"`
// the Type of the connection invitation
Type string `json:"@type,omitempty"`
}
type invitationDIDExchangeV0 struct {
V0
}
func CreateInvitationV0(info *AgentInfo) Invitation {
return &invitationDIDExchangeV0{
V0: V0{
Type: info.InvitationType,
ID: info.InvitationID,
Label: info.AgentLabel,
ServiceEndpoint: info.EndpointURL,
RecipientKeys: []string{info.RecipientKey},
},
}
}
func (inv *invitationDIDExchangeV0) Build() (s string, err error) {
defer err2.Handle(&err, "build invitation V0")
const prefix = "didcomm://aries_connection_invitation?c_i="
b := try.To1(json.Marshal(inv))
return prefix + base64.RawURLEncoding.EncodeToString(b), nil
}
func (inv *invitationDIDExchangeV0) Version() DIDExchangeVersion {
return DIDExchangeVersionV0
}
func (inv *invitationDIDExchangeV0) Type() string {
return inv.V0.Type
}
func (inv *invitationDIDExchangeV0) ID() string {
return inv.V0.ID
}
func (inv *invitationDIDExchangeV0) Label() string {
return inv.V0.Label
}
func (inv *invitationDIDExchangeV0) Services() []ServiceEndpoint {
return []ServiceEndpoint{{
ServiceEndpoint: inv.V0.ServiceEndpoint,
RecipientKeys: inv.V0.RecipientKeys,
RoutingKeys: inv.V0.RoutingKeys,
}}
}
func (inv *invitationDIDExchangeV0) ImageURL() string {
return inv.V0.ImageURL
}
func (inv *invitationDIDExchangeV0) Accept() []string {
panic("not implemented")
}
func (inv *invitationDIDExchangeV0) HandshakeProtocols() []string {
panic("not implemented")
}