auth

package
v0.0.0-...-cbb00c2 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2024 License: MIT Imports: 19 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateAuthData

func GenerateAuthData(ct, uuid string, kp KeyParams) string

Types

type AuthParamsOutput

type AuthParamsOutput struct {
	Identifier    string `json:"identifier"`
	PasswordSalt  string `json:"pw_salt"`
	PasswordCost  int64  `json:"pw_cost"`
	PasswordNonce string `json:"pw_nonce"`
	Version       string `json:"version"`
	TokenName     string
	Verifier      generateLoginChallengeCodeVerifier
}

type ErrorResponse

type ErrorResponse struct {
	Meta signInResponseMeta `json:"meta"`
	Data ErrorResponseData  `json:"data"`
}

type ErrorResponseData

type ErrorResponseData struct {
	Error struct {
		Tag     string `json:"tag"`
		Message string `json:"message"`
		Payload struct {
			MFAKey string `json:"mfa_key"`
		}
	}
}

type KeyParams

type KeyParams struct {
	Created     string `json:"created"`
	Identifier  string `json:"identifier"`
	Origination string `json:"origination"`
	PwNonce     string `json:"pw_nonce"`
	Version     string `json:"version"`
}

type RefreshSessionInput

type RefreshSessionInput struct {
	Email        string
	AccessToken  string
	RefreshToken string
	APIServer    string
	Debug        bool
}

type RefreshSessionOutput

type RefreshSessionOutput struct {
	Session   SignInResponseDataSession
	KeyParams KeyParams
	User      User
	TokenName string
}

type RefreshSessionResponse

type RefreshSessionResponse struct {
	Meta struct {
		Auth   interface{} `json:"auth"`
		Server struct {
			FilesServerURL string `json:"filesServerUrl"`
		} `json:"server"`
	} `json:"meta"`
	Data struct {
		Session struct {
			AccessToken       string `json:"access_token"`
			RefreshToken      string `json:"refresh_token"`
			AccessExpiration  int64  `json:"access_expiration"`
			RefreshExpiration int64  `json:"refresh_expiration"`
			ReadOnlyAccess    int    `json:"readonly_access"`
		} `json:"session"`
	} `json:"data"`
}

func RequestRefreshToken

func RequestRefreshToken(client *retryablehttp.Client, url, accessToken, refreshToken string, debug bool) (output RefreshSessionResponse, err error)

type RegisterInput

type RegisterInput struct {
	Client      *retryablehttp.Client
	Password    string
	Email       string
	PWNonce     string
	Version     string
	Origination string
	Created     int64
	APIServer   string
	Debug       bool
}

func (RegisterInput) Register

func (input RegisterInput) Register() (token string, err error)

Register creates a new user token Params: email, password, pw_cost, pw_nonce, version.

type RequestRefreshTokenOutput

type RequestRefreshTokenOutput struct {
	AccessToken       string `json:"access_token"`
	RefreshToken      string `json:"refresh_token"`
	AccessExpiration  int64  `json:"access_expiration"`
	RefreshExpiration int64  `json:"refresh_expiration"`
	ReadOnlyAccess    int    `json:"read_only_access"`
}

type SignInInput

type SignInInput struct {
	HTTPClient *retryablehttp.Client
	Email      string
	TokenName  string
	TokenVal   string
	Password   string
	APIServer  string
	Debug      bool
}

type SignInOutput

type SignInOutput struct {
	Session   SignInResponseDataSession
	KeyParams KeyParams
	User      User
	TokenName string
}

func SignIn

func SignIn(input SignInInput) (output SignInOutput, err error)

SignIn authenticates with the server using credentials and optional MFA in order to obtain the data required to interact with Standard Notes.

type SignInResponseDataSession

type SignInResponseDataSession struct {
	Debug            bool
	HTTPClient       *retryablehttp.Client
	SchemaValidation bool
	Server           string
	FilesServerUrl   string `json:"filesServerUrl"`
	Token            string
	MasterKey        string
	// ImporterItemsKeys is the key used to encrypt exported items and set during import only
	KeyParams         KeyParams `json:"keyParams"`
	AccessToken       string    `json:"access_token"`
	RefreshToken      string    `json:"refresh_token"`
	AccessExpiration  int64     `json:"access_expiration"`
	RefreshExpiration int64     `json:"refresh_expiration"`
	ReadOnlyAccess    bool      `json:"readonly_access"`
	PasswordNonce     string
}

func CliSignIn

func CliSignIn(email, password, server string, debug bool) (session SignInResponseDataSession, err error)

CliSignIn takes the server URL and credentials and sends them to the API to get a response including an authentication token plus the keys required to encrypt and decrypt SN items.

type User

type User struct {
	UUID            string `json:"uuid"`
	Email           string `json:"email"`
	ProtocolVersion string `json:"protocolVersion"`
}

Jump to

Keyboard shortcuts

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