You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Contains an object with `validate (marshalledData, key, callback)` and `select (dataA, dataB, [callback])` functions.
114
+
Contains an object with `validate (marshalledData, key)` and `select (dataA, dataB)` functions.
124
115
125
-
The `validate` function aims to verify if an IPNS record is valid. First the record is unmarshalled, then the public key is obtained and finally the record is validated (signature and validity are verified).
116
+
The `validate`async function aims to verify if an IPNS record is valid. First the record is unmarshalled, then the public key is obtained and finally the record is validated (signature and validity are verified).
126
117
127
-
The `select` function is responsible for deciding which ipns record is the best (newer) between two records. Both records are unmarshalled and their sequence numbers are compared. If the first record provided is the newer, the operation result will be `0`, otherwise the operation result will be `1`. If a callback is not provided, the response is returned.
118
+
The `select` function is responsible for deciding which ipns record is the best (newer) between two records. Both records are unmarshalled and their sequence numbers are compared. If the first record provided is the newer, the operation result will be `0`, otherwise the operation result will be `1`.
Create an IPNS record for being stored in a protocol buffer.
@@ -141,9 +132,8 @@ Create an IPNS record for being stored in a protocol buffer.
141
132
-`value` (string): ipfs path of the object to be published.
142
133
-`sequenceNumber` (Number): number representing the current version of the record.
143
134
-`lifetime` (string): lifetime of the record (in milliseconds).
144
-
-`callback` (function): operation result.
145
135
146
-
`callback` must follow `function (err, ipnsEntry) {}` signature, where `err` is an error if the operation was not successful. `ipnsEntry` is an object that contains the entry's properties, such as:
136
+
Returns a `Promise` that resolves to an object with the entry's properties eg:
147
137
148
138
```js
149
139
{
@@ -159,16 +149,15 @@ Create an IPNS record for being stored in a protocol buffer.
159
149
160
150
```js
161
151
162
-
ipns.validate(publicKey, ipnsEntry, [callback])
152
+
ipns.validate(publicKey, ipnsEntry)
163
153
```
164
154
165
155
Validate an IPNS record previously stored in a protocol buffer.
166
156
167
157
-`publicKey` (`PubKey`[RSA Instance](https://github.com/libp2p/js-libp2p-crypto/blob/master/src/keys/rsa-class.js)): key to be used for cryptographic operations.
168
158
-`ipnsEntry` (Object): ipns entry record (obtained using the create function).
169
-
-`callback` (function): operation result.
170
159
171
-
`callback` must follow `function (err) {}` signature, where `err` is an error if the operation was not successful. This way, if no error, the validation was successful.
160
+
Returns a `Promise`, which may be rejected if the validation was not successful.
172
161
173
162
#### Datastore key
174
163
@@ -203,16 +192,15 @@ Returns the entry data structure after being serialized.
Embed a public key in an IPNS entry. If it is possible to extract the public key from the `peer-id`, there is no need to embed.
210
199
211
200
-`publicKey` (`PubKey`[RSA Instance](https://github.com/libp2p/js-libp2p-crypto/blob/master/src/keys/rsa-class.js)): key to be used for cryptographic operations.
212
201
-`ipnsEntry` (Object): ipns entry record (obtained using the create function).
213
-
-`callback` (function): operation result.
214
202
215
-
`callback` must follow `function (err, resultEntry) {}` signature, where `err` is an error if the operation was not successful. This way, if no error, the operation was successful. If the `resultEntry` is also null, the `peer-id` allows to extract the public key from the `peer-id` and there is no need in extracting it.
203
+
Returns a `Promise`. If the promise resolves to null it means the public key can be extracted directly from the `peer-id`.
216
204
217
205
#### Extract public key from record
218
206
@@ -224,9 +212,8 @@ Extract a public key from an IPNS entry.
-`ipnsEntry` (Object): ipns entry record (obtained using the create function).
227
-
-`callback` (function): operation result.
228
215
229
-
`callback` must follow `function (err, publicKey) {}` signature, where `err` is an error if the operation was not successful. This way, if no error, the validation was successful. The public key (`PubKey`[RSA Instance](https://github.com/libp2p/js-libp2p-crypto/blob/master/src/keys/rsa-class.js)): may be used for cryptographic operations.
216
+
The returned public key (`PubKey`[RSA Instance](https://github.com/libp2p/js-libp2p-crypto/blob/master/src/keys/rsa-class.js)): may be used for cryptographic operations.
0 commit comments