package bridge import ( "amadan.net/oficina/calls/callscore" "context" "encoding/json" ) type Authentication struct{ auth *callscore.Authentication } func BeginAuthentication(address string) (*Authentication, error) { a, e := callscore.BeginAuthentication(context.Background(), address) if e != nil { return nil, e } return &Authentication{auth: a}, nil } // BeginOfferAuthentication is the handoff for a link from the web's // "Join in the app", which carries the offer its browser made: that // browser asks the person to confirm, so the app opens none. See // callscore.BeginOfferAuthentication. func BeginOfferAuthentication(address, offer string) (*Authentication, error) { a, e := callscore.BeginOfferAuthentication(context.Background(), address, offer) if e != nil { return nil, e } return &Authentication{auth: a}, nil } func (a *Authentication) BrowserURL() string { return a.auth.BrowserURL() } func (a *Authentication) Cancel() { a.auth.Cancel() } func (a *Authentication) Wait() (string, error) { r, e := a.auth.Wait() if e != nil { return "", e } b, e := json.Marshal(r) return string(b), e } func (a *Authentication) ConfirmationCode() string { return a.auth.ConfirmationCode() }