phonepair

package
v0.149.4 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2026 License: MIT Imports: 33 Imported by: 0

Documentation

Overview

Package phonepair implements wing-scoped, two-sided phone enrollment and control.

Index

Constants

View Source
const Lifetime = 5 * time.Minute
View Source
const MaxPayload = 256 << 10

Variables

This section is empty.

Functions

func CheckEmoji

func CheckEmoji(key []byte) string

func DiscoveryName

func DiscoveryName(wingID string) string

DiscoveryName identifies one wing, not a display name or another machine.

func EmojiFromShared

func EmojiFromShared(q Invitation, shared []byte, alice, bob string) string

EmojiFromShared repeats the domain-separated HKDF so callers need not expose cipher internals.

func Fingerprint

func Fingerprint(key string) string

func Identity

func Identity(q Invitation) string

func PairKey

func PairKey(q Invitation, shared []byte, alice, bob string) (cipher.AEAD, error)

Types

type Control

type Control struct {
	Port   int    `json:"port"`
	Token  string `json:"token"`
	WingID string `json:"wing_id"`
	Key    string `json:"key"`
	Name   string `json:"name"`
}

type Device

type Device struct {
	ID             string    `json:"device_id"`
	Name           string    `json:"name"`
	PublicKey      string    `json:"public_key"`
	CredentialHash string    `json:"credential_hash"`
	PairedAt       time.Time `json:"paired_at"`
	LastSeen       time.Time `json:"last_seen"`
	Revoked        bool      `json:"revoked"`
}

type Handler

type Handler interface {
	Execute(context.Context, string, string, string, string) (any, error)
	Close(string)
}

type Invitation

type Invitation struct {
	Version   int       `json:"v"`
	WingID    string    `json:"wing_id"`
	Name      string    `json:"name"`
	Key       string    `json:"key"`
	Local     string    `json:"local"`
	Endpoints []string  `json:"endpoints,omitempty"`
	Relay     string    `json:"relay"`
	ID        string    `json:"id"`
	Secret    string    `json:"secret"`
	ExpiresAt time.Time `json:"expires_at"`
}
func (q Invitation) Link() string

type Manager

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

func New

func New(dir, wingID, name, local string, relay func() string, private *ecdh.PrivateKey, handler Handler) (*Manager, error)

func (*Manager) Allow

func (m *Manager) Allow(id string) error

func (*Manager) Box

func (m *Manager) Box(ctx context.Context, r Request) Response

Box encrypts the entire phone protocol, including PAKE public messages and errors, to the QR-pinned wing key before it enters an untrusted carrier.

func (*Manager) Cancel

func (m *Manager) Cancel(id string) error

func (*Manager) Close

func (m *Manager) Close()

func (*Manager) Create

func (m *Manager) Create() (Invitation, error)

func (*Manager) Devices

func (m *Manager) Devices() []Device

func (*Manager) Handle

func (m *Manager) Handle(ctx context.Context, r Request) Response

func (*Manager) Revoke

func (m *Manager) Revoke(name string) error

func (*Manager) Status

func (m *Manager) Status(id string) (PairStatus, error)

type PairStatus

type PairStatus struct {
	State     string    `json:"state"`
	Name      string    `json:"name,omitempty"`
	Emoji     string    `json:"emoji,omitempty"`
	ExpiresAt time.Time `json:"expires_at"`
}

type Request

type Request struct {
	Op           string `json:"op"`
	ID           string `json:"id,omitempty"`
	Message      string `json:"message,omitempty"`
	SenderPub    string `json:"sender_pub,omitempty"`
	ConnectionID string `json:"connection_id,omitempty"`
	Payload      string `json:"payload,omitempty"`
}

type Response

type Response struct {
	Error        string    `json:"error,omitempty"`
	Message      string    `json:"message,omitempty"`
	Key          string    `json:"key,omitempty"`
	Name         string    `json:"name,omitempty"`
	ExpiresAt    time.Time `json:"expires_at,omitempty"`
	ConnectionID string    `json:"connection_id,omitempty"`
	Payload      string    `json:"payload,omitempty"`
}

type Server

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

func Listen

func Listen(ctx context.Context, dir, wingID, name string, relay func() string, private *ecdh.PrivateKey, handler Handler) (*Server, error)

func (*Server) Close

func (s *Server) Close()

Directories

Path Synopsis
testpeer is an isolated cross-language protocol fixture; it never opens real wing state.
testpeer is an isolated cross-language protocol fixture; it never opens real wing state.

Jump to

Keyboard shortcuts

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