bundlr

package
v0.0.0-...-6b33018 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 5, 2024 License: MIT Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Setting this flag disables retrying request with peers
	ContextDisablePeers = value("disablePeers")

	// Forces the URL of the peer, otherwise the default one is picked
	ContextForcePeer = value("forcePeer")
)

Variables

View Source
var (
	ErrSignerNotSpecified                = errors.New("signer not specified")
	ErrUnmarshalEthereumPubKey           = errors.New("cannot unmarshal ethereum pubkey")
	ErrEthereumSignatureMismatch         = errors.New("ethereum signature mismatch")
	ErrFailedToParse                     = errors.New("failed to parse response")
	ErrIdEmpty                           = errors.New("bundle id is empty")
	ErrNotEnoughBytesForSignatureType    = errors.New("not enough bytes for the signature type")
	ErrNotEnoughBytesForSignature        = errors.New("not enough bytes for the signature")
	ErrNotEnoughBytesForOwner            = errors.New("not enough bytes for the owner")
	ErrNotEnoughBytesForTargetFlag       = errors.New("not enough bytes for the target flag")
	ErrNotEnoughBytesForTarget           = errors.New("not enough bytes for the target")
	ErrNotEnoughBytesForAnchorFlag       = errors.New("not enough bytes for the anchor flag")
	ErrNotEnoughBytesForAnchor           = errors.New("not enough bytes for the anchor")
	ErrNotEnoughBytesForNumberOfTags     = errors.New("not enough bytes for the number of tags")
	ErrNotEnoughBytesForNumberOfTagBytes = errors.New("not enough bytes for the number of tag bytes")
	ErrNotEnoughBytesForTags             = errors.New("not enough bytes for tags")
	ErrVerifyIdSignatureMismatch         = errors.New("id doesn't match signature")
	ErrVerifyBadAnchorLength             = errors.New("anchor must be 32 bytes long")
	ErrVerifyTooManyTags                 = errors.New("too many tags, max is 128")
	ErrVerifyEmptyTagName                = errors.New("tag name is empty")
	ErrVerifyTooLongTagName              = errors.New("tag name is too long, max is 1024 bytes")
	ErrVerifyEmptyTagValue               = errors.New("tag value is empty")
	ErrVerifyTooLongTagValue             = errors.New("tag value is too long, max is 3072 bytes")
	ErrVerifyTooManyTagsBytes            = errors.New("serialized tags are too long, max is 4KB")
	ErrBufferTooSmall                    = errors.New("buffer too small")
	ErrUnsupportedSignatureType          = errors.New("unsupported signature type")
	ErrFailedToParseEthereumPublicKey    = errors.New("failed to parse ethereum public key")
	ErrNotSigned                         = errors.New("bundle item not signed")
	ErrInvalidId                         = errors.New("invalid id")
	ErrNestedBundleInvalidLength         = errors.New("nested bundle invalid length in one of the fields")
	ErrAlreadyReceived                   = errors.New("data item already received")
	ErrPaymentRequired                   = errors.New("payment required")
)

Functions

func EthereumHash

func EthereumHash(data []byte) []byte

func LongTo32ByteArray

func LongTo32ByteArray(long int) (out []byte)

func LongTo8ByteArray

func LongTo8ByteArray(long int) (out []byte)

func ShortTo2ByteArray

func ShortTo2ByteArray(long int) []byte

Types

type ArweaveSigner

type ArweaveSigner struct {
	PrivateKey *rsa.PrivateKey
	Owner      []byte
}

func NewArweaveSigner

func NewArweaveSigner(privateKeyJWK string) (self *ArweaveSigner, err error)

func (*ArweaveSigner) GetOwner

func (self *ArweaveSigner) GetOwner() []byte

func (*ArweaveSigner) GetOwnerLength

func (self *ArweaveSigner) GetOwnerLength() int

func (*ArweaveSigner) GetSignatureLength

func (self *ArweaveSigner) GetSignatureLength() int

func (*ArweaveSigner) GetType

func (self *ArweaveSigner) GetType() SignatureType

func (*ArweaveSigner) Sign

func (self *ArweaveSigner) Sign(data []byte) (signature []byte, err error)

func (*ArweaveSigner) Verify

func (self *ArweaveSigner) Verify(data []byte, signature []byte) (err error)

type BaseClient

type BaseClient struct {
	// contains filtered or unexported fields
}

func (*BaseClient) Request

func (self *BaseClient) Request(ctx context.Context) (*resty.Request,
	context.CancelFunc)

func (*BaseClient) Reset

func (self *BaseClient) Reset()

func (*BaseClient) SetPeers

func (self *BaseClient) SetPeers(peers []string)

Set the list of potential peers in order they should be used Uses only peers that are proper urls

type BundleItem

type BundleItem struct {
	SignatureType SignatureType        `json:"signature_type"`
	Signature     arweave.Base64String `json:"signature"`
	Owner         arweave.Base64String `json:"owner"`  //  utils.Base64Encode(pubkey)
	Target        arweave.Base64String `json:"target"` // optional, if exist must length 32, and is base64 str
	Anchor        arweave.Base64String `json:"anchor"` // optional, if exist must length 32, and is base64 str
	Tags          Tags                 `json:"tags"`
	Data          arweave.Base64String `json:"data"`
	Id            arweave.Base64String `json:"id"`
	// contains filtered or unexported fields
}

func (*BundleItem) Encode

func (self *BundleItem) Encode(out io.Writer) (err error)

func (*BundleItem) GetTag

func (self *BundleItem) GetTag(name string) (value string, found bool)

func (*BundleItem) IsSigned

func (self *BundleItem) IsSigned() bool

func (BundleItem) Marshal

func (self BundleItem) Marshal() ([]byte, error)

func (BundleItem) MarshalJSON

func (self BundleItem) MarshalJSON() ([]byte, error)

func (BundleItem) MarshalTo

func (self BundleItem) MarshalTo(buf []byte) (n int, err error)

func (*BundleItem) NestBundles

func (self *BundleItem) NestBundles(dataItems []*BundleItem) (err error)

func (*BundleItem) Reader

func (self *BundleItem) Reader() (out *bytes.Buffer, err error)

func (*BundleItem) Sign

func (self *BundleItem) Sign(signer Signer) (err error)

func (*BundleItem) Size

func (self *BundleItem) Size() (out int)

func (*BundleItem) String

func (self *BundleItem) String() string

func (*BundleItem) Unmarshal

func (self *BundleItem) Unmarshal(buf []byte) (err error)

func (*BundleItem) UnmarshalFromReader

func (self *BundleItem) UnmarshalFromReader(reader io.Reader) (err error)

Reverse operation of Reader

func (*BundleItem) UnmarshalJSON

func (self *BundleItem) UnmarshalJSON(data []byte) error

func (*BundleItem) VerifySignature

func (self *BundleItem) VerifySignature() (err error)

type Client

type Client struct {
	*BaseClient
}

func NewClient

func NewClient(ctx context.Context, config *config.Bundlr) (self *Client)

func (*Client) GetStatus

func (self *Client) GetStatus(ctx context.Context,
	id string) (out *responses.Status, err error)

func (*Client) Upload

func (self *Client) Upload(ctx context.Context,
	item *BundleItem) (out *responses.Upload, resp *resty.Response, err error)

type EthereumSigner

type EthereumSigner struct {
	PrivateKey *ecdsa.PrivateKey
	Owner      []byte
}

func NewEthereumSigner

func NewEthereumSigner(privateKeyHex string) (self *EthereumSigner, err error)

func (*EthereumSigner) GetOwner

func (self *EthereumSigner) GetOwner() []byte

func (*EthereumSigner) GetOwnerLength

func (self *EthereumSigner) GetOwnerLength() int

func (*EthereumSigner) GetSignatureLength

func (self *EthereumSigner) GetSignatureLength() int

func (*EthereumSigner) GetType

func (self *EthereumSigner) GetType() SignatureType

func (*EthereumSigner) Sign

func (self *EthereumSigner) Sign(data []byte) (signature []byte, err error)

func (*EthereumSigner) Verify

func (self *EthereumSigner) Verify(data []byte, signature []byte) (err error)

type SignatureType

type SignatureType int
const (
	SignatureTypeArweave  SignatureType = 1
	SignatureTypeEthereum SignatureType = 3
)

Values are taken from bundlr library https://github.com/Bundlr-Network/arbundles/blob/5413fe576098355f7502a5fa9456f8db6a861492/src/constants.ts#L4

func (SignatureType) Bytes

func (self SignatureType) Bytes() []byte

type Signer

type Signer interface {
	Sign(data []byte) (signature []byte, err error)
	Verify(data []byte, signature []byte) (err error)
	GetOwner() []byte
	GetType() SignatureType
	GetSignatureLength() int
	GetOwnerLength() int
}

func GetSigner

func GetSigner(SignatureType SignatureType, owner []byte) (signer Signer,
	err error)

Signer created ONLY FOR VERIFICATION of the signature. Private key is not initialized.

type Tag

type Tag struct {
	Name  string `json:"name" avro:"name"`
	Value string `json:"value" avro:"value"`
}

type Tags

type Tags []Tag

func (Tags) Append

func (self Tags) Append(tags []Tag) Tags

func (Tags) Get

func (self Tags) Get(name string) (string, bool)

func (Tags) Marshal

func (self Tags) Marshal() ([]byte, error)

func (Tags) Size

func (self Tags) Size() int

func (Tags) Unmarshal

func (self Tags) Unmarshal(data []byte) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL