Conversation
README.md
Outdated
| #### Create record | ||
|
|
||
| ```js | ||
| const ipns = require('./ipns') |
There was a problem hiding this comment.
This should be:
const ipns = require('ipns')
README.md
Outdated
| #### Validate record | ||
|
|
||
| ```js | ||
| const ipns = require('./ipns') |
README.md
Outdated
| #### Datastore key | ||
|
|
||
| ```js | ||
| const ipns = require('./ipns') |
README.md
Outdated
| @@ -0,0 +1,129 @@ | |||
| # ipns | |||
There was a problem hiding this comment.
This should be all uppercase, no?
src/index.js
Outdated
| const ERRORS = require('./errors') | ||
|
|
||
| /** | ||
| * Create creates a new ipns entry and signs it with the given private key. |
d39fa74 to
14e53d0
Compare
14e53d0 to
3afa02c
Compare
README.md
Outdated
|
|
||
| ## License | ||
|
|
||
| [MIT](LICENSE) |
There was a problem hiding this comment.
Would you mind updating this to fit with the IPFS licensing policy? That should just be a slight tweak to this line in the README to add a little info and updating the LICENSE file to make sure copyright is assigned to “Protocol Labs, Inc.” instead of “IPFS” (which is not an entity copyright can be assigned to).
README.md
Outdated
| - `privateKey` (`PrivKey` RSA Instance): key to be used for cryptographic operations. | ||
| - `value` (string): ipfs path of the object to be published. | ||
| - `sequenceNumber` (Number): sequence number of the record. | ||
| - `eol` (string): end of life datetime of the record (according to RFC3339). |
There was a problem hiding this comment.
Why not a Date instance?...oh wait I think the docs are wrong here this needs to be a date as you're calling toISOString on it in create (https://github.com/ipfs/js-ipns/pull/1/files#diff-1fdf421c05c1140f6d71444ea2b27638R23).
There was a problem hiding this comment.
Is it easier to pass a TTL? DNS records use TTL, so it'll be familiar to developers - and this is what seems to be stored in the protobuf...
There was a problem hiding this comment.
As you understood, eol was standing for a date in the last origin commit. Currently, I have a new approach in here.
Basically, I think that this function should receive a lifetime of the record and it should be responsible for calculating the appropriate validity of the record (RFC3339 with nanoseconds precision). And I consider this to be the best approach, as a consequence of the ipns entry requirement of the RFC, which does not allow the usage of the native date.
I didn't go with the ttl parameter instead of lifetime/ validity because the ttl parameter will also be used in the IPNS for caching purposes, as you can see here
EDIT: I will try to update this PR today with this new approach
README.md
Outdated
|
|
||
| - `privateKey` (`PrivKey` RSA Instance): key to be used for cryptographic operations. | ||
| - `value` (string): ipfs path of the object to be published. | ||
| - `sequenceNumber` (Number): sequence number of the record. |
There was a problem hiding this comment.
Would you mind expanding on this description please?
README.md
Outdated
|
|
||
| Create an IPNS record for being stored in a protocol buffer. | ||
|
|
||
| - `privateKey` (`PrivKey` RSA Instance): key to be used for cryptographic operations. |
There was a problem hiding this comment.
A link the module that would provide this instance would be useful here
There was a problem hiding this comment.
Yeah! I agree that it is useful here. Will add it
README.md
Outdated
|
|
||
| Create an IPNS record for being stored in a protocol buffer. | ||
|
|
||
| - `publicKey` (`PubKey` RSA Instance): key to be used for cryptographic operations. |
There was a problem hiding this comment.
A link the module that would provide this instance would be useful here
| - `value` (string): ipfs path of the object to be published. | ||
| - `sequenceNumber` (Number): sequence number of the record. | ||
| - `eol` (string): end of life datetime of the record (according to RFC3339). | ||
| - `callback` (function): operation result. |
There was a problem hiding this comment.
This needs documentation about the shape or class of the object that is returned, it's methods and properties.
There was a problem hiding this comment.
haha, still says (string) here, should it be a number now?
src/index.js
Outdated
| * @param {Object} peerId peer identifier object. | ||
| * @param {Object} entry ipns entry record. | ||
| * @param {function(Error)} [callback] | ||
| * @returns {Promise|void} |
There was a problem hiding this comment.
Currently does not return a promise...
README.md
Outdated
| ipns.getDatastoreKey(peerId); | ||
| ``` | ||
|
|
||
| Returns a key to be used for storing the ipns entry in the datastore according to the specs, that is: |
There was a problem hiding this comment.
Please link to specs you're referring to or reword...
There was a problem hiding this comment.
I will have to reword by now! I still didn't create the PR with specs.
src/index.js
Outdated
| sign(privateKey, value, validityType, validity, (error, signature) => { | ||
| if (error) { | ||
| log.error(error) | ||
| return callback(error) |
test/index.spec.js
Outdated
|
|
||
| it('should create an ipns record correctly', () => { | ||
| const sequence = 0 | ||
| const eol = new Date(Date.now()) |
There was a problem hiding this comment.
Is equivalent to const eol = new Date()
There was a problem hiding this comment.
Changed for milliseconds as previously described.
src/index.js
Outdated
| value: value, | ||
| signature: signature, // TODO confirm format compliance with go-ipfs | ||
| validityType: validityType, | ||
| validity: validity, |
There was a problem hiding this comment.
I'm not sure how this relates to ttl in the protobuf definition - could you explain?
There was a problem hiding this comment.
This proto definition has to be the same as go, in order to guarantee the interoperability among them.
The ttl parameter will also be used in the IPNS for caching purposes, as you can see here. But since it is still experimental in go, I decided to leave it with low priority for now.
|
I have migrated this utility file from |
| - `value` (string): ipfs path of the object to be published. | ||
| - `sequenceNumber` (Number): sequence number of the record. | ||
| - `eol` (string): end of life datetime of the record (according to RFC3339). | ||
| - `callback` (function): operation result. |
There was a problem hiding this comment.
haha, still says (string) here, should it be a number now?
src/index.js
Outdated
| * @param {Object} entry ipns entry record. | ||
| * @param {function(Error)} [callback] | ||
| * @returns {Promise|void} | ||
| * @returns {function(Error)} callback |
There was a problem hiding this comment.
Isn't this @return {Void} also?
src/index.js
Outdated
| * | ||
| * @param {Buffer} key peer identifier object. | ||
| * @returns {string} | ||
| * @returns {Object} containgin the `nameKey` and the `ipnsKey`. |
|
@vasco-santos should there be a test to verify that if I create an IPNS record, marshal it and then unmarshal it that I get the "same" record back? I get the feeling that currently we'd lose the validity field... |
I will add it now, I think it makes sense! |
- Changes the Default TTL to the suggested default of 1 hour per the ipns-record [spec](https://specs.ipfs.tech/ipns/ipns-record/#ttl-uint64) - Allows for a custom TTL to be passed Fixes #310 --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: semantic-release-bot <semantic-release-bot@martynus.net> Co-authored-by: Alex Potsides <alex@achingbrain.net> Co-authored-by: Daniel Norman <1992255+2color@users.noreply.github.com>
## [9.1.0](v9.0.0...v9.1.0) (2024-04-02) ### Features * change default TTL and add support for custom TTL ([#1](#1)) ([#308](#308)) ([d647529](d647529)), closes [/specs.ipfs.tech/ipns/ipns-record/#ttl-uint64](https://github.com/ipfs//specs.ipfs.tech/ipns/ipns-record//issues/ttl-uint64) [#310](#310) ### Trivial Changes * add or force update .github/workflows/js-test-and-release.yml ([#311](#311)) ([0c5f3e1](0c5f3e1)) * add or force update .github/workflows/js-test-and-release.yml ([#312](#312)) ([46a2b72](46a2b72)) * add or force update .github/workflows/js-test-and-release.yml ([#313](#313)) ([e933496](e933496)) * Update .github/workflows/stale.yml [skip ci] ([16e0e10](16e0e10))
This repo aims to be used by
js-ipfsfor creating, understanding and validating IPNS records.This is an important part of js-ipfs PR1400 and once merged and released, the previous PR will be modified for using this module instead of having all the IPNS records code in it.