coreapi: Documentation for Name/Key
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com> This commit was moved from ipfs/interface-go-ipfs-core@74695ab9b4f2efc64b6a88fcd900fbd67a63b416 This commit was moved from ipfs/boxo@d733fa263ca5d8340684f8c062ef474000f54fe7
Łukasz Magiera committed
Dec 15, 2017 at 01:03 UTC
b92cca8429acecf498e37fd438df15a323e4c246
1 file changed
+47
core/coreiface/interface.go
+47
@@ -98,26 +98,73 @@ type DagAPI interface {
98
WithDepth(depth int) options.DagTreeOption
99
}
100
101
+// NameAPI specifies the interface to IPNS.
102
+//
103
+// IPNS is a PKI namespace, where names are the hashes of public keys, and the
104
+// private key enables publishing new (signed) values. In both publish and
105
+// resolve, the default name used is the node's own PeerID, which is the hash of
106
+// its public key.
107
+//
108
+// You can use .Key API to list and generate more names and their respective keys.
109
type NameAPI interface {
110
+ // Publish announces new IPNS name
111
Publish(ctx context.Context, path Path, opts ...options.NamePublishOption) (*IpnsEntry, error)
112
+
113
+ // WithValidTime is an option for Publish which specifies for how long the
114
+ // entry will remain valid. Default value is 24h
115
WithValidTime(validTime time.Duration) options.NamePublishOption
116
+
117
+ // WithKey is an option for Publish which specifies the key to use for
118
+ // publishing. Default value is "self" which is the node's own PeerID.
119
+ //
120
+ // You can use .Key API to list and generate more names and their respective keys.
121
WithKey(key string) options.NamePublishOption
122
123
+ // Resolve attempts to resolve the newest version of the specified name
124
Resolve(ctx context.Context, name string, opts ...options.NameResolveOption) (Path, error)
125
+
126
+ // WithRecursive is an option for Resolve which specifies whether to perform a
127
+ // recursive lookup. Default value is false
128
WithRecursive(recursive bool) options.NameResolveOption
129
+
130
+ // WithLocal is an option for Resolve which specifies if the lookup should be
131
+ // offline. Default value is false
132
WithLocal(local bool) options.NameResolveOption
133
+
134
+ // WithNoCache is an option for Resolve which specifies when set to true
135
+ // disables the use of local name cache. Default value is false
136
WithNoCache(nocache bool) options.NameResolveOption
137
}
138
139
+// KeyAPI specifies the interface to Keystore
140
type KeyAPI interface {
141
+ // Generate generates new key, stores it in the keystore under the specified
142
+ // name and returns a base58 encoded multihash of it's public key
143
Generate(ctx context.Context, name string, opts ...options.KeyGenerateOption) (string, error)
144
+
145
+ // WithAlgorithm is an option for Generate which specifies which algorithm
146
+ // should be used for the key. Default is "rsa"
147
+ //
148
+ // Supported algorithms:
149
+ // * rsa
150
+ // * ed25519
151
WithAlgorithm(algorithm string) options.KeyGenerateOption
152
+
153
+ // WithSize is an option for Generate which specifies the size of the key to
154
+ // generated. Default is 0
155
WithSize(size int) options.KeyGenerateOption
156
157
+ // Rename renames oldName key to newName.
158
Rename(ctx context.Context, oldName string, newName string, opts ...options.KeyRenameOption) (string, bool, error)
159
+
160
+ // WithForce is an option for Rename which specifies whether to allow to
161
+ // replace existing keys.
162
WithForce(force bool) options.KeyRenameOption
163
164
+ // List lists keys stored in keystore
165
List(ctx context.Context) (map[string]string, error) //TODO: better key type?
166
+
167
+ // Remove removes keys from keystore
168
Remove(ctx context.Context, name string) (string, error)
169
}
170