wizard

package
v0.0.0-...-85f1224 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2026 License: AGPL-3.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const ED25519_CODEC_ID = 0xed

Ed25519 multicodec identifier

View Source
const TerminusDefaultDomain = "olares.cn"

Variables

This section is empty.

Functions

func GenerateMnemonic

func GenerateMnemonic() string

GenerateMnemonic generates new BIP39 mnemonic

func GetDID

func GetDID(mnemonic string) (string, error)

GetDID convenience function: generate DID from mnemonic

func GetPublicJWK

func GetPublicJWK(mnemonic string) (*jwk.JWK, error)

GetPublicJWK convenience function: generate public JWK from mnemonic

func InitializeGlobalStores

func InitializeGlobalStores(mnemonic, terminusName string) error

InitializeGlobalStores initializes global storage

func ResetPassword

func ResetPassword(baseURL, localName, currentPassword, newPassword, accessToken string) error

ResetPassword implements password reset functionality (ref: account.ts reset_password)

func RunActivationWizard

func RunActivationWizard(baseURL, accessToken string, config WizardConfig) error

RunActivationWizard convenient function to run activation wizard

func SetPlatform

func SetPlatform(p Platform)

func UserBindTerminus

func UserBindTerminus(mnemonic, bflUrl, vaultUrl, osPwd, terminusName, localName string) (string, error)

UserBindTerminus main user binding function (ref: TypeScript version)

Types

type Account

type Account struct {
	ID               string           `json:"id"`
	DID              string           `json:"did"`
	Name             string           `json:"name"`
	Local            bool             `json:"local,omitempty"`
	Created          string           `json:"created,omitempty"`          // ISO 8601 format
	Updated          string           `json:"updated,omitempty"`          // ISO 8601 format
	PublicKey        string           `json:"publicKey,omitempty"`        // Base64 encoded RSA public key
	EncryptedData    string           `json:"encryptedData,omitempty"`    // Base64 encoded encrypted data
	EncryptionParams EncryptionParams `json:"encryptionParams,omitempty"` // AES encryption parameters
	KeyParams        KeyParams        `json:"keyParams,omitempty"`        // PBKDF2 key derivation parameters
	MainVault        MainVault        `json:"mainVault"`                  // Main vault information
	Orgs             []OrgInfo        `json:"orgs"`                       // Organization list (important: prevent undefined)
	Revision         string           `json:"revision,omitempty"`         // Version control
	Kid              string           `json:"kid,omitempty"`              // Key ID
	Settings         AccountSettings  `json:"settings,omitempty"`         // Account settings
	Version          string           `json:"version,omitempty"`          // Version
}

type AccountProvisioning

type AccountProvisioning struct {
	ID            string         `json:"id"`
	DID           string         `json:"did"`
	Name          *string        `json:"name,omitempty"`
	AccountID     *string        `json:"accountId,omitempty"`
	Status        string         `json:"status"`
	StatusLabel   string         `json:"statusLabel"`
	StatusMessage string         `json:"statusMessage"`
	ActionURL     *string        `json:"actionUrl,omitempty"`
	ActionLabel   *string        `json:"actionLabel,omitempty"`
	MetaData      map[string]any `json:"metaData,omitempty"`
	SkipTos       bool           `json:"skipTos"`
	BillingPage   any            `json:"billingPage,omitempty"`
	Quota         map[string]any `json:"quota"`
	Features      map[string]any `json:"features"`
	Orgs          []string       `json:"orgs"`
}

AccountProvisioning represents account provisioning information

type AccountSettings

type AccountSettings struct {
}

AccountSettings represents account settings

type AccountStatus

type AccountStatus string
const (
	AccountStatusUnregistered AccountStatus = "unregistered"
	AccountStatusActive       AccountStatus = "active"
	AccountStatusBlocked      AccountStatus = "blocked"
	AccountStatusDeleted      AccountStatus = "deleted"
)

type ActivationWizard

type ActivationWizard struct {
	BaseURL      string
	Config       WizardConfig
	AccessToken  string
	MaxRetries   int
	PollInterval time.Duration
}

ActivationWizard activation wizard

func NewActivationWizard

func NewActivationWizard(baseURL, accessToken string, config WizardConfig) *ActivationWizard

NewActivationWizard creates a new activation wizard

func (*ActivationWizard) RunWizard

func (w *ActivationWizard) RunWizard() error

RunWizard runs the complete activation wizard process (ref: ActivateWizard.vue updateInfo)

type ActiveAccountParams

type ActiveAccountParams struct {
	ID       string `json:"id"`
	BFLToken string `json:"bflToken"`
	BFLUser  string `json:"bflUser"`
	JWS      string `json:"jws"`
}

type App

type App struct {
	Version string  `json:"version"`
	API     *Client `json:"-"` // Uses Client from client.go
}

App class - simplified version for backend CLI use

func NewApp

func NewApp(sender Sender) *App

NewApp constructor - initializes with Client (corresponds to original TypeScript constructor)

func NewAppWithBaseURL

func NewAppWithBaseURL(baseURL string) *App

NewAppWithBaseURL creates App with base URL (convenience function)

func (*App) Login

func (a *App) Login(params LoginParams) error

Login function - simplified version

func (*App) Signup

func (a *App) Signup(params SignupParams) (*CreateAccountResponse, error)

Signup function - based on original TypeScript signup method (ref: app.ts)

type AppAPI

type AppAPI interface {
	StartAuthRequest(params StartAuthRequestParams) (*StartAuthRequestResponse, error)
	CompleteAuthRequest(params CompleteAuthRequestParams) (*CompleteAuthRequestResponse, error)
}

AppAPI interface for app-level operations

type Auth

type Auth struct {
	ID        string       `json:"id"`
	DID       string       `json:"did"`
	Verifier  []byte       `json:"verifier"`
	KeyParams PBKDF2Params `json:"keyParams"`
}

func NewAuth

func NewAuth(did string) *Auth

Auth methods

func (*Auth) GetAuthKey

func (a *Auth) GetAuthKey(password string) ([]byte, error)

GetAuthKey generates authentication key (ref: auth.ts line 278-284)

type AuthClient

type AuthClient interface {
	PrepareAuthentication(params map[string]any) (map[string]any, error)
}

AuthClient interface for authentication clients

type AuthError

type AuthError struct {
	Code    ErrorCode `json:"code"`
	Message string    `json:"message"`
	Data    any       `json:"data,omitempty"`
}

AuthError represents authentication errors

func NewAuthError

func NewAuthError(code ErrorCode, message string, data any) *AuthError

func (*AuthError) Error

func (e *AuthError) Error() string

type AuthPurpose

type AuthPurpose string
const (
	AuthPurposeSignup            AuthPurpose = "signup"
	AuthPurposeLogin             AuthPurpose = "login"
	AuthPurposeRecover           AuthPurpose = "recover"
	AuthPurposeAccessKeyStore    AuthPurpose = "access_key_store"
	AuthPurposeTestAuthenticator AuthPurpose = "test_authenticator"
	AuthPurposeAdminLogin        AuthPurpose = "admin_login"
)

type AuthRequestStatus

type AuthRequestStatus string
const (
	AuthRequestStatusStarted  AuthRequestStatus = "started"
	AuthRequestStatusVerified AuthRequestStatus = "verified"
	AuthRequestStatusExpired  AuthRequestStatus = "expired"
)

type AuthType

type AuthType string

============================================================================ Type Definitions and Enums ============================================================================

const (
	AuthTypeSSI AuthType = "ssi"
)

type AuthenticateRequest

type AuthenticateRequest struct {
	DID                string                    `json:"did"`
	Type               AuthType                  `json:"type"`
	Purpose            AuthPurpose               `json:"purpose"`
	AuthenticatorIndex int                       `json:"authenticatorIndex"`
	PendingRequest     *StartAuthRequestResponse `json:"pendingRequest,omitempty"`
	Caller             string                    `json:"caller"`
}

type AuthenticateResponse

type AuthenticateResponse struct {
	DID           string              `json:"did"`
	Token         string              `json:"token"`
	AccountStatus AccountStatus       `json:"accountStatus"`
	Provisioning  AccountProvisioning `json:"provisioning"`
	DeviceTrusted bool                `json:"deviceTrusted"`
}

func Authenticate

func Authenticate(req AuthenticateRequest) (*AuthenticateResponse, error)

Main authentication function - corresponds to original TypeScript _authenticate function

type Base64Bytes

type Base64Bytes []byte

Base64Bytes automatically handles base64 encoding/decoding for byte arrays

func (Base64Bytes) Bytes

func (b Base64Bytes) Bytes() []byte

Bytes returns the underlying byte array

func (Base64Bytes) MarshalJSON

func (b Base64Bytes) MarshalJSON() ([]byte, error)

MarshalJSON implements JSON serialization, automatically encoding to base64 string

func (*Base64Bytes) UnmarshalJSON

func (b *Base64Bytes) UnmarshalJSON(data []byte) error

UnmarshalJSON implements JSON deserialization, automatically decoding from base64 string

type Client

type Client struct {
	State  ClientState
	Sender Sender
}

Client implementation - based on original TypeScript Client class

func NewClient

func NewClient(state ClientState, sender Sender) *Client

func (*Client) ActiveAccount

func (c *Client) ActiveAccount(params ActiveAccountParams) error

func (*Client) CompleteAuthRequest

func (c *Client) CompleteAuthRequest(params CompleteAuthRequestParams) (*CompleteAuthRequestResponse, error)

func (*Client) CompleteCreateSession

func (c *Client) CompleteCreateSession(params CompleteCreateSessionParams) (*Session, error)

func (*Client) CreateAccount

func (c *Client) CreateAccount(params CreateAccountParams) (*CreateAccountResponse, error)

Extend Client interface to support App-required methods

func (*Client) GetAccount

func (c *Client) GetAccount() (*Account, error)

func (*Client) StartAuthRequest

func (c *Client) StartAuthRequest(params StartAuthRequestParams) (*StartAuthRequestResponse, error)

Implement AppAPI interface

func (*Client) StartCreateSession

func (c *Client) StartCreateSession(params StartCreateSessionParams) (*StartCreateSessionResponse, error)

func (*Client) UpdateVault

func (c *Client) UpdateVault(vault Vault) (*Vault, error)

type ClientState

type ClientState interface {
	GetSession() *Session
	SetSession(session *Session)
	GetAccount() *Account
	SetAccount(account *Account)
	GetDevice() *DeviceInfo
}

ClientState interface for managing client session state

type CompleteAuthRequestParams

type CompleteAuthRequestParams struct {
	ID   string         `json:"id"`
	Data map[string]any `json:"data"`
	DID  string         `json:"did"`
}

type CompleteAuthRequestResponse

type CompleteAuthRequestResponse struct {
	AccountStatus AccountStatus       `json:"accountStatus"`
	DeviceTrusted bool                `json:"deviceTrusted"`
	Provisioning  AccountProvisioning `json:"provisioning"`
}

type CompleteCreateSessionParams

type CompleteCreateSessionParams struct {
	SRPId            string      `json:"srpId"`
	AccountID        string      `json:"accountId"`
	A                Base64Bytes `json:"A"`                // Use Base64Bytes to handle @AsBytes() decorator
	M                Base64Bytes `json:"M"`                // Use Base64Bytes to handle @AsBytes() decorator
	AddTrustedDevice bool        `json:"addTrustedDevice"` // Add missing field
	Kind             string      `json:"kind"`             // Add kind field
	Version          string      `json:"version"`          // Add version field
}

type CreateAccountParams

type CreateAccountParams struct {
	Account   Account `json:"account"`
	Auth      Auth    `json:"auth"`
	AuthToken string  `json:"authToken"`
	BFLToken  string  `json:"bflToken"`
	SessionID string  `json:"sessionId"`
	BFLUser   string  `json:"bflUser"`
	JWS       string  `json:"jws"`
}

New data structures

type CreateAccountResponse

type CreateAccountResponse struct {
	MFA string `json:"mfa"`
}

type CreateVaultItemParams

type CreateVaultItemParams struct {
	Name   string
	Vault  *Vault
	Fields []Field
	Tags   []string
	Icon   string
	Type   VaultType
}

CreateVaultItemParams parameters for creating a vault item

type DIDKeyResult

type DIDKeyResult struct {
	DID        string  `json:"did"`
	PublicJWK  jwk.JWK `json:"publicJwk"`
	PrivateJWK jwk.JWK `json:"privateJwk"`
}

DIDKeyResult represents the result of DID key generation

func GetPrivateJWK

func GetPrivateJWK(mnemonic string) (*DIDKeyResult, error)

GetPrivateJWK convenience function: generate private JWK from mnemonic

type DeviceInfo

type DeviceInfo struct {
	ID       string `json:"id"`
	Platform string `json:"platform"`
}

type EncryptionParams

type EncryptionParams struct {
	Algorithm      string `json:"algorithm"`      // "AES-GCM"
	TagSize        int    `json:"tagSize"`        // 128
	KeySize        int    `json:"keySize"`        // 256
	IV             string `json:"iv"`             // Base64 encoded initialization vector
	AdditionalData string `json:"additionalData"` // Base64 encoded additional data
	Version        string `json:"version"`        // "3.0.14"
}

EncryptionParams represents AES encryption parameters

type ErrorCode

type ErrorCode string
const (
	ErrorCodeAuthenticationFailed ErrorCode = "email_verification_failed"
	ErrorCodeNotFound             ErrorCode = "not_found"
	ErrorCodeServerError          ErrorCode = "server_error"
)

type ErrorInfo

type ErrorInfo struct {
	Code    string `json:"code"`
	Message string `json:"message"`
}

type FRPConfig

type FRPConfig struct {
	Host string `json:"host"`
	Jws  string `json:"jws"`
}

type Field

type Field struct {
	Name  string    `json:"name"`
	Type  FieldType `json:"type"`
	Value string    `json:"value"`
}

Field represents a field in a vault item

type FieldType

type FieldType string

FieldType represents the type of field in a vault item

const (
	FieldTypeUsername  FieldType = "username"
	FieldTypePassword  FieldType = "password"
	FieldTypeApiSecret FieldType = "apiSecret"
	FieldTypeMnemonic  FieldType = "mnemonic"
	FieldTypeUrl       FieldType = "url"
	FieldTypeEmail     FieldType = "email"
	FieldTypeDate      FieldType = "date"
	FieldTypeMonth     FieldType = "month"
	FieldTypeCredit    FieldType = "credit"
	FieldTypePhone     FieldType = "phone"
	FieldTypePin       FieldType = "pin"
	FieldTypeTotp      FieldType = "totp"
	FieldTypeNote      FieldType = "note"
	FieldTypeText      FieldType = "text"
)

type FirstFactorRequest

type FirstFactorRequest struct {
	Username       string `json:"username"`
	Password       string `json:"password"`
	KeepMeLoggedIn bool   `json:"keepMeLoggedIn"`
	RequestMethod  string `json:"requestMethod"`
	TargetURL      string `json:"targetURL"`
	AcceptCookie   bool   `json:"acceptCookie"`
}

FirstFactorRequest represents first factor request structure

type FirstFactorResponse

type FirstFactorResponse struct {
	Status string `json:"status"`
	Data   Token  `json:"data"`
}

FirstFactorResponse represents first factor response structure

type HDNode

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

HDNode represents BIP32 hierarchical deterministic node

type HDWalletGo

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

HDWalletGo is a pure Go HD wallet based on Trust Wallet Core implementation

func NewHDWalletFromMnemonic

func NewHDWalletFromMnemonic(mnemonic, passphrase string) (*HDWalletGo, error)

NewHDWalletFromMnemonic creates HD wallet from mnemonic (simulates Trust Wallet Core implementation)

func (*HDWalletGo) GetMasterKeyEd25519

func (w *HDWalletGo) GetMasterKeyEd25519() (ed25519.PrivateKey, ed25519.PublicKey, error)

GetMasterKeyEd25519 gets Ed25519 master key (simulates Trust Wallet Core's getMasterKey)

func (*HDWalletGo) GetPrivateJWKTrustWalletCore

func (w *HDWalletGo) GetPrivateJWKTrustWalletCore() (*DIDKeyResult, error)

GetPrivateJWKTrustWalletCore generates private JWK using Trust Wallet Core compatible method

type HTTPSender

type HTTPSender struct {
	BaseURL string
	Client  *http.Client
}

HTTPSender implements HTTP-based Sender interface

func NewHTTPSender

func NewHTTPSender(baseURL string) *HTTPSender

NewHTTPSender creates new HTTP Sender

func (*HTTPSender) Send

func (h *HTTPSender) Send(req *Request) (*Response, error)

Send implements Sender interface, sends HTTP request

type ISOTime

type ISOTime time.Time

ISOTime is a custom time type that ensures JSON serialization matches JavaScript toISOString() format

func (ISOTime) MarshalJSON

func (t ISOTime) MarshalJSON() ([]byte, error)

MarshalJSON implements JSON serialization using JavaScript toISOString() format

func (ISOTime) Unix

func (t ISOTime) Unix() int64

Unix returns Unix timestamp for compatibility

func (*ISOTime) UnmarshalJSON

func (t *ISOTime) UnmarshalJSON(data []byte) error

UnmarshalJSON implements JSON deserialization

type ItemTemplate

type ItemTemplate struct {
	ID     string  `json:"id"`
	Name   string  `json:"name"`
	Icon   string  `json:"icon"`
	Fields []Field `json:"fields"`
}

ItemTemplate represents a template for creating vault items

func GetAuthenticatorTemplate

func GetAuthenticatorTemplate() *ItemTemplate

GetAuthenticatorTemplate returns the authenticator template for TOTP items

type KeyParams

type KeyParams struct {
	Algorithm  string `json:"algorithm"`  // "PBKDF2"
	Hash       string `json:"hash"`       // "SHA-256"
	KeySize    int    `json:"keySize"`    // 256
	Iterations int    `json:"iterations"` // 100000
	Salt       string `json:"salt"`       // Base64 encoded salt
	Version    string `json:"version"`    // "3.0.14"
}

KeyParams represents PBKDF2 key derivation parameters

type LoginParams

type LoginParams struct {
	DID       string  `json:"did"`
	Password  string  `json:"password"`
	AuthToken *string `json:"authToken,omitempty"`
	AsAdmin   *bool   `json:"asAdmin,omitempty"`
}

type MainVault

type MainVault struct {
	ID       string `json:"id"`
	Name     string `json:"name,omitempty"`
	Revision string `json:"revision,omitempty"`
}

MainVault represents main vault information

type OrgInfo

type OrgInfo struct {
	ID       string `json:"id"`
	Name     string `json:"name,omitempty"`
	Revision string `json:"revision,omitempty"`
}

OrgInfo represents organization information

type PBKDF2Params

type PBKDF2Params struct {
	Algorithm  string      `json:"algorithm,omitempty"`
	Hash       string      `json:"hash,omitempty"`
	Salt       Base64Bytes `json:"salt"`
	Iterations int         `json:"iterations"`
	KeySize    int         `json:"keySize,omitempty"`
	Kind       string      `json:"kind,omitempty"`
	Version    string      `json:"version,omitempty"`
}

type PasswordConfig

type PasswordConfig struct {
	CurrentPassword string `json:"current_password"` // Current password (from wizard settings)
	NewPassword     string `json:"new_password"`     // New password (for reset)
}

PasswordConfig password configuration

type Platform

type Platform interface {
	StartAuthRequest(opts StartAuthRequestOptions) (*StartAuthRequestResponse, error)
	CompleteAuthRequest(req *StartAuthRequestResponse) (*AuthenticateResponse, error)
}

Platform interface for authentication operations

type Request

type Request struct {
	Method string        `json:"method"`
	Params []interface{} `json:"params,omitempty"`
	Device *DeviceInfo   `json:"device,omitempty"`
	Auth   *RequestAuth  `json:"auth,omitempty"`
}

Request represents an RPC request

type RequestAuth

type RequestAuth struct {
	Session   string      `json:"session"`
	Time      ISOTime     `json:"time"`      // Use custom ISOTime type
	Signature Base64Bytes `json:"signature"` // Use Base64Bytes to automatically handle base64 encoding
}

type Response

type Response struct {
	Result interface{} `json:"result,omitempty"`
	Error  *ErrorInfo  `json:"error,omitempty"`
}

type SRPClient

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

SRPClient represents SRP client

func NewSRPClient

func NewSRPClient(length SRPGroupLength) *SRPClient

func (*SRPClient) GetA

func (c *SRPClient) GetA() []byte

func (*SRPClient) GetK

func (c *SRPClient) GetK() []byte

func (*SRPClient) GetM1

func (c *SRPClient) GetM1() []byte

func (*SRPClient) GetM2

func (c *SRPClient) GetM2() []byte

func (*SRPClient) GetV

func (c *SRPClient) GetV() []byte

Getter methods

func (*SRPClient) Initialize

func (c *SRPClient) Initialize(x []byte) error

Initialize initializes SRP client

func (*SRPClient) SetB

func (c *SRPClient) SetB(B []byte) error

SetB sets server's B value

type SRPCore

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

SRPCore implements core SRP algorithms

func NewSRPCore

func NewSRPCore(length SRPGroupLength) *SRPCore

func (*SRPCore) A

func (c *SRPCore) A(a *big.Int) *big.Int

A calculates A = g^a % N

func (*SRPCore) B

func (c *SRPCore) B(v, b *big.Int) (*big.Int, error)

B calculates B = (k*v + g^b % N) % N

func (*SRPCore) ClientS

func (c *SRPCore) ClientS(B, x, a, u *big.Int) (*big.Int, error)

ClientS calculates S = (B - k*(g^x % N))^(a + u*x) % N

func (*SRPCore) H

func (c *SRPCore) H(inputs ...*big.Int) (*big.Int, error)

H hash function (...inp) - ref: TypeScript srp.ts line 384-386

func (*SRPCore) IsZeroWhenModN

func (c *SRPCore) IsZeroWhenModN(n *big.Int) bool

IsZeroWhenModN checks if value is zero mod N

func (*SRPCore) K

func (c *SRPCore) K(S *big.Int) (*big.Int, error)

K calculates shared key K = H(S)

func (*SRPCore) K_multiplier

func (c *SRPCore) K_multiplier() (*big.Int, error)

K_multiplier calculates multiplier k = H(N | g)

func (*SRPCore) M1

func (c *SRPCore) M1(A, B, K *big.Int) (*big.Int, error)

M1 calculates first verification value M1 = H(A | B | K)

func (*SRPCore) M2

func (c *SRPCore) M2(A, M1, K *big.Int) (*big.Int, error)

M2 calculates second verification value M2 = H(A | M1 | K)

func (*SRPCore) ServerS

func (c *SRPCore) ServerS(A, v, u, b *big.Int) *big.Int

ServerS calculates S = (A * v^u % N)^b % N

func (*SRPCore) U

func (c *SRPCore) U(A, B *big.Int) (*big.Int, error)

U calculates u = H(A | B)

func (*SRPCore) V

func (c *SRPCore) V(x *big.Int) *big.Int

V calculates verifier v = g^x % N

type SRPGroupLength

type SRPGroupLength int

SRPGroupLength represents SRP group length types

const (
	SRPGroup3072 SRPGroupLength = 3072
	SRPGroup4096 SRPGroupLength = 4096
	SRPGroup6144 SRPGroupLength = 6144
	SRPGroup8192 SRPGroupLength = 8192
)

type SRPParams

type SRPParams struct {
	Length SRPGroupLength
	Hash   string // "SHA-256"
	G      *big.Int
	N      *big.Int
}

SRPParams represents SRP parameters

type SRPServer

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

SRPServer represents SRP server

func NewSRPServer

func NewSRPServer(length SRPGroupLength) *SRPServer

func (*SRPServer) GetB

func (s *SRPServer) GetB() []byte

Getter methods

func (*SRPServer) GetK

func (s *SRPServer) GetK() []byte

func (*SRPServer) GetM1

func (s *SRPServer) GetM1() []byte

func (*SRPServer) GetM2

func (s *SRPServer) GetM2() []byte

func (*SRPServer) Initialize

func (s *SRPServer) Initialize(v []byte) error

Initialize initializes SRP server

func (*SRPServer) SetA

func (s *SRPServer) SetA(A []byte) error

SetA sets client's A value

type SRPSession

type SRPSession struct {
	ID             string    `json:"id"`
	Created        time.Time `json:"created"`
	FailedAttempts int       `json:"failedAttempts"`
	AsAdmin        bool      `json:"asAdmin"`
	X              *big.Int  `json:"x,omitempty"`
	V              *big.Int  `json:"v,omitempty"`
	A              *big.Int  `json:"a,omitempty"`
	BigA           *big.Int  `json:"A,omitempty"`
	B              *big.Int  `json:"b,omitempty"`
	BigB           *big.Int  `json:"B,omitempty"`
	K              *big.Int  `json:"K,omitempty"`
	M1             *big.Int  `json:"M1,omitempty"`
	M2             *big.Int  `json:"M2,omitempty"`
}

SRPSession represents SRP session state

func NewSRPSession

func NewSRPSession() *SRPSession

type SSIAuthClient

type SSIAuthClient struct {
	UserStore *UserStore // Direct use of UserStore struct

}

SSI authentication client implementation

func (*SSIAuthClient) PrepareAuthentication

func (p *SSIAuthClient) PrepareAuthentication(params map[string]any) (map[string]any, error)

PrepareAuthentication implements authentication functionality for SSI client

type Sender

type Sender interface {
	Send(req *Request) (*Response, error)
}

Sender interface for network transport

type Session

type Session struct {
	ID  string `json:"id"`
	Key []byte `json:"key,omitempty"`
}

Session represents a user session

type SignupParams

type SignupParams struct {
	DID            string `json:"did"`
	MasterPassword string `json:"masterPassword"`
	Name           string `json:"name"`
	AuthToken      string `json:"authToken"`
	SessionID      string `json:"sessionId"`
	BFLToken       string `json:"bflToken"`
	BFLUser        string `json:"bflUser"`
	JWS            string `json:"jws"`
}

Parameter structures

type SimpleClientState

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

SimpleClientState - simplified client state for backend CLI

func (*SimpleClientState) GetAccount

func (s *SimpleClientState) GetAccount() *Account

func (*SimpleClientState) GetDevice

func (s *SimpleClientState) GetDevice() *DeviceInfo

func (*SimpleClientState) GetSession

func (s *SimpleClientState) GetSession() *Session

func (*SimpleClientState) SetAccount

func (s *SimpleClientState) SetAccount(account *Account)

func (*SimpleClientState) SetSession

func (s *SimpleClientState) SetSession(session *Session)

type StartAuthRequestOptions

type StartAuthRequestOptions struct {
	Purpose            AuthPurpose `json:"purpose"`
	Type               *AuthType   `json:"type,omitempty"`
	DID                *string     `json:"did,omitempty"`
	AuthenticatorID    *string     `json:"authenticatorId,omitempty"`
	AuthenticatorIndex *int        `json:"authenticatorIndex,omitempty"`
}

type StartAuthRequestParams

type StartAuthRequestParams struct {
	DID                string      `json:"did"`
	Type               *AuthType   `json:"type,omitempty"`
	SupportedTypes     []AuthType  `json:"supportedTypes"`
	Purpose            AuthPurpose `json:"purpose"`
	AuthenticatorID    *string     `json:"authenticatorId,omitempty"`
	AuthenticatorIndex *int        `json:"authenticatorIndex,omitempty"`
}

type StartAuthRequestResponse

type StartAuthRequestResponse struct {
	ID              string               `json:"id"`
	DID             string               `json:"did"`
	Token           string               `json:"token"`
	Data            map[string]any       `json:"data"`
	Type            AuthType             `json:"type"`
	Purpose         AuthPurpose          `json:"purpose"`
	AuthenticatorID string               `json:"authenticatorId"`
	RequestStatus   AuthRequestStatus    `json:"requestStatus"`
	AccountStatus   *AccountStatus       `json:"accountStatus,omitempty"`
	Provisioning    *AccountProvisioning `json:"provisioning,omitempty"`
	DeviceTrusted   bool                 `json:"deviceTrusted"`
}

type StartCreateSessionParams

type StartCreateSessionParams struct {
	DID       string  `json:"did"`
	AuthToken *string `json:"authToken,omitempty"`
	AsAdmin   *bool   `json:"asAdmin,omitempty"`
}

type StartCreateSessionResponse

type StartCreateSessionResponse struct {
	AccountID string       `json:"accountId"`
	KeyParams PBKDF2Params `json:"keyParams"`
	SRPId     string       `json:"srpId"`
	B         Base64Bytes  `json:"B"`
	Kind      string       `json:"kind,omitempty"`
	Version   string       `json:"version,omitempty"`
}

type SystemConfig

type SystemConfig struct {
	Location string     `json:"location"`      // Timezone location, e.g. "Asia/Shanghai"
	Language string     `json:"language"`      // Language, e.g. "zh-CN" or "en-US"
	Theme    string     `json:"theme"`         // Theme, e.g. "dark" or "light"
	FRP      *FRPConfig `json:"frp,omitempty"` // Optional FRP configuration
}

SystemConfig system configuration

type TerminusInfo

type TerminusInfo struct {
	WizardStatus string `json:"wizardStatus"`
	OlaresId     string `json:"olaresId"`
}

TerminusInfo Terminus information response

type Token

type Token struct {
	AccessToken  string `json:"access_token"`
	TokenType    string `json:"token_type"`
	RefreshToken string `json:"refresh_token"`
	ExpiresIn    int    `json:"expires_in"`
	ExpiresAt    int    `json:"expires_at"`
	SessionID    string `json:"session_id"`
	FA2          bool   `json:"fa2"`
}

Token struct, corresponds to TypeScript Token interface

func LoginTerminus

func LoginTerminus(bflUrl, terminusName, localName, password string, needTwoFactor bool) (*Token, error)

LoginTerminus implements Terminus login functionality (ref: BindTerminusBusiness.ts loginTerminus)

func OnFirstFactor

func OnFirstFactor(baseURL, terminusName, osUser, osPwd string, acceptCookie, needTwoFactor bool) (*Token, error)

OnFirstFactor implements first factor authentication (ref: BindTerminusBusiness.ts)

type UserStore

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

UserStore implementation using actual DID keys

func NewUserStore

func NewUserStore(mnemonic, terminusName string) (*UserStore, error)

NewUserStore creates user store, generating all keys from mnemonic (using methods from did_key_utils.go)

func (*UserStore) GetAuthURL

func (u *UserStore) GetAuthURL() string

func (*UserStore) GetCurrentID

func (u *UserStore) GetCurrentID() string

UserStore method implementations

func (*UserStore) GetCurrentUserPrivateKey

func (u *UserStore) GetCurrentUserPrivateKey() (*jwk.JWK, error)

func (*UserStore) GetDid

func (u *UserStore) GetDid() string

func (*UserStore) GetDomainName

func (u *UserStore) GetDomainName() string

func (*UserStore) GetLocalName

func (u *UserStore) GetLocalName() string

func (*UserStore) GetMFA

func (u *UserStore) GetMFA() (string, error)

GetMFA retrieves MFA token

func (*UserStore) GetPrivateJWK

func (u *UserStore) GetPrivateJWK() *jwk.JWK

func (*UserStore) GetTerminusName

func (u *UserStore) GetTerminusName() string

func (*UserStore) GetVaultURL

func (u *UserStore) GetVaultURL() string

func (*UserStore) SetMFA

func (u *UserStore) SetMFA(mfa string) error

SetMFA saves MFA token

func (*UserStore) SignJWS

func (u *UserStore) SignJWS(payload map[string]any) (string, error)

SignJWS performs real DID key JWS signing (using BearerDID created from private key)

type Vault

type Vault struct {
	Kind             string      `json:"kind"` // Always "vault" for Vault objects
	ID               string      `json:"id"`
	Name             string      `json:"name"`
	Owner            string      `json:"owner"`
	Created          string      `json:"created"` // ISO 8601 format
	Updated          string      `json:"updated"` // ISO 8601 format
	Revision         string      `json:"revision,omitempty"`
	Items            []VaultItem `json:"items,omitempty"`
	KeyParams        interface{} `json:"keyParams,omitempty"`
	EncryptionParams interface{} `json:"encryptionParams,omitempty"`
	Accessors        interface{} `json:"accessors,omitempty"`
	EncryptedData    interface{} `json:"encryptedData,omitempty"`
	Version          string      `json:"version,omitempty"` // Serialization version
}

Vault represents a vault containing items

type VaultItem

type VaultItem struct {
	ID        string    `json:"id"`
	Name      string    `json:"name"`
	Type      VaultType `json:"type"`
	Icon      string    `json:"icon,omitempty"`
	Fields    []Field   `json:"fields"`
	Tags      []string  `json:"tags"`
	Updated   string    `json:"updated"` // ISO 8601 format
	UpdatedBy string    `json:"updatedBy"`
}

VaultItem represents an item in a vault

type VaultType

type VaultType int

VaultType represents the type of vault item

const (
	VaultTypeDefault           VaultType = 0
	VaultTypeLogin             VaultType = 1
	VaultTypeCard              VaultType = 2
	VaultTypeTerminusTotp      VaultType = 3
	VaultTypeOlaresSSHPassword VaultType = 4
)

type WebPlatform

type WebPlatform struct {
	SupportedAuthTypes []AuthType
	App                AppAPI // App interface, currently only interface definition
	Mnemonic           string // Mnemonic for real JWS signing
	DID                string // DID for user identification
}

WebPlatform implementation - based on original TypeScript WebPlatform

func NewWebPlatform

func NewWebPlatform(app AppAPI) *WebPlatform

func NewWebPlatformWithMnemonic

func NewWebPlatformWithMnemonic(app AppAPI, mnemonic, did string) *WebPlatform

NewWebPlatformWithMnemonic creates WebPlatform with mnemonic

func (*WebPlatform) CompleteAuthRequest

func (p *WebPlatform) CompleteAuthRequest(req *StartAuthRequestResponse) (*AuthenticateResponse, error)

func (*WebPlatform) StartAuthRequest

func (p *WebPlatform) StartAuthRequest(opts StartAuthRequestOptions) (*StartAuthRequestResponse, error)

type WizardConfig

type WizardConfig struct {
	System   SystemConfig   `json:"system"`
	Password PasswordConfig `json:"password"`
}

WizardConfig contains activation wizard configuration

func CustomWizardConfig

func CustomWizardConfig(location, language string, enableTunnel bool, host, jws, currentPassword, newPassword string) WizardConfig

CustomWizardConfig creates custom wizard configuration

Jump to

Keyboard shortcuts

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