-
Notifications
You must be signed in to change notification settings - Fork 1
/
auth.go
74 lines (62 loc) · 3.08 KB
/
auth.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
// Package protocol defines core protocol messages
package protocol
import (
"encoding/json"
"github.com/iden3/go-rapidsnark/types"
"github.com/iden3/iden3comm/v2"
)
const (
// AuthorizationRequestMessageType defines auth request type of the communication protocol
AuthorizationRequestMessageType iden3comm.ProtocolMessage = iden3comm.Iden3Protocol + "authorization/1.0/request"
// AuthorizationResponseMessageType defines auth response type of the communication protocol
AuthorizationResponseMessageType iden3comm.ProtocolMessage = iden3comm.Iden3Protocol + "authorization/1.0/response"
)
// AuthorizationResponseMessage is struct the represents iden3message authorization response
type AuthorizationResponseMessage struct {
ID string `json:"id"`
Typ iden3comm.MediaType `json:"typ,omitempty"`
Type iden3comm.ProtocolMessage `json:"type"`
ThreadID string `json:"thid,omitempty"`
Body AuthorizationMessageResponseBody `json:"body,omitempty"`
From string `json:"from,omitempty"`
To string `json:"to,omitempty"`
}
// AuthorizationMessageResponseBody is struct the represents authorization response data
type AuthorizationMessageResponseBody struct {
DIDDoc json.RawMessage `json:"did_doc,omitempty"`
Message string `json:"message,omitempty"`
Scope []ZeroKnowledgeProofResponse `json:"scope"`
}
// AuthorizationRequestMessage is struct the represents iden3message authorization request
type AuthorizationRequestMessage struct {
ID string `json:"id"`
Typ iden3comm.MediaType `json:"typ,omitempty"`
Type iden3comm.ProtocolMessage `json:"type"`
ThreadID string `json:"thid,omitempty"`
Body AuthorizationRequestMessageBody `json:"body,omitempty"`
From string `json:"from,omitempty"`
To string `json:"to,omitempty"`
}
// AuthorizationRequestMessageBody is body for authorization request
type AuthorizationRequestMessageBody struct {
CallbackURL string `json:"callbackUrl"`
Reason string `json:"reason,omitempty"`
Message string `json:"message,omitempty"`
DIDDoc json.RawMessage `json:"did_doc,omitempty"`
Scope []ZeroKnowledgeProofRequest `json:"scope"`
}
// ZeroKnowledgeProofRequest represents structure of zkp request object
type ZeroKnowledgeProofRequest struct {
ID uint32 `json:"id"` // unique request id
CircuitID string `json:"circuitId"`
Params map[string]interface{} `json:"params,omitempty"`
Optional *bool `json:"optional,omitempty"`
Query map[string]interface{} `json:"query"`
}
// ZeroKnowledgeProofResponse represents structure of zkp response
type ZeroKnowledgeProofResponse struct {
ID uint32 `json:"id"` // unique id to present unique proof request
CircuitID string `json:"circuitId"`
VerifiablePresentation json.RawMessage `json:"vp,omitempty"`
types.ZKProof
}