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
Adds a `v1Compatible` option when creating IPNS records that will cause the V1 signature
to be added to the record. This option defaults to true, in the future it will be changed to
false.
The value types have also been updated to make it harder to create invalid records. It now
accepts only CIDs, PeerIds, or arbitrary path strings prefixed with `"/"`.
BREAKING CHANGE: all /ipns/* keys are now encoded as base36 encoded CIDv1 libp2p-cid
Closes#217
---------
Co-authored-by: Marcin Rataj <lidel@lidel.org>
Co-authored-by: Alex Potsides <alex@achingbrain.net>
Returns the entry data structure after being serialized.
120
+
Returns the `IPNSRecord`after being deserialized.
121
121
122
122
### Validator
123
123
@@ -131,81 +131,70 @@ Contains an object with `validate (marshalledData, key)` and `select (dataA, dat
131
131
132
132
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 (`signatureV2` of CBOR `data` is verified).
133
133
134
-
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`.
134
+
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.
146
146
147
147
-`privateKey` (`PrivKey`[RSA Instance](https://github.com/libp2p/js-libp2p-crypto/blob/master/src/keys/rsa-class.js)): key to be used for cryptographic operations.
148
-
-`value` (Uint8Array): ipfs path of the object to be published.
148
+
-`value` (string): IPFS path of the object to be published.
149
149
-`sequenceNumber` (Number): number representing the current version of the record.
150
150
-`lifetime` (Number): lifetime of the record (in milliseconds).
Returns a `Promise` that resolves to an object with the entry's properties eg:
153
-
154
-
```js
155
-
{
156
-
value:Uint8Array,
157
-
signature:Uint8Array, // V1 (legacy, ignored)
158
-
validityType:0,
159
-
validity:Uint8Array,
160
-
sequence:2,
161
-
signatureV2:Uint8Array, // V2 signature of data field
162
-
data:Uint8Array// DAG-CBOR that was signed
163
-
}
164
-
```
153
+
Returns a `Promise` that resolves to an object with a `IPNSRecord`.
165
154
166
155
### Validate record
167
156
168
157
```js
169
-
ipns.validate(publicKey, ipnsEntry)
158
+
ipns.validate(publicKey, ipnsRecord)
170
159
```
171
160
172
161
Validate an IPNS record previously stored in a protocol buffer.
173
162
174
163
-`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.
175
-
-`ipnsEntry` (Object): ipns entry record (obtained using the create function).
164
+
-`ipnsRecord` (`IPNSRecord`): IPNS record (obtained using the create function).
176
165
177
166
Returns a `Promise`, which may be rejected if the validation was not successful.
178
167
179
168
### Marshal data with proto buffer
180
169
181
170
```js
182
-
constmarshalledData=ipns.marshal(entryData)
171
+
constmarshalledData=ipns.marshal(ipnsRecord)
183
172
```
184
173
185
-
Returns the entry data serialized.
174
+
Returns the serialized IPNS record.
186
175
187
-
-`entryData` (Object): ipns entry record (obtained using the create function).
176
+
-`ipnsRecord` (`IPNSRecord`): ipns record (obtained using the create function).
188
177
189
178
### Unmarshal data from proto buffer
190
179
191
180
```js
192
181
constdata=ipns.unmarshal(storedData)
193
182
```
194
183
195
-
Returns the entry data structure after being serialized.
184
+
Returns a `IPNSRecord` after being serialized.
196
185
197
-
-`storedData` (Uint8Array): ipns entry record serialized.
186
+
-`storedData` (Uint8Array): ipns record serialized.
-`ipnsEntry` (Object): ipns entry record (obtained using the create function).
197
+
-`ipnsRecord` (`IPNSRecord`): ipns record (obtained using the create function).
209
198
210
199
Returns a `Promise` which resolves to public key ([`PublicKey`](https://github.com/libp2p/js-libp2p-interfaces/blob/master/packages/interface-keys/src/index.ts) ): may be used for cryptographic operations.
0 commit comments