-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: initial implementation #1
Conversation
README.md
Outdated
#### Create record | ||
|
||
```js | ||
const ipns = require('./ipns') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be:
const ipns = require('ipns')
README.md
Outdated
#### Validate record | ||
|
||
```js | ||
const ipns = require('./ipns') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as prev comment.
README.md
Outdated
#### Datastore key | ||
|
||
```js | ||
const ipns = require('./ipns') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same.
README.md
Outdated
@@ -0,0 +1,129 @@ | |||
# ipns |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicate create(s)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
d39fa74
to
14e53d0
Compare
14e53d0
to
3afa02c
Compare
README.md
Outdated
|
||
## License | ||
|
||
[MIT](LICENSE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add link to RFC?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A link the module that would provide this instance would be useful here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A link the module that would provide this instance would be useful here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as before 🙂
README.md
Outdated
- `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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please link to specs you're referring to or reword...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add signing error code?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is equivalent to const eol = new Date()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure how this relates to ttl
in the protobuf definition - could you explain?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
README.md
Outdated
- `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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
haha, still says (string)
here, should it be a number now?
src/index.js
Outdated
@@ -48,7 +60,7 @@ const create = (privateKey, value, seq, eol, callback) => { | |||
* @param {Object} publicKey public key for validating the record. | |||
* @param {Object} entry ipns entry record. | |||
* @param {function(Error)} [callback] | |||
* @returns {Promise|void} | |||
* @returns {function(Error)} callback |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this @return {Void}
also?
src/index.js
Outdated
|
||
/** | ||
* Get key for sharing the record in the routing mechanism. | ||
* Format: ${base32(/ipns/<HASH>)}, ${base32(/pk/<HASH>)} | ||
* | ||
* @param {Buffer} key peer identifier object. | ||
* @returns {string} | ||
* @returns {Object} containgin the `nameKey` and the `ipnsKey`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo "containgin"
@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] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: semantic-release-bot <[email protected]> Co-authored-by: Alex Potsides <[email protected]> Co-authored-by: Daniel Norman <[email protected]>
## [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-ipfs
for 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.