Giter Club home page Giter Club logo

go-ipns's Introduction

go-ipns

ipns record definitions

standard-readme compliant GoDoc

❗ This repo is no longer maintained.

👉 We highly recommend switching to the maintained version at https://github.com/ipfs/boxo/tree/main/ipns. 🏎️ Good news! There is tooling and documentation to expedite a switch in your repo.

⚠️ If you continue using this repo, please note that security fixes will not be provided (unless someone steps in to maintain it).

📚 Learn more, including how to take the maintainership mantle or ask questions, here.

This package contains all of the components necessary to create, understand, and validate IPNS records. It does not publish or resolve those records. Kubo uses this package internally to manipulate records.

Usage

To create a new IPNS record:

import (
	"time"

	ipns "github.com/ipfs/go-ipns"
	crypto "github.com/libp2p/go-libp2p-crypto"
)

// Generate a private key to sign the IPNS record with. Most of the time, 
// however, you'll want to retrieve an already-existing key from IPFS using the
// go-ipfs/core/coreapi CoreAPI.KeyAPI() interface.
privateKey, publicKey, err := crypto.GenerateKeyPair(crypto.RSA, 2048)
if err != nil {
  panic(err)
}

// Create an IPNS record that expires in one hour and points to the IPFS address
// /ipfs/Qme1knMqwt1hKZbc1BmQFmnm9f36nyQGwXxPGVpVJ9rMK5
ipnsRecord, err := ipns.Create(privateKey, []byte("/ipfs/Qme1knMqwt1hKZbc1BmQFmnm9f36nyQGwXxPGVpVJ9rMK5"), 0, time.Now().Add(1*time.Hour))
if err != nil {
	panic(err)
}

Once you have the record, you’ll need to use IPFS to publish it.

There are several other major operations you can do with go-ipns. Check out the API docs or look at the tests in this repo for examples.

Documentation

https://godoc.org/github.com/ipfs/go-ipns

Want to hack on IPFS?

License

Copyright (c) Protocol Labs, Inc. under the MIT license. See LICENSE file for details.

go-ipns's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

go-ipns's Issues

Consider renaming to go-ipns-record

This package doesn't contain resolution logic. We'll probably want a package containing a value store based resolver/publisher and go-ipns may be the right place for that.

Not compatible while using github.com/ipfs/go-ipfs/namesys

I believe due to the gx dependencies in this (ipfs/go-ipns) it is incompatible while using github.com/ipfs/go-ipfs/namesys in the same package. I'm currently playing around with IPNS for the first time and tried using this package to create records, while also being able to publish/resolve them on a live system, which requires the usage of github.com/ipfs/go-ipfs/namesys but there are type errors preventing compilation.

stop using peer.IDFromString

peer.IDFromString was removed from libp2p, as it is almost always used incorrectly, see libp2p/go-libp2p-core#274.

This repo uses it in

pid, err := peer.IDFromString(pidString)

I'm not 100% sure if it's used correctly here or not, so I can't submit a fix. This needs to be resolved before we can update the IPFS stack to go-libp2p v0.22.0.

Background Concepts and Definitions

So, in order to do any meaningful review I need to ask a lot of boring questions (@Stebalien you knew what you singed up for when you asked me to review), I can't find much information about any of this, I'm reading the README,

Utilities for creating, parsing, and validating IPNS records

What is an IPNS record? (I should even ask what IPNS really is.)

Once you have the record, you’ll need to use IPFS to publish it.

What does it mean to publish it?

The documentation posted is just a GoDoc link with not much meaningful information.

Feel free to reply with just a link where I can read about all of this (please don't let it be a 3 year old closed issue like the one google throws when asking it).

Add usage example to README

I think it would be really helpful to add one or two usage examples to the README, e.g:

import (
	"time"

	util "github.com/ipfs/go-ipfs-util"
	ipns "github.com/ipfs/go-ipns"
	crypto "github.com/libp2p/go-libp2p-crypto"
)

// Is there a more generic way to create the needed private key than requiring go-ipfs-util/go-libp2p-crypto?
seed := util.NewTimeSeededRand()
privateKey, publicKey, err := crypto.GenerateKeyPairWithReader(crypto.RSA, 1024, sr)

// Create an IPNS record that expires in one hour and points to the IPFS address
// /ipfs/Qme1knMqwt1hKZbc1BmQFmnm9f36nyQGwXxPGVpVJ9rMK5
ipnsEntry, err := ipns.Create(privateKey, []byte("/ipfs/Qme1knMqwt1hKZbc1BmQFmnm9f36nyQGwXxPGVpVJ9rMK5"), 0, time.Now().Add(1*time.Hour))
if err != nil {
	panic(err)
}

Add a repo description

We’re trying to make sure every repo has a description (see ipfs-inactive/docs#55) and this repo is missing one. I don’t have permissions to add it, but I’d suggest something like:

Tools for creating, parsing, and validating IPNS records

Needs Review

This package should be thoroughly reviewed. To make it a bit more general-purpose (less libp2p-record specific), I've refactored it quite a bit.

IPNS directories being empty after new file being added

So recently, I published a directory to IPNS then added a file to the directory. After I checked IPNS again, the file did not show up. I know that with IPFS it behaves similarly to version control; the hash is different each time the contents of the directory are changed. My understanding with IPNS was that this was supposed to be a way of more stably pining directories to a single hash identity (correct me if I'm mistaken).

Basically, I've been trying to create an application with an IPNS-based back-end. The previous back-end was previously made with Node.js and MongoDB, and the front-end connected through a localhost gateway. I've been attempting to at least get a stable read-only version of this web app where a nested directory on IPFS/IPNS behaves similarly enough to an API spec.

(NOTE: please let me know if there is any other information you would prefer about this problem. I can add the specific commands and files that were used as well. If you want to see the full documentation of the API spec I'm trying to replicate, I can add that as well. I just didn't want to prematurely cause information overload)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.