forked from hyperledger-archives/aries-framework-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
doc.go
77 lines (75 loc) · 2.53 KB
/
doc.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
/*
Copyright SecureKey Technologies Inc. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
// Package outofband provides support for the Out-of-Band protocols:
// https://github.com/hyperledger/aries-rfcs/blob/master/features/0434-outofband/README.md.
//
// Create your client:
//
// ctx := getFrameworkContext()
// client, err := outofband.New(ctx)
// if err != nil {
// panic(err)
// }
//
// You can create requests and invitations with client.CreateRequest() and client.CreateInvitation()
// respectively.
//
// You can accept out-of-band requests and invitations received via out of band channels.
// If you have a request or an invitation on hand you can use the client.AcceptRequest() and
// client.AcceptInvitation() respectively. These return the ID of the newly-created connection
// record.
//
// If you're expecting to receive out-of-band invitations or requests via a DIDComm channel then
// you should register to the action event stream and the state event stream:
//
// events := make(chan service.DIDCommAction)
// err = client.RegisterActionEvent(events)
// if err != nil {
// panic(err)
// }
//
// states := make(chan service.StateMsg)
// err = client.RegisterMsgEvent(states)
// if err != nil {
// panic(err)
// }
//
// for {
// select {
// case event := <-events:
// switch event.Message.Type() {
// case outofband.RequestMsgType:
// // inspect the request
// req := &outofband.Request{}
// err = event.Message.Decode(req)
// if err != nil {
// panic(err)
// }
//
// // accept the request:
// event.Continue(&outofband.EventOptions{Label: "Bob"})
// // OR you may reject this request:
// // event.Stop(errors.New("rejected"))
// case outofband.InvitationMsgType:
// // inspect and handle the out-of-band invitation just like with the
// // request message above
// }
// case state := <-states:
// // the connection ID is delivered in a PostState
// if state.Type == service.PostState {
// props := state.Properties.(outofband.Event)
// if props.Error() != nil {
// panic(props.Error())
// }
//
// // the connection ID
// connID := props.ConnectionID()
// }
// }
// }
//
// Note: the ouf-of-band protocol results in the execution of other protocols. You need to subscribe
// to the event and state streams of those protocols as well.
package outofband