salmon

package
v0.0.0-...-30adf6a Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2018 License: MIT Imports: 17 Imported by: 3

Documentation

Overview

Package salmon implements the Salmon protocol, as defined in http://www.salmon-protocol.org/salmon-protocol-summary.

Index

Constants

View Source
const Rel = "salmon"

Rel is the salmon relation.

View Source
const RelMagicPublicKey = "magic-public-key"

MagicPublicKeyRel is the magic-public-key relation.

Variables

This section is empty.

Functions

func FormatPublicKey

func FormatPublicKey(pk crypto.PublicKey) (string, error)

FormatPublicKey formats a public key into the application/magic-key format.

func FormatPublicKeyDataURL

func FormatPublicKeyDataURL(pk crypto.PublicKey) (string, error)

FormatPublicKeyDataURL returns the data URL for a public key.

func NewHandler

func NewHandler(be Backend) http.Handler

NewHandler creates a new salmon endpoint.

func ParsePublicKey

func ParsePublicKey(s string) (crypto.PublicKey, error)

ParsePublicKey parses a public key from the application/magic-key format.

func ParsePublicKeyDataURL

func ParsePublicKeyDataURL(u string) (crypto.PublicKey, error)

ParsePublicKeyDataURL parses a public key data URL.

func PublicKeyID

func PublicKeyID(pk crypto.PublicKey) (string, error)

PublicKeyID returns the key identifier for a public key.

func ResourcePublicKey

func ResourcePublicKey(resource *xrd.Resource) (crypto.PublicKey, error)

ResourcePublicKey returns a resource's public key.

Types

type Backend

type Backend interface {
	PublicKeyBackend

	// Notify is called when a salmon is pushed to the endpoint.
	Notify(*activitystream.Entry) error
}

A Backend is used to build salmon endpoints.

type MagicData

type MagicData struct {
	Type  string `xml:"type,attr" json:"data_type"`
	Value string `xml:",chardata" json:"data"`
}

A MagicaData contains a type and a value.

type MagicEnv

type MagicEnv struct {
	XMLName  xml.Name    `xml:"http://salmon-protocol.org/ns/magic-env env"`
	Data     *MagicData  `xml:"data"`
	Encoding string      `xml:"encoding"`
	Alg      string      `xml:"alg"`
	Sig      []*MagicSig `xml:"sig"`
}

A MagicEnv is a magic envelope and contains a message bundled along with signature(s) for that message.

func CreateMagicEnv

func CreateMagicEnv(mediaType string, data []byte, priv crypto.PrivateKey) (*MagicEnv, error)

CreateMagicEnv creates a new magic envelope.

func (*MagicEnv) MarshalJSON

func (env *MagicEnv) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*MagicEnv) UnmarshalJSON

func (env *MagicEnv) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaler.

func (*MagicEnv) UnverifiedData

func (env *MagicEnv) UnverifiedData() ([]byte, error)

UnverifiedData returns this envelope's message, without checking the signature.

func (*MagicEnv) Verify

func (env *MagicEnv) Verify(pub crypto.PublicKey) error

Verify checks that the envelope is signed with pub.

type MagicSig

type MagicSig struct {
	KeyID string `xml:"key_id,attr" json:"key_id"`
	Value string `xml:",chardata" json:"value"`
}

A MagicSig is a magic signature.

type PublicKeyBackend

type PublicKeyBackend interface {
	// PublicKey retrieves a public key.
	PublicKey(accountURI string) (crypto.PublicKey, error)
}

PublicKeyBackend represent a Public Key Infrastructure.

func NewPublicKeyBackend

func NewPublicKeyBackend() PublicKeyBackend

NewPublicKeyBackend returns a basic PublicKeyBackend that queries public keys with LRDD.

Jump to

Keyboard shortcuts

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