Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.

Commit

Permalink
chore: deprecate types and readme
Browse files Browse the repository at this point in the history
  • Loading branch information
hacdias committed May 18, 2023
1 parent 72be64e commit 9c326e9
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 6 deletions.
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
# go-ipns

> ipns record definitions
[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](https://protocol.ai)
[![](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](https://ipfs.tech/)
[![standard-readme compliant](https://img.shields.io/badge/standard--readme-OK-green.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme)
[![GoDoc](https://godoc.org/github.com/ipfs/go-datastore?status.svg)](https://godoc.org/github.com/ipfs/go-ipns)

> ipns record definitions

This package contains all of the components necessary to create, understand, and validate IPNS records. It does *not* publish or resolve those records. [Kubo](https://github.com/ipfs/kubo) uses this package internally to manipulate records.
## ❗ 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](https://github.com/ipfs/boxo#migrating-to-boxo) to expedite a switch in your repo.

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

[Adin Schmahmann](https://github.com/aschmahmann)
📚 Learn more, including how to take the maintainership mantle or ask questions, [here](https://github.com/ipfs/boxo/wiki/Copied-or-Migrated-Repos-FAQ).


This package contains all of the components necessary to create, understand, and validate IPNS records. It does *not* publish or resolve those records. [Kubo](https://github.com/ipfs/kubo) uses this package internally to manipulate records.

## Usage

Expand Down
20 changes: 20 additions & 0 deletions errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,59 @@ import (

// ErrExpiredRecord should be returned when an ipns record is
// invalid due to being too old
//
// Deprecated: use github.com/ipfs/boxo/ipns.ErrExpiredRecord
var ErrExpiredRecord = errors.New("expired record")

// ErrUnrecognizedValidity is returned when an IpnsRecord has an
// unknown validity type.
//
// Deprecated: use github.com/ipfs/boxo/ipns.ErrUnrecognizedValidity
var ErrUnrecognizedValidity = errors.New("unrecognized validity type")

// ErrInvalidPath should be returned when an ipns record path
// is not in a valid format
//
// Deprecated: use github.com/ipfs/boxo/ipns.ErrInvalidPath
var ErrInvalidPath = errors.New("record path invalid")

// ErrSignature should be returned when an ipns record fails
// signature verification
//
// Deprecated: use github.com/ipfs/boxo/ipns.ErrSignature
var ErrSignature = errors.New("record signature verification failed")

// ErrKeyFormat should be returned when an ipns record key is
// incorrectly formatted (not a peer ID)
//
// Deprecated: use github.com/ipfs/boxo/ipns.ErrKeyFormat
var ErrKeyFormat = errors.New("record key could not be parsed into peer ID")

// ErrPublicKeyNotFound should be returned when the public key
// corresponding to the ipns record path cannot be retrieved
// from the peer store
//
// Deprecated: use github.com/ipfs/boxo/ipns.ErrPublicKeyNotFound
var ErrPublicKeyNotFound = errors.New("public key not found in peer store")

// ErrPublicKeyMismatch should be returned when the public key embedded in the
// record doesn't match the expected public key.
//
// Deprecated: use github.com/ipfs/boxo/ipns.ErrPublicKeyMismatch
var ErrPublicKeyMismatch = errors.New("public key in record did not match expected pubkey")

// ErrBadRecord should be returned when an ipns record cannot be unmarshalled
//
// Deprecated: use github.com/ipfs/boxo/ipns.ErrBadRecord
var ErrBadRecord = errors.New("record could not be unmarshalled")

// 10 KiB limit defined in https://github.com/ipfs/specs/pull/319
//
// Deprecated: use github.com/ipfs/boxo/ipns.MaxRecordSize
const MaxRecordSize int = 10 << (10 * 1)

// ErrRecordSize should be returned when an ipns record is
// invalid due to being too big
//
// Deprecated: use github.com/ipfs/boxo/ipns.ErrRecordSize
var ErrRecordSize = errors.New("record exceeds allowed size limit")
2 changes: 2 additions & 0 deletions examples/embed.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (
// CreateEntryWithEmbed shows how you can create an IPNS entry
// and embed it with a public key. For ed25519 keys this is not needed
// so attempting to embed with an ed25519 key, will not actually embed the key
//
// Deprecated: use github.com/ipfs/boxo/ipns/examples.CreateEntryWithEmbed
func CreateEntryWithEmbed(ipfsPath string, publicKey crypto.PubKey, privateKey crypto.PrivKey) (*pb.IpnsEntry, error) {
ipfsPathByte := []byte(ipfsPath)
eol := time.Now().Add(time.Hour * 48)
Expand Down
4 changes: 4 additions & 0 deletions examples/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
)

// GenerateRSAKeyPair is used to generate an RSA key pair
//
// Deprecated: use github.com/ipfs/boxo/ipns/examples.GenerateRSAKeyPair
func GenerateRSAKeyPair(bits int) (crypto.PrivKey, error) {
priv, _, err := crypto.GenerateKeyPair(crypto.RSA, bits)
if err != nil {
Expand All @@ -14,6 +16,8 @@ func GenerateRSAKeyPair(bits int) (crypto.PrivKey, error) {
}

// GenerateEDKeyPair is used to generate an ED25519 keypair
//
// Deprecated: use github.com/ipfs/boxo/ipns/examples.GenerateEDKeyPair
func GenerateEDKeyPair() (crypto.PrivKey, error) {
// ED25519 ignores the bit param and uses 256bit keys
priv, _, err := crypto.GenerateKeyPair(crypto.Ed25519, 256)
Expand Down
12 changes: 12 additions & 0 deletions ipns.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ const (
//
// This function does not embed the public key. If you want to do that, use
// `EmbedPublicKey`.
//
// Deprecated: use github.com/ipfs/boxo/ipns.Create
func Create(sk ic.PrivKey, val []byte, seq uint64, eol time.Time, ttl time.Duration) (*pb.IpnsEntry, error) {
entry := new(pb.IpnsEntry)

Expand Down Expand Up @@ -131,6 +133,8 @@ func createCborDataForIpnsEntry(e *pb.IpnsEntry) ([]byte, error) {
}

// Validates validates the given IPNS entry against the given public key.
//
// Deprecated: use github.com/ipfs/boxo/ipns.Validate
func Validate(pk ic.PubKey, entry *pb.IpnsEntry) error {
// Make sure max size is respected
if entry.Size() > MaxRecordSize {
Expand Down Expand Up @@ -254,6 +258,8 @@ func validateCborDataMatchesPbData(entry *pb.IpnsEntry) error {
//
// This function returns ErrUnrecognizedValidity if the validity type of the
// record isn't EOL. Otherwise, it returns an error if it can't parse the EOL.
//
// Deprecated: use github.com/ipfs/boxo/ipns.GetEOL
func GetEOL(entry *pb.IpnsEntry) (time.Time, error) {
if entry.GetValidityType() != pb.IpnsEntry_EOL {
return time.Time{}, ErrUnrecognizedValidity
Expand All @@ -265,6 +271,8 @@ func GetEOL(entry *pb.IpnsEntry) (time.Time, error) {
// strictly required, some nodes (e.g., DHT servers) may reject IPNS entries
// that don't embed their public keys as they may not be able to validate them
// efficiently.
//
// Deprecated: use github.com/ipfs/boxo/ipns.EmbedPublicKey
func EmbedPublicKey(pk ic.PubKey, entry *pb.IpnsEntry) error {
// Try extracting the public key from the ID. If we can, *don't* embed
// it.
Expand Down Expand Up @@ -292,6 +300,8 @@ func EmbedPublicKey(pk ic.PubKey, entry *pb.IpnsEntry) error {
//
// This function returns (nil, nil) when no public key can be extracted and
// nothing is malformed.
//
// Deprecated: use github.com/ipfs/boxo/ipns.ExtractPublicKey
func ExtractPublicKey(pid peer.ID, entry *pb.IpnsEntry) (ic.PubKey, error) {
if entry.PubKey != nil {
pk, err := ic.UnmarshalPublicKey(entry.PubKey)
Expand Down Expand Up @@ -328,6 +338,8 @@ func ExtractPublicKey(pid peer.ID, entry *pb.IpnsEntry) (ic.PubKey, error) {
// order by comparing their serialized byte representations (using
// `bytes.Compare`). You must do this if you are implementing a libp2p record
// validator (or you can just use the one provided for you by this package).
//
// Deprecated: use github.com/ipfs/boxo/ipns.Compare
func Compare(a, b *pb.IpnsEntry) (int, error) {
aHasV2Sig := a.GetSignatureV2() != nil
bHasV2Sig := b.GetSignatureV2() != nil
Expand Down
14 changes: 12 additions & 2 deletions pb/ipns.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions record.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,16 @@ var log = logging.Logger("ipns")
var _ record.Validator = Validator{}

// RecordKey returns the libp2p record key for a given peer ID.
//
// Deprecated: use github.com/ipfs/boxo/ipns.RecordKey
func RecordKey(pid peer.ID) string {
return "/ipns/" + string(pid)
}

// Validator is an IPNS record validator that satisfies the libp2p record
// validator interface.
//
// Deprecated: use github.com/ipfs/boxo/ipns.Validator
type Validator struct {
// KeyBook, if non-nil, will be used to lookup keys for validating IPNS
// records.
Expand Down

0 comments on commit 9c326e9

Please sign in to comment.