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.
118
+
Contains an object with `validate (marshalledData, key)` and `select (dataA, dataB)` functions.
124
119
125
120
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).
126
121
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.
122
+
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 +136,8 @@ Create an IPNS record for being stored in a protocol buffer.
141
136
- `value` (string): ipfs path of the object to be published.
142
137
- `sequenceNumber` (Number): number representing the current version of the record.
143
138
- `lifetime` (string): lifetime of the record (in milliseconds).
144
-
-`callback` (function): operation result.
145
139
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:
140
+
Returns a `Promise` that resolves to an object with the entry's properties eg:
147
141
148
142
```js
149
143
{
@@ -159,16 +153,15 @@ Create an IPNS record for being stored in a protocol buffer.
159
153
160
154
```js
161
155
162
-
ipns.validate(publicKey, ipnsEntry, [callback])
156
+
ipns.validate(publicKey, ipnsEntry)
163
157
```
164
158
165
159
Validate an IPNS record previously stored in a protocol buffer.
166
160
167
161
- `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
162
- `ipnsEntry` (Object): ipns entry record (obtained using the create function).
169
-
-`callback` (function): operation result.
170
163
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.
164
+
Throws an error if the validation was not successful.
172
165
173
166
#### Datastore key
174
167
@@ -203,16 +196,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
203
211
204
- `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
205
- `ipnsEntry` (Object): ipns entry record (obtained using the create function).
213
-
-`callback` (function): operation result.
214
206
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.
207
+
Returns a `Promise`. If the promise resolves to null it means the public key can be extracted directly from the `peer-id`.
216
208
217
209
#### Extract public key from record
218
210
@@ -224,9 +216,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
219
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.
220
+
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