package direct
import "github.com/threefoldtech/rmb-sdk-go/direct"
Index ¶
- Constants
- func Challenge(env *types.Envelope) ([]byte, error)
- func NewJWT(identity substrate.Identity, id uint32, session string, ttl uint32) (string, error)
- func Sign(signer substrate.Identity, input []byte) ([]byte, error)
- func VerifySignature(twinDB TwinDB, env *types.Envelope) error
- type DirectClient
- func NewClient(ctx context.Context, keytype string, mnemonics string, relayURL string, session string, sub *substrate.Substrate, enableEncryption bool) (*DirectClient, error)
- func (d *DirectClient) Call(ctx context.Context, twin uint32, fn string, data interface{}, result interface{}) error
- func (d *DirectClient) Ping(ctx context.Context) error
- type Ed25519VerifyingKey
- type InnerConnection
- func NewConnection(identity substrate.Identity, url string, session string, twinID uint32) InnerConnection
- func (c *InnerConnection) Start(ctx context.Context) (Reader, Writer)
- type Reader
- type RmbSigner
- func (s *RmbSigner) Alg() string
- func (s *RmbSigner) Sign(signingString string, key interface{}) (string, error)
- func (s *RmbSigner) Verify(signingString, signature string, key interface{}) error
- type Sr25519VerifyingKey
- type Twin
- type TwinDB
- type Verifier
- type Writer
Constants ¶
const ( KeyTypeEd25519 = "ed25519" KeyTypeSr25519 = "sr25519" )
const ( SignatureTypeEd25519 = "ed25519" SignatureTypeSr25519 = "sr25519" )
const CustomSigning = "RMB"
Functions ¶
func Challenge ¶
func NewJWT ¶
func Sign ¶
func VerifySignature ¶
VerifySignature is responsible for verifying that the source produced this signature
Types ¶
type DirectClient ¶
type DirectClient struct {
// contains filtered or unexported fields
}
func NewClient ¶
func NewClient(ctx context.Context, keytype string, mnemonics string, relayURL string, session string, sub *substrate.Substrate, enableEncryption bool) (*DirectClient, error)
NewClient creates a new RMB direct client. It connects directly to the RMB-Relay, and peridically tries to reconnect if the connection broke.
You can close the connection by canceling the passed context.
Make sure the context passed to Call() does not outlive the directClient's context. Call() will panic if called while the directClient's context is canceled.
func (*DirectClient) Call ¶
func (d *DirectClient) Call(ctx context.Context, twin uint32, fn string, data interface{}, result interface{}) error
func (*DirectClient) Ping ¶
func (d *DirectClient) Ping(ctx context.Context) error
Ping sends an application level ping. You normally do not ever need to call this yourself because this rmb client takes care of automatic pinging of the server and reconnecting if needed. But in case you want to test if a connection is active and established you can call this Ping method yourself. If no error is returned then ping has succeeded. Make sure to always provide a ctx with a timeout or a deadline otherwise the call will block forever waiting for a response.
type Ed25519VerifyingKey ¶
type Ed25519VerifyingKey []byte
func (Ed25519VerifyingKey) Verify ¶
func (k Ed25519VerifyingKey) Verify(msg []byte, sig []byte) bool
type InnerConnection ¶
type InnerConnection struct {
// contains filtered or unexported fields
}
func NewConnection ¶
func NewConnection(identity substrate.Identity, url string, session string, twinID uint32) InnerConnection
func (*InnerConnection) Start ¶
func (c *InnerConnection) Start(ctx context.Context) (Reader, Writer)
type Reader ¶
type Reader <-chan []byte
func (Reader) Read ¶
type RmbSigner ¶
type RmbSigner struct{}
func (*RmbSigner) Alg ¶
func (*RmbSigner) Sign ¶
func (*RmbSigner) Verify ¶
type Sr25519VerifyingKey ¶
type Sr25519VerifyingKey []byte
func (Sr25519VerifyingKey) Verify ¶
func (k Sr25519VerifyingKey) Verify(msg []byte, sig []byte) bool
type Twin ¶
Twin is used to store a twin id and its public key
type TwinDB ¶
TwinDB is used to get Twin instances
func NewTwinDB ¶
NewTwinDB creates a new twinDBImpl instance, with a non expiring cache.
type Verifier ¶
type Writer ¶
type Writer chan<- []byte
func (Writer) Write ¶
Source Files ¶
connection.go direct.go hashes.go jwt.go sig.go twindb.go
Directories ¶
Path | Synopsis |
---|---|
direct/types |
- Version
- v1.0.1 (latest)
- Published
- Apr 26, 2023
- Platform
- linux/amd64
- Imports
- 31 packages
- Last checked
- 5 months ago –
Tools for package owners.