github.com/keybase/client/go@v0.0.0-20240309051027-028f7c731f8b/libkb/login_state.go (about)

     1  // Copyright 2015 Keybase, Inc. All rights reserved. Use of
     2  // this source code is governed by the included BSD license.
     3  
     4  package libkb
     5  
     6  import (
     7  	keybase1 "github.com/keybase/client/go/protocol/keybase1"
     8  )
     9  
    10  // PassphraseGeneration represents which generation of the passphrase is
    11  // currently in use.  It's used to guard against race conditions in which
    12  // the passphrase is changed on one device which the other still has it cached.
    13  type PassphraseGeneration int
    14  
    15  // IsNil returns true if this PassphraseGeneration isn't initialized.
    16  func (p PassphraseGeneration) IsNil() bool { return p == PassphraseGeneration(0) }
    17  
    18  // LoginContext is passed to all loginHandler functions.  It
    19  // allows them safe access to various parts of the LoginState during
    20  // the login process.
    21  type LoginContext interface {
    22  	LoggedInLoad() (bool, error)
    23  	Salt() []byte
    24  	CreateStreamCache(tsec Triplesec, pps *PassphraseStream)
    25  	SetStreamCache(c *PassphraseStreamCache)
    26  	PassphraseStreamCache() *PassphraseStreamCache
    27  
    28  	CreateLoginSessionWithSalt(emailOrUsername string, salt []byte) error
    29  	LoginSession() *LoginSession
    30  	SetLoginSession(l *LoginSession)
    31  
    32  	LocalSession() *Session
    33  	GetUID() keybase1.UID
    34  	GetUsername() NormalizedUsername
    35  	GetUserVersion() keybase1.UserVersion
    36  	SaveState(sessionID, csrf string, username NormalizedUsername, uv keybase1.UserVersion, deviceID keybase1.DeviceID) error
    37  	SetUsernameUserVersion(username NormalizedUsername, uv keybase1.UserVersion) error
    38  
    39  	Keyring(m MetaContext) (*SKBKeyringFile, error)
    40  	ClearKeyring()
    41  	SecretSyncer() *SecretSyncer
    42  	RunSecretSyncer(m MetaContext, uid keybase1.UID) error
    43  	Dump(m MetaContext, prefix string)
    44  }
    45  
    46  type loginAPIResult struct {
    47  	sessionID string
    48  	csrfToken string
    49  	uv        keybase1.UserVersion
    50  	username  string
    51  	ppGen     PassphraseGeneration
    52  }