@@ -15,7 +15,6 @@ import (
15
15
cid "github.com/ipfs/go-cid"
16
16
cbornode "github.com/ipfs/go-ipld-cbor"
17
17
coreapi "github.com/ipfs/interface-go-ipfs-core"
18
- "github.com/pkg/errors"
19
18
"github.com/polydawn/refmt/obj/atlas"
20
19
"go.uber.org/zap"
21
20
)
@@ -50,7 +49,7 @@ func (i *ipfsAccessController) CanAppend(entry logac.LogEntry, p identityprovide
50
49
}
51
50
}
52
51
53
- return errors . New ("not allowed" )
52
+ return fmt . Errorf ("not allowed" )
54
53
}
55
54
56
55
func (i * ipfsAccessController ) GetAuthorizedByRole (role string ) ([]string , error ) {
@@ -65,46 +64,46 @@ func (i *ipfsAccessController) GetAuthorizedByRole(role string) ([]string, error
65
64
}
66
65
67
66
func (i * ipfsAccessController ) Grant (ctx context.Context , capability string , keyID string ) error {
68
- return errors . New ("not implemented - does not exist in JS version" )
67
+ return fmt . Errorf ("not implemented - does not exist in JS version" )
69
68
}
70
69
71
70
func (i * ipfsAccessController ) Revoke (ctx context.Context , capability string , keyID string ) error {
72
- return errors . New ("not implemented - does not exist in JS version" )
71
+ return fmt . Errorf ("not implemented - does not exist in JS version" )
73
72
}
74
73
75
74
func (i * ipfsAccessController ) Load (ctx context.Context , address string ) error {
76
75
i .logger .Debug (fmt .Sprintf ("reading IPFS access controller write access on hash %s" , address ))
77
76
78
77
c , err := cid .Decode (address )
79
78
if err != nil {
80
- return errors . Wrap ( err , "unable to parse cid" )
79
+ return fmt . Errorf ( "unable to parse cid: %w" , err )
81
80
}
82
81
83
82
res , err := io .ReadCBOR (ctx , i .ipfs , c )
84
83
if err != nil {
85
- return errors . Wrap ( err , "unable to load access controller manifest data" )
84
+ return fmt . Errorf ( "unable to load access controller manifest data: %w" , err )
86
85
}
87
86
88
87
manifest := & accesscontroller.Manifest {}
89
88
err = cbornode .DecodeInto (res .RawData (), manifest )
90
89
if err != nil {
91
- return errors . Wrap ( err , "unable to unmarshal access controller manifest data" )
90
+ return fmt . Errorf ( "unable to unmarshal access controller manifest data: %w" , err )
92
91
}
93
92
94
93
res , err = io .ReadCBOR (ctx , i .ipfs , manifest .Params .GetAddress ())
95
94
if err != nil {
96
- return errors . Wrap ( err , "unable to load access controller data" )
95
+ return fmt . Errorf ( "unable to load access controller data: %w" , err )
97
96
}
98
97
99
98
writeAccessData := & cborWriteAccess {}
100
99
err = cbornode .DecodeInto (res .RawData (), writeAccessData )
101
100
if err != nil {
102
- return errors . Wrap ( err , "unable to unmarshal access controller data" )
101
+ return fmt . Errorf ( "unable to unmarshal access controller data: %w" , err )
103
102
}
104
103
105
104
var writeAccess []string
106
105
if err := json .Unmarshal ([]byte (writeAccessData .Write ), & writeAccess ); err != nil {
107
- return errors . Wrap ( err , "unable to unmarshal json write access" )
106
+ return fmt . Errorf ( "unable to unmarshal json write access: %w" , err )
108
107
}
109
108
110
109
i .muWriteAccess .Lock ()
@@ -120,12 +119,12 @@ func (i *ipfsAccessController) Save(ctx context.Context) (accesscontroller.Manif
120
119
i .muWriteAccess .RUnlock ()
121
120
122
121
if err != nil {
123
- return nil , errors . Wrap ( err , "unable to serialize write access" )
122
+ return nil , fmt . Errorf ( "unable to serialize write access: %w" , err )
124
123
}
125
124
126
125
c , err := io .WriteCBOR (ctx , i .ipfs , & cborWriteAccess {Write : string (writeAccess )}, nil )
127
126
if err != nil {
128
- return nil , errors . Wrap ( err , "unable to save access controller" )
127
+ return nil , fmt . Errorf ( "unable to save access controller: %w" , err )
129
128
}
130
129
131
130
i .logger .Debug (fmt .Sprintf ("saved IPFS access controller write access on hash %s" , c .String ()))
@@ -134,17 +133,17 @@ func (i *ipfsAccessController) Save(ctx context.Context) (accesscontroller.Manif
134
133
}
135
134
136
135
func (i * ipfsAccessController ) Close () error {
137
- return errors . New ("not implemented - does not exist in JS version" )
136
+ return fmt . Errorf ("not implemented - does not exist in JS version" )
138
137
}
139
138
140
139
// NewIPFSAccessController Returns an access controller for IPFS
141
140
func NewIPFSAccessController (_ context.Context , db iface.BaseOrbitDB , params accesscontroller.ManifestParams , options ... accesscontroller.Option ) (accesscontroller.Interface , error ) {
142
141
if params == nil {
143
- return & ipfsAccessController {}, errors . New ("an options object must be passed" )
142
+ return & ipfsAccessController {}, fmt . Errorf ("an options object must be passed" )
144
143
}
145
144
146
145
if db == nil {
147
- return & ipfsAccessController {}, errors . New ("an OrbitDB instance is required" )
146
+ return & ipfsAccessController {}, fmt . Errorf ("an OrbitDB instance is required" )
148
147
}
149
148
150
149
if len (params .GetAccess ("write" )) == 0 {
0 commit comments