-
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
dist/ | ||
|
||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
bower_components | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (http://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules/ | ||
jspm_packages/ | ||
|
||
# Typescript v1 declaration files | ||
typings/ | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# Yarn Integrity file | ||
.yarn-integrity | ||
|
||
# dotenv environment variables file | ||
.env | ||
|
||
# while testing npm5 | ||
package-lock.json | ||
yarn.lock |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
# ipns | ||
|
||
[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://protocol.ai) | ||
[![](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io/) | ||
[![](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) | ||
[![standard-readme](https://img.shields.io/badge/standard--readme-OK-green.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme) | ||
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/feross/standard) | ||
|
||
> ipns record definitions | ||
|
||
This module contains all the necessary code for creating, understanding and validating IPNS records. | ||
|
||
## Lead Maintainer | ||
|
||
[Vasco Santos](https://github.com/vasco-santos). | ||
|
||
## Table of Contents | ||
|
||
- [Install](#install) | ||
- [Usage](#usage) | ||
- [Create Record](#create-record) | ||
- [Validate Record](#validate-record) | ||
- [Embed public key to record](#embed-public-key-to-record) | ||
- [Extract public key from record](#extract-public-key-from-record) | ||
- [Datastore key](#datastore-key) | ||
- [API](#api) | ||
- [Contribute](#contribute) | ||
- [License](#license) | ||
|
||
### Install | ||
|
||
> npm install ipns | ||
|
||
## Usage | ||
|
||
#### Create record | ||
|
||
```js | ||
const ipns = require('./ipns') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be: const ipns = require('ipns') |
||
|
||
ipns.create(privateKey, value, seqNumber, eol, (err, entryData) => { | ||
// your code goes here | ||
}); | ||
``` | ||
|
||
#### Validate record | ||
|
||
```js | ||
const ipns = require('./ipns') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as prev comment. |
||
|
||
ipns.validate(publicKey, ipnsEntry, (err) => { | ||
// your code goes here | ||
// if no error, the record is valid | ||
}); | ||
``` | ||
|
||
#### Embed public key to record | ||
|
||
> Not available yet | ||
|
||
#### Extract public key from record | ||
|
||
> Not available yet | ||
|
||
#### Datastore key | ||
|
||
```js | ||
const ipns = require('./ipns') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same. |
||
|
||
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 commentThe 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 commentThe 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. |
||
|
||
``` | ||
/ipns/${base32(<HASH>)} | ||
``` | ||
|
||
## API | ||
|
||
#### Create record | ||
|
||
```js | ||
|
||
ipns.create(privateKey, value, sequenceNumber, eol, callback); | ||
``` | ||
|
||
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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Yeah! I agree that it is useful here. Will add it |
||
- `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 commentThe reason will be displayed to describe this comment to others. Learn more. Would you mind expanding on this description please? |
||
- `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 commentThe reason will be displayed to describe this comment to others. Learn more. Why not a There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. As you understood, Basically, I think that this function should receive a I didn't go with the EDIT: I will try to update this PR today with this new approach |
||
- `callback` (function): operation result. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. haha, still says |
||
|
||
#### Create record | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This title should read |
||
|
||
```js | ||
|
||
ipns.validate(publicKey, ipnsEntry, callback); | ||
``` | ||
|
||
Create an IPNS record for being stored in a protocol buffer. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wrong description |
||
|
||
- `publicKey` (`PubKey` RSA Instance): key to be used for cryptographic operations. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. same as before 🙂 |
||
- `ipnsEntry` (Object): ipns entry record (obtained using the create function). | ||
- `callback` (function): operation result (if no error, validation successful). | ||
|
||
#### Datastore key | ||
|
||
```js | ||
ipns.getDatastoreKey(peerId); | ||
``` | ||
|
||
Get a key for storing the ipns entry in the datastore. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This doesn't feel like it belongs here...shouldn't it be something that the datastore determines? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, maybe the name was not the best one. For Therefore, I will change this name to |
||
|
||
- `peerId` (`Uint8Array`): peer identifier. | ||
|
||
## Contribute | ||
|
||
Feel free to join in. All welcome. Open an [issue](https://github.com/ipfs/js-ipns/issues)! | ||
|
||
This repository falls under the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md). | ||
|
||
[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/contributing.md) | ||
|
||
## License | ||
|
||
[MIT](LICENSE) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// Warning: This file is automatically synced from https://github.com/ipfs/ci-sync so if you want to change it, please change it there and ask someone to sync all repositories. | ||
javascript() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
{ | ||
"name": "ipns", | ||
"version": "0.1.0", | ||
"description": "ipns record definitions", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there going to more than just record stuff in here? If not would it be better named There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I totally agree with you! It has been discussed here, but there is no agreement yet! It is |
||
"leadMaintainer": "Vasco Santos <[email protected]>", | ||
"main": "src/index.js", | ||
"scripts": { | ||
"build": "aegir build", | ||
"lint": "aegir lint", | ||
"release": "aegir release", | ||
"release-minor": "aegir release --type minor", | ||
"release-major": "aegir release --type major", | ||
"test": "aegir test", | ||
"test:browser": "aegir test -t browser -t webworker", | ||
"test:node": "aegir test -t node" | ||
}, | ||
"pre-push": [ | ||
"lint", | ||
"test" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/ipfs/js-ipns.git" | ||
}, | ||
"keywords": [ | ||
"ipfs", | ||
"ipns" | ||
], | ||
"author": "Vasco Santos <[email protected]>", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/ipfs/js-ipns/issues" | ||
}, | ||
"homepage": "https://github.com/ipfs/js-ipns#readme", | ||
"dependencies": { | ||
"base32-encode": "^1.0.0", | ||
"debug": "^3.1.0", | ||
"protons": "^1.0.1" | ||
}, | ||
"devDependencies": { | ||
"aegir": "^13.1.0", | ||
"chai": "^4.1.2", | ||
"chai-string": "^1.4.0", | ||
"dirty-chai": "^2.0.1", | ||
"ipfs": "^0.28.2", | ||
"ipfsd-ctl": "^0.36.0", | ||
"libp2p-crypto": "^0.13.0", | ||
"multihashes": "^0.4.13" | ||
}, | ||
"contributors": [ | ||
"Vasco Santos <[email protected]>" | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
'use strict' | ||
|
||
exports.ERR_IPNS_EXPIRED_RECORD = 'ERR_IPNS_EXPIRED_RECORD' | ||
exports.ERR_UNRECOGNIZED_VALIDITY = 'ERR_UNRECOGNIZED_VALIDITY' | ||
exports.ERR_SIGNATURE_VERIFICATION = 'ERR_SIGNATURE_VERIFICATION' |
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?