This repository has been archived by the owner on Feb 1, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathmodel.go
131 lines (115 loc) · 4.76 KB
/
model.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
/*
Copyright 2020 Telefónica Digital España. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package main
// Request to serialize args
type Request struct {
Did string `json:"did,omitempty"`
PublicKey string `json:"publicKey,omitempty"`
Payload string `json:"payload,omitempty"` // me pasa una firma // el controller lo meto yo
}
// Identity stored in bc
type Identity struct {
PublicKey string `json:"publicKey"`
Controller string `json:"controller"` // issuer's DID
Access int `json:"access,omitempty"`
}
// IdentityRequest to serialize args
type IdentityRequest struct {
Did string `json:"did"`
Controller string `json:"controller,omitempty"`
PublicKey string `json:"publicKey"`
Payload string `json:"payload,omitempty"` // me pasa una firma // el controller lo meto yo
Access int `json:"access,omitempty"`
}
// Service stored in bc
type Service struct {
Name string `json:"name"`
Controller string `json:"controller,omitempty"` // issuer's DID
// Access map[string]int `json:"access,omitempty"` // mapping did - access type
Access AccessPolicy `json:"access,omitempty"` // issuer's DID
// Access map[string]int `json:"access,omit
// TODO: Remove, it will be included in the access policy
Channel string `json:"channel"`
}
// PolicyType ..
type PolicyType string
const (
// PublicPolicy the service is public
PublicPolicy PolicyType = "PUBLIC"
// SameControllerPolicy the controller service must be equal to the did's controller that is invoking the service
SameControllerPolicy = "SAME_CONTROLLER"
// FineGrainedPolicy anyone with access can interact
FineGrainedPolicy = "FINE_GRAINED"
// TODO: You can add additional PolicyTypes. Remember to add verification
// logic in hasAccess from chaincode.gateway.go.
)
// AccessPolicy policy
type AccessPolicy struct {
Policy PolicyType `json:"policy"`
Threshold int `json:"threshold,omitempty"`
Registry map[string]int `json:"registry,omitempty"`
}
// ServiceRequest stored in bc
type ServiceRequest struct {
Name string `json:"name"`
Did string `json:"did"`
Access AccessPolicy `json:"access,omitempty"`
}
// IdentityUnverifiedRequest to serialize args
type IdentityUnverifiedRequest struct {
PublicKey string `json:"publicKey"`
Payload string `json:"payload,omitempty"` // me pasa una firma // el controller lo meto yo
}
// CcRequest payload from jws
type CcRequest struct {
Name string `json:"name,omitempty"`
Args []string `json:"args"`
Channel string `json:"channel"`
Did string `json:"did"`
}
// Event to handle events in HF
type Event struct {
EventName string `json:"eventName"` // name for the event
Payload []byte `json:"payload"` // payload for the
}
// Error responses
// ERROR_XXX occurs when XXX
const (
ERRORWrongNumberArgs = `Wrong number of arguments. Expecting a JSON with token information.`
ERRORParsingData = `Error parsing data `
ERRORPutState = `Failed to store data in the ledger. `
ERRORGetState = `Failed to get data from the ledger. `
ERRORDelState = `Failed to delete data from the ledger. `
ERRORChaincodeCall = `Error calling chaincode`
ERRORGetService = `Error getting service`
ERRORUpdService = `Error updating service`
ERRORServiceNotExists = `Error The service doesn't exist`
ERRORCreatingService = "Error storing service"
ERRORParsingService = `Error parsing service`
ERRORServiceExists = `The service already exists in registry`
ERRORDidMissing = `Error calling service, no service DID Specified`
ERRORStoringIdentity = `Error storing identity`
ERRORUpdatingID = `Error updating identity in ledger`
ERRORGetID = `Error getting identity`
ERRORVerID = `Error verification unauthorized, the did provided has not access`
ERRORRevID = `Error revocation unauthorized, the did provided has not access`
ERRORVerSign = `Error verifying signature`
ERRORRevSign = `Error revoking signature`
ERRORRevoke = `Error revoking Unauthorized, the did provided cannot revoke the identity`
ERRORnotID = `Error the identity does not exist`
ERRORParsingID = `Error parsing identity`
ERRORRevokeLedger = `Error deleting from ledger`
ERRORIDExists = `Error the identity already exists`
ERRORUserAccess = `Error user has not access`
ERRORParseJWS = `Error parsing into JWS`
ERRORParseX509 = `Error parsing into X509`
ERRORBase64 = `Error decoding into base64`
ERRORVerifying = `Error verifying signature `
IDGATEWAY = `ID Gateway`
IDREGISTRY = `ID Registry`
ServiceGATEWAY = `ID Service Gateway`
ServiceREGISTRY = `ID Service Registry`
JoseUTIL = `JOSE Util`
)