github.com/hyperledger/aries-framework-go@v0.3.2/pkg/client/outofband/doc.go (about) 1 /* 2 Copyright SecureKey Technologies Inc. All Rights Reserved. 3 4 SPDX-License-Identifier: Apache-2.0 5 */ 6 7 // Package outofband provides support for the Out-of-Band protocols: 8 // https://github.com/hyperledger/aries-rfcs/blob/master/features/0434-outofband/README.md. 9 // 10 // Create your client: 11 // 12 // ctx := getFrameworkContext() 13 // client, err := outofband.New(ctx) 14 // if err != nil { 15 // panic(err) 16 // } 17 // 18 // You can create requests and invitations with client.CreateRequest() and client.CreateInvitation() 19 // respectively. 20 // 21 // You can accept out-of-band requests and invitations received via out of band channels. 22 // If you have a request or an invitation on hand you can use the client.AcceptRequest() and 23 // client.AcceptInvitation() respectively. These return the ID of the newly-created connection 24 // record. 25 // 26 // If you're expecting to receive out-of-band invitations or requests via a DIDComm channel then 27 // you should register to the action event stream and the state event stream: 28 // 29 // events := make(chan service.DIDCommAction) 30 // err = client.RegisterActionEvent(events) 31 // if err != nil { 32 // panic(err) 33 // } 34 // 35 // states := make(chan service.StateMsg) 36 // err = client.RegisterMsgEvent(states) 37 // if err != nil { 38 // panic(err) 39 // } 40 // 41 // for { 42 // select { 43 // case event := <-events: 44 // switch event.Message.Type() { 45 // case outofband.RequestMsgType: 46 // // inspect the request 47 // req := &outofband.Invitation{} 48 // err = event.Message.Decode(req) 49 // if err != nil { 50 // panic(err) 51 // } 52 // 53 // // accept the request: 54 // event.Continue(&outofband.EventOptions{Label: "Bob"}) 55 // // OR you may reject this request: 56 // // event.Stop(errors.New("rejected")) 57 // case outofband.InvitationMsgType: 58 // // inspect and handle the out-of-band invitation just like with the 59 // // request message above 60 // } 61 // case state := <-states: 62 // // the connection ID is delivered in a PostState 63 // if state.Type == service.PostState { 64 // props := state.Properties.(outofband.Event) 65 // if props.Error() != nil { 66 // panic(props.Error()) 67 // } 68 // 69 // // the connection ID 70 // connID := props.ConnectionID() 71 // } 72 // } 73 // } 74 // 75 // Note: the ouf-of-band protocol results in the execution of other protocols. You need to subscribe 76 // to the event and state streams of those protocols as well. 77 package outofband