本文整理汇总了Golang中github.com/keybase/client/go/libkb.ErrToOk函数的典型用法代码示例。如果您正苦于以下问题:Golang ErrToOk函数的具体用法?Golang ErrToOk怎么用?Golang ErrToOk使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ErrToOk函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Init
func (se *SecretEntry) Init() (err error) {
G.Log.Debug("+ SecretEntry.Init()")
if se.initRes != nil {
G.Log.Debug("- SecretEntry.Init() -> cached %s", libkb.ErrToOk(*se.initRes))
return *se.initRes
}
if G.Env.GetNoPinentry() {
G.Log.Debug("| Pinentry skipped due to config")
} else {
pe := pinentry.New(G.Env.GetPinentry(), G.Log)
if e2, fatalerr := pe.Init(); fatalerr != nil {
err = fatalerr
} else if e2 != nil {
G.Log.Debug("| Pinentry initialization failed: %s", e2)
} else {
se.pinentry = pe
G.Log.Debug("| Pinentry initialized")
}
}
if err == nil {
if se.pinentry == nil && se.terminal == nil {
err = fmt.Errorf("No terminal and pinentry init; cannot input secrets")
}
}
se.initRes = &err
G.Log.Debug("- SecretEntry.Init() -> %s", libkb.ErrToOk(err))
return err
}
示例2: prompt
func (s *CmdSignup) prompt() (err error) {
s.G().Log.Debug("+ prompt")
defer func() {
s.G().Log.Debug("- prompt -> %s", libkb.ErrToOk(err))
}()
if !s.doPrompt {
return nil
}
if s.prompter == nil {
s.MakePrompter()
}
if err = s.prompter.Run(); err != nil {
s.G().Log.Debug("| Prompter failed\n")
return
}
f := s.fields.passphraseRetry
if f.Disabled || libkb.IsYes(f.GetValue()) {
var res keybase1.GetPassphraseRes
res, err = PromptPassphrase(s.G())
if err != nil {
return
}
s.passphrase = res.Passphrase
s.storeSecret = res.StoreSecret
}
return
}
示例3: checkRegistered
func (s *CmdSignup) checkRegistered() (err error) {
s.G().Log.Debug("+ clientModeSignupEngine::CheckRegistered")
defer s.G().Log.Debug("- clientModeSignupEngine::CheckRegistered -> %s", libkb.ErrToOk(err))
var rres keybase1.GetCurrentStatusRes
if rres, err = s.ccli.GetCurrentStatus(context.TODO(), 0); err != nil {
return err
}
if !rres.Registered {
return
}
if !s.doPrompt {
return nil
}
prompt := "Already registered; do you want to reregister?"
if rereg, err := s.G().UI.GetTerminalUI().PromptYesNo(PromptDescriptorReregister, prompt, libkb.PromptDefaultNo); err != nil {
return err
} else if !rereg {
return NotConfirmedError{}
}
return nil
}
示例4: storeRemoteUntrack
func (e *UntrackEngine) storeRemoteUntrack(them *libkb.User, ctx *Context) (err error) {
e.G().Log.Debug("+ StoreRemoteUntrack")
defer e.G().Log.Debug("- StoreRemoteUntrack -> %s", libkb.ErrToOk(err))
arg := libkb.SecretKeyArg{
Me: e.arg.Me,
KeyType: libkb.DeviceSigningKeyType,
}
var signingKeyPriv libkb.GenericKey
if signingKeyPriv, err = e.G().Keyrings.GetSecretKeyWithPrompt(ctx.LoginContext, arg, ctx.SecretUI, "untracking signature"); err != nil {
return
}
var sig string
var sigid keybase1.SigID
if sig, sigid, err = signingKeyPriv.SignToString(e.untrackStatementBytes); err != nil {
return
}
_, err = e.G().API.Post(libkb.APIArg{
Endpoint: "follow",
NeedSession: true,
Args: libkb.HTTPArgs{
"sig_id_base": libkb.S{Val: sigid.ToString(false)},
"sig_id_short": libkb.S{Val: sigid.ToShortID()},
"sig": libkb.S{Val: sig},
"uid": libkb.UIDArg(them.GetUID()),
"type": libkb.S{Val: "untrack"},
"signing_kid": e.signingKeyPub.GetKID(),
},
})
return
}
示例5: Run
// Run starts the engine.
func (e *XLogin) Run(ctx *Context) (err error) {
e.G().Log.Debug("+ XLogin.Run()")
defer func() { e.G().Log.Debug("- XLogin.Run() -> %s", libkb.ErrToOk(err)) }()
// first see if this device is already provisioned and it is possible to log in:
eng := NewXLoginCurrentDevice(e.G(), e.username)
err = RunEngine(eng, ctx)
if err == nil {
// login successful
e.G().Log.Debug("XLoginCurrentDevice.Run() was successful")
return err
}
// if this device has been provisioned already and there was an error, then
// return that error. Otherwise, ignore it and keep going.
if !e.notProvisionedErr(err) {
return err
}
e.G().Log.Debug("XLoginProvisioned error: %s (continuing with device provisioning...)", err)
// this device needs to be provisioned:
deng := NewXLoginProvision(e.G(), e.deviceType)
err = RunEngine(deng, ctx)
return err
}
示例6: GetHelloArg
// GetHelloArg implements GetHelloArg in kex2.Provisioner.
func (e *Kex2Provisioner) GetHelloArg() (arg keybase1.HelloArg, err error) {
e.G().Log.Debug("+ GetHelloArg()")
defer func() { e.G().Log.Debug("- GetHelloArg() -> %s", libkb.ErrToOk(err)) }()
e.ctx.ProvisionUI.DisplaySecretExchanged(context.TODO(), 0)
// get a session token that device Y can use
token, csrf, err := e.sessionForY()
if err != nil {
return arg, err
}
// generate a skeleton key proof
sigBody, err := e.skeletonProof()
if err != nil {
return arg, err
}
// return the HelloArg
arg = keybase1.HelloArg{
Uid: e.me.GetUID(),
Pps: e.pps.Export(),
Token: keybase1.SessionToken(token),
Csrf: keybase1.CsrfToken(csrf),
SigBody: sigBody,
}
return arg, nil
}
示例7: CounterSign
// CounterSign implements CounterSign in kex2.Provisioner.
func (e *Kex2Provisioner) CounterSign(input keybase1.HelloRes) (sig []byte, err error) {
e.G().Log.Debug("+ CounterSign()")
defer func() { e.G().Log.Debug("- CounterSign() -> %s", libkb.ErrToOk(err)) }()
jw, err := jsonw.Unmarshal([]byte(input))
if err != nil {
return nil, err
}
// check the reverse signature
if err = e.checkReverseSig(jw); err != nil {
e.G().Log.Debug("provisioner failed to verify reverse sig: %s", err)
return nil, err
}
e.G().Log.Debug("provisioner verified reverse sig")
// remember some device information for ProvisionUI.ProvisionerSuccess()
if err = e.rememberDeviceInfo(jw); err != nil {
return nil, err
}
// sign the whole thing with provisioner's signing key
s, _, _, err := libkb.SignJSON(jw, e.signingKey)
if err != nil {
return nil, err
}
return []byte(s), nil
}
示例8: Run
// Run the engine
func (c *PassphraseChange) Run(ctx *Context) (err error) {
c.G().Log.Debug("+ PassphraseChange.Run")
defer func() {
c.G().Log.Debug("- PassphraseChange.Run -> %s", libkb.ErrToOk(err))
}()
if len(c.arg.Passphrase) < libkb.MinPassphraseLength {
return libkb.PassphraseError{Msg: "too short"}
}
if err = c.loadMe(); err != nil {
return
}
c.G().LoginState().RunSecretSyncer(c.me.GetUID())
if c.arg.Force {
err = c.runForcedUpdate(ctx)
} else {
err = c.runStandardUpdate(ctx)
}
if err == nil {
c.G().LoginState().RunSecretSyncer(c.me.GetUID())
}
return
}
示例9: Run
func (s *CmdTestFSNotify) Run() (err error) {
s.G().Log.Debug("+ CmdTestFSNotify.Run")
defer func() { s.G().Log.Debug("- CmdTestFSNotify.Run -> %s", libkb.ErrToOk(err)) }()
cli, err := GetKBFSClient(s.G())
if err != nil {
return err
}
arg := keybase1.FSNotification{
PublicTopLevelFolder: s.publicTLF,
Filename: s.filename,
NotificationType: s.action,
StatusCode: keybase1.FSStatusCode_START,
}
s.G().Log.Debug("sending start event")
err = cli.FSEvent(context.TODO(), arg)
if err != nil {
return err
}
s.G().Log.Debug("sleeping for %s", s.delay)
time.Sleep(s.delay)
arg.StatusCode = keybase1.FSStatusCode_FINISH
s.G().Log.Debug("sending finish event")
err = cli.FSEvent(context.TODO(), arg)
if err != nil {
return err
}
s.G().Log.Debug("done with event")
return err
}
示例10: checkExists2
func (p *Prove) checkExists2(ctx *Context) (err error) {
p.G().Log.Debug("+ CheckExists2")
defer func() { p.G().Log.Debug("- CheckExists2 -> %s", libkb.ErrToOk(err)) }()
if !p.st.LastWriterWins() {
var found libkb.RemoteProofChainLink
for _, proof := range p.me.IDTable().GetActiveProofsFor(p.st) {
_, name := proof.ToKeyValuePair()
if libkb.Cicmp(name, p.usernameNormalized) {
found = proof
break
}
}
if found != nil {
var redo bool
redo, err = ctx.ProveUI.PromptOverwrite(context.TODO(), keybase1.PromptOverwriteArg{
Account: found.ToDisplayString(),
Typ: keybase1.PromptOverwriteType_SITE,
})
if err != nil {
return
}
if !redo {
err = libkb.NotConfirmedError{}
return
}
p.supersede = true
}
}
return
}
示例11: Run
// Run starts the engine.
func (e *Kex2Provisionee) Run(ctx *Context) error {
e.G().Log.Debug("+ Kex2Provisionee.Run()")
// check device struct:
if len(e.device.Type) == 0 {
return errors.New("provisionee device requires Type to be set")
}
if e.device.ID.IsNil() {
return errors.New("provisionee device requires ID to be set")
}
// ctx is needed in some of the kex2 functions:
e.ctx = ctx
karg := kex2.KexBaseArg{
Ctx: context.TODO(),
Mr: libkb.NewKexRouter(e.G()),
DeviceID: e.device.ID,
Secret: e.secret,
SecretChannel: e.secretCh,
Timeout: 5 * time.Minute,
}
parg := kex2.ProvisioneeArg{
KexBaseArg: karg,
Provisionee: e,
}
err := kex2.RunProvisionee(parg)
e.G().Log.Debug("- Kex2Provisionee.Run() -> %s", libkb.ErrToOk(err))
return err
}
示例12: generate
func (e *PGPKeyImportEngine) generate(ctx *Context) (err error) {
e.G().Log.Debug("+ PGP::Generate")
defer func() {
e.G().Log.Debug("- PGP::Generate -> %s", libkb.ErrToOk(err))
}()
e.G().Log.Debug("| GenerateKey")
if e.arg.Pregen != nil {
e.bundle = e.arg.Pregen
} else if e.arg.Gen == nil {
err = libkb.InternalError{Msg: "PGPKeyImportEngine: need either Gen or Pregen"}
return
} else if err = e.generateKey(ctx); err != nil {
return
}
e.G().Log.Debug("| WriteKey (hasSecret = %v)", e.bundle.HasSecretKey())
if !e.arg.NoSave && e.bundle.HasSecretKey() {
if err = e.saveLKS(ctx); err != nil {
return
}
}
if e.arg.PushSecret {
if err = e.prepareSecretPush(ctx); err != nil {
return
}
}
return
}
示例13: Run
// Run starts the engine.
func (e *DeviceAdd) Run(ctx *Context) (err error) {
e.G().Log.Debug("+ DeviceAdd.Run()")
defer func() { e.G().Log.Debug("- DeviceAdd.Run() -> %s", libkb.ErrToOk(err)) }()
provisioneeType, err := ctx.ProvisionUI.ChooseDeviceType(context.TODO(), 0)
if err != nil {
return err
}
e.G().Log.Debug("provisionee device type: %v", provisioneeType)
// make a new secret:
secret, err := libkb.NewKex2Secret()
if err != nil {
return err
}
e.G().Log.Debug("secret phrase: %s", secret.Phrase())
// create provisioner engine
provisioner := NewKex2Provisioner(e.G(), secret.Secret())
var canceler func()
// display secret and prompt for secret from X in a goroutine:
go func() {
sb := secret.Secret()
arg := keybase1.DisplayAndPromptSecretArg{
Secret: sb[:],
Phrase: secret.Phrase(),
OtherDeviceType: provisioneeType,
}
var contxt context.Context
contxt, canceler = context.WithCancel(context.Background())
receivedSecret, err := ctx.ProvisionUI.DisplayAndPromptSecret(contxt, arg)
if err != nil {
// XXX ???
e.G().Log.Warning("DisplayAndPromptSecret error: %s", err)
} else if receivedSecret != nil {
e.G().Log.Debug("received secret, adding to provisioner")
var ks kex2.Secret
copy(ks[:], receivedSecret)
provisioner.AddSecret(ks)
}
}()
defer func() {
if canceler != nil {
e.G().Log.Debug("canceling DisplayAndPromptSecret call")
canceler()
}
}()
// run provisioner
if err = RunEngine(provisioner, ctx); err != nil {
return err
}
return nil
}
示例14: CheckRegistered
func (s *SignupJoinEngine) CheckRegistered() (err error) {
s.G().Log.Debug("+ libkb.SignupJoinEngine::CheckRegistered")
if cr := s.G().Env.GetConfig(); cr == nil {
err = fmt.Errorf("No configuration file available")
} else if u := cr.GetUID(); u.Exists() {
err = libkb.AlreadyRegisteredError{UID: u}
}
s.G().Log.Debug("- libkb.SignupJoinEngine::CheckRegistered -> %s", libkb.ErrToOk(err))
return err
}
示例15: runStandardUpdate
// runStandardUpdate is for when the user knows the current
// password.
func (c *PassphraseChange) runStandardUpdate(ctx *Context) (err error) {
c.G().Log.Debug("+ PassphraseChange.runStandardUpdate")
defer func() {
c.G().Log.Debug("- PassphraseChange.runStandardUpdate -> %s", libkb.ErrToOk(err))
}()
if len(c.arg.OldPassphrase) == 0 {
err = c.getVerifiedPassphraseHash(ctx)
} else {
err = c.verifySuppliedPassphrase(ctx)
}
if err != nil {
return err
}
pgpKeys, err := c.findAndDecryptPrivatePGPKeys(ctx)
if err != nil {
return err
}
var acctErr error
c.G().LoginState().Account(func(a *libkb.Account) {
gen := a.PassphraseStreamCache().PassphraseStream().Generation()
oldPWH := a.PassphraseStreamCache().PassphraseStream().PWHash()
oldClientHalf := a.PassphraseStreamCache().PassphraseStream().LksClientHalf()
payload, err := c.commonArgs(a, oldClientHalf, pgpKeys, gen)
if err != nil {
acctErr = err
return
}
payload["oldpwh"] = libkb.HexArg(oldPWH).String()
payload["ppgen"] = gen
postArg := libkb.APIArg{
Endpoint: "passphrase/replace",
NeedSession: true,
JSONPayload: payload,
SessionR: a.LocalSession(),
}
_, err = c.G().API.PostJSON(postArg)
if err != nil {
acctErr = err
return
}
}, "PassphraseChange.runStandardUpdate")
if acctErr != nil {
err = acctErr
return err
}
return nil
}