-
Notifications
You must be signed in to change notification settings - Fork 17
/
request.go
167 lines (122 loc) · 4.62 KB
/
request.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
/*
Copyright SecureKey Technologies Inc. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package model
import (
"github.com/trustbloc/sidetree-core-go/pkg/api/operation"
"github.com/trustbloc/sidetree-core-go/pkg/jws"
"github.com/trustbloc/sidetree-core-go/pkg/patch"
)
// CreateRequest is the struct for create payload JCS.
type CreateRequest struct {
// operation
// Required: true
Operation operation.Type `json:"type,omitempty"`
// Suffix data object
// Required: true
SuffixData *SuffixDataModel `json:"suffixData,omitempty"`
// Delta object
// Required: true
Delta *DeltaModel `json:"delta,omitempty"`
}
// SuffixDataModel is part of create request.
type SuffixDataModel struct {
// Hash of the delta object (required)
DeltaHash string `json:"deltaHash,omitempty"`
// Commitment hash for the next recovery or deactivate operation (required)
RecoveryCommitment string `json:"recoveryCommitment,omitempty"`
// AnchorOrigin signifies the system(s) that know the most recent anchor for this DID (optional)
AnchorOrigin interface{} `json:"anchorOrigin,omitempty"`
// Type signifies the type of entity a DID represents (optional)
Type string `json:"type,omitempty"`
}
// DeltaModel contains patch data (patches used for create, recover, update).
type DeltaModel struct {
// Commitment hash for the next update operation
UpdateCommitment string `json:"updateCommitment,omitempty"`
// Patches defines document patches
Patches []patch.Patch `json:"patches,omitempty"`
}
// UpdateRequest is the struct for update request.
type UpdateRequest struct {
// Operation defines operation type
Operation operation.Type `json:"type"`
// DidSuffix is the suffix of the DID
DidSuffix string `json:"didSuffix"`
// RevealValue is the reveal value
RevealValue string `json:"revealValue"`
// SignedData is compact JWS - signature information
SignedData string `json:"signedData"`
// Delta is encoded delta object
Delta *DeltaModel `json:"delta"`
}
// DeactivateRequest is the struct for deactivating document.
type DeactivateRequest struct {
// Operation
// Required: true
Operation operation.Type `json:"type"`
// DidSuffix of the DID
// Required: true
DidSuffix string `json:"didSuffix"`
// RevealValue is the reveal value
RevealValue string `json:"revealValue"`
// Compact JWS - signature information
SignedData string `json:"signedData"`
}
// UpdateSignedDataModel defines signed data model for update.
type UpdateSignedDataModel struct {
// UpdateKey is the current update key
UpdateKey *jws.JWK `json:"updateKey"`
// DeltaHash of the unsigned delta object
DeltaHash string `json:"deltaHash"`
// AnchorFrom defines earliest time for this operation.
AnchorFrom int64 `json:"anchorFrom,omitempty"`
// AnchorUntil defines expiry time for this operation.
AnchorUntil int64 `json:"anchorUntil,omitempty"`
}
// RecoverSignedDataModel defines signed data model for recovery.
type RecoverSignedDataModel struct {
// DeltaHash of the unsigned delta object
DeltaHash string `json:"deltaHash"`
// RecoveryKey is The current recovery key
RecoveryKey *jws.JWK `json:"recoveryKey"`
// RecoveryCommitment is the commitment used for the next recovery/deactivate
RecoveryCommitment string `json:"recoveryCommitment"`
// AnchorOrigin signifies the system(s) that know the most recent anchor for this DID (optional)
AnchorOrigin interface{} `json:"anchorOrigin,omitempty"`
// AnchorFrom defines earliest time for this operation.
AnchorFrom int64 `json:"anchorFrom,omitempty"`
// AnchorUntil defines expiry time for this operation.
AnchorUntil int64 `json:"anchorUntil,omitempty"`
}
// DeactivateSignedDataModel defines data model for deactivate.
type DeactivateSignedDataModel struct {
// DidSuffix is the suffix of the DID
// Required: true
DidSuffix string `json:"didSuffix"`
// RevealValue is the reveal value
RevealValue string `json:"revealValue"`
// RecoveryKey is the current recovery key
RecoveryKey *jws.JWK `json:"recoveryKey"`
// AnchorFrom defines earliest time for this operation.
AnchorFrom int64 `json:"anchorFrom,omitempty"`
// AnchorUntil defines expiry time for this operation.
AnchorUntil int64 `json:"anchorUntil,omitempty"`
}
// RecoverRequest is the struct for document recovery payload.
type RecoverRequest struct {
// operation
// Required: true
Operation operation.Type `json:"type"`
// DidSuffix is the suffix of the DID
// Required: true
DidSuffix string `json:"didSuffix"`
// RevealValue is the reveal value
RevealValue string `json:"revealValue"`
// Compact JWS - signature information
SignedData string `json:"signedData"`
// Delta object
// Required: true
Delta *DeltaModel `json:"delta"`
}