tonconnect

package
v1.5.8 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2024 License: MIT Imports: 21 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseStateInit added in v1.1.0

func ParseStateInit(stateInit string) ([]byte, error)

func StaticDomain added in v1.3.1

func StaticDomain(domain string) checkFunc

Types

type Option

type Option func(o *Options)

func WithLifeTimePayload

func WithLifeTimePayload(lifeTimePayload int64) Option

func WithLifeTimeProof

func WithLifeTimeProof(lifeTimeProof int64) Option

type Options

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

type Proof

type Proof struct {
	Address string    `json:"address"`
	Proof   ProofData `json:"proof"`
}

func CreateSignedProof added in v1.2.1

func CreateSignedProof(payload string, accountID tongo.AccountID, privateKey ed25519.PrivateKey, stateInit tlb.StateInit, options ProofOptions) (*Proof, error)

CreateSignedProof returns a proof that the caller posses a private key of a particular account. This can be used on the client side, when the server side runs tonconnect.Server or any other server implementation of ton-connect.

type ProofData

type ProofData struct {
	Timestamp int64  `json:"timestamp"`
	Domain    string `json:"domain"`
	Signature string `json:"signature"`
	Payload   string `json:"payload"`
	StateInit string `json:"state_init"`
}

type ProofOptions added in v1.2.1

type ProofOptions struct {
	Timestamp time.Time
	Domain    string
}

ProofOptions configures particular aspects of a proof.

type Server

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

func NewTonConnect

func NewTonConnect(executor abi.Executor, secret string, opts ...Option) (*Server, error)

func (*Server) CheckPayload added in v1.3.1

func (s *Server) CheckPayload(payload string) (bool, error)

func (*Server) CheckProof

func (s *Server) CheckProof(ctx context.Context, tp *Proof, checkPayload, checkDomain checkFunc) (bool, ed25519.PublicKey, error)

CheckProof aggregated with ready-made data from TonConnect 2.0 1) Client fetches payload from GeneratePayload to be signed by wallet 2) Client connects to the wallet via TonConnect 2.0 and passes ton_proof request with specified payload, for more details see the frontend SDK: https://github.com/ton-connect/sdk/tree/main/packages/sdk 3) User approves connection and client receives signed payload with additional prefixes. 4) Client sends signed result (Proof) to the backend and CheckProof checks correctness of the all prefixes and signature correctness

func (*Server) GeneratePayload

func (s *Server) GeneratePayload() (string, error)

GeneratePayload this is the first stage of the authorization process. Client fetches payload to be signed by wallet

func (*Server) GetSecret

func (s *Server) GetSecret() string

Jump to

Keyboard shortcuts

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