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
* test: clarify that paths are allowed with test
* docs: update based on curent API
* Apply suggestions from code review
Co-authored-by: Russell Dempsey <[email protected]>
* docs: document difference between two validators
---------
Co-authored-by: Daniel N <[email protected]>
Co-authored-by: Russell Dempsey <[email protected]>
This is useful when validating IPNS names that use RSA keys, whose public key is embedded in the record (rather than in the routing key as with Ed25519).
Returns the `IPNSRecord` after being deserialized.
106
100
107
-
### Validator
108
-
109
-
```js
110
-
import*asipnsfrom'ipns'
111
-
112
-
constvalidator=ipns.validator
113
-
```
114
-
115
-
Contains an object with `validate (marshalledData, key)` and `select (dataA, dataB)` functions.
116
-
117
-
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).
118
-
119
-
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.
131
-
132
-
-`privateKey` ([PrivateKey](https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.keys.PrivateKey.html)): key to be used for cryptographic operations.
133
-
-`value` (string): IPFS path of the object to be published.
134
-
-`sequenceNumber` (Number): number representing the current version of the record.
135
-
-`lifetime` (Number): lifetime of the record (in milliseconds).
Returns a `Promise` that resolves to an object with a `IPNSRecord`.
139
-
140
-
### Validate record
141
-
142
-
```js
143
-
ipns.validate(publicKey, ipnsRecord)
144
-
```
145
-
146
-
Validate an IPNS record previously stored in a protocol buffer.
147
-
148
-
-`publicKey` ([PublicKey](https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.keys.PublicKey.html)): key to be used for cryptographic operations.
149
-
-`ipnsRecord` (`IPNSRecord`): IPNS record (obtained using the create function).
150
-
151
-
Returns a `Promise`, which may be rejected if the validation was not successful.
152
-
153
-
### Marshal data with proto buffer
154
-
155
-
```js
156
-
constmarshalledData=ipns.marshal(ipnsRecord)
157
-
```
158
-
159
-
Returns the serialized IPNS record.
160
101
161
-
-`ipnsRecord` (`IPNSRecord`): ipns record (obtained using the create function).
162
-
163
-
### Unmarshal data from proto buffer
164
-
165
-
```js
166
-
constdata=ipns.unmarshal(storedData)
167
-
```
168
-
169
-
Returns a `IPNSRecord` after being serialized.
170
-
171
-
-`storedData` (Uint8Array): ipns record serialized.
-`ipnsRecord` (`IPNSRecord`): ipns record (obtained using the create function).
104
+
-<https://ipfs.github.io/js-ipns>
183
105
184
-
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