wizard

package
v0.0.0-...-35992de Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2026 License: AGPL-3.0 Imports: 38 Imported by: 0

Documentation

Overview

frp.go: fetch the public Olares-tunnel (FRP) registry by olaresId.

Mirrors the TS reference in TermiPass/packages/app/src/stores/wizard-step.ts (getFrpList) and the shared host map in TermiPass/packages/core/src/global.ts:

We POST `/v2/servers` with `{"name": "<olaresId>"}` and decode the returned `OlaresTunneV2Interface[]` shape:

[{ region: string, name: { "en-US": ..., "zh-CN": ... }, machine: [{ host: string }] }]

This endpoint is public (no auth header) and is the same one the activation wizard's "select tunnel" step calls before the user has finished binding to a per-user namespace.

Index

Constants

View Source
const AppStateKind = "appstate"

AppStateKind is the kind used by the local Storage layer.

View Source
const ED25519_CODEC_ID = 0xed

Ed25519 multicodec identifier

View Source
const TerminusDefaultDomain = "olares.com"

Variables

This section is empty.

Functions

func DefaultStorageRoot

func DefaultStorageRoot(did string) (string, error)

DefaultStorageRoot returns ~/.olares/<did>; falls back to current dir if the user home cannot be resolved.

func FrpListBaseURL

func FrpListBaseURL(env FrpEnvironment) string

FrpListBaseURL returns the public Olares API base URL the FRP list call targets for `env`. Unknown envs fall back to the EN endpoint (same defensive default as the TS code).

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 the global UserStore and the local DirKVStorage rooted at ~/.olares/<did>/. The DID is derived from the mnemonic via the UserStore.

func LoginTerminus

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

LoginTerminus performs first-factor (and, when needed, second-factor TOTP) authentication against the Authelia backend. The actual HTTP work is delegated to pkg/auth.Login so the wizard never owns its own copy of the `passwordAddSort` salt math, the cookie-jar / 2FA wiring, or the response parser — keeping wire-format quirks centralised in pkg/auth.

The wizard-specific bit that pkg/auth deliberately does not know about is where the TOTP code comes from: during activation it has to be computed locally from the MFA seed stored in globalUserStore (see getTOTPFromMFA). We therefore:

  1. pre-compute TOTP eagerly when the caller already knows 2FA is on (`needTwoFactor=true`), so we can submit both factors in one call;
  2. fall back to the same TOTP source if pkg/auth.Login surfaces ErrTOTPRequired (caller passed false but server says fa2 is needed) — this matches the old wizard behaviour of branching on `token.FA2 || needTwoFactor`.

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, authUrl, osPwd, terminusName, localName string) (string, error)

UserBindTerminus main user binding function (ref: TypeScript version)

Types

type Accessor

type Accessor struct {
	ID           string      `json:"id"`
	EncryptedKey Base64Bytes `json:"encryptedKey"`
	PublicKey    Base64Bytes `json:"publicKey,omitempty"`
}

Accessor mirrors apps/packages/sdk/src/core/container.ts Accessor.

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
}

func (*Account) Unlock

func (acc *Account) Unlock(password string) (*UnlockedAccount, error)

Unlock derives the master key from `password` using PBKDF2 (account.KeyParams), AES-GCM-decrypts the account secrets blob, and returns a non-nil UnlockedAccount carrying the cleartext private/signing keys.

Mirrors apps/packages/sdk/src/core/account.ts Account.unlock.

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,omitempty"`
}

AccountProvisioning represents account provisioning information

type AccountSecrets

type AccountSecrets struct {
	SigningKey Base64Bytes `json:"signingKey"`
	PrivateKey Base64Bytes `json:"privateKey"`
	Favorites  []string    `json:"favorites,omitempty"`
	Tags       []TagInfo   `json:"tags,omitempty"`
}

AccountSecrets is the JSON shape that lives inside the account's AES-GCM encryptedData blob.

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:"-"`
	State   *AppState `json:"-"`
}

App class - mirrors the TS App in apps/packages/sdk/src/core/app.ts.

Holds a single AppState which is both the in-memory client state used by the RPC Client and the persistable representation of the account / vaults / orgs known to this client.

func NewApp

func NewApp(sender Sender, state *AppState) *App

NewApp constructs an App using the given sender and AppState. If state is nil, an in-memory only state is created.

func NewAppWithBaseURL

func NewAppWithBaseURL(baseURL string) *App

NewAppWithBaseURL creates App with base URL (convenience function). Uses an in-memory state. Prefer NewAppWithState when you need persistence.

func NewAppWithState

func NewAppWithState(baseURL string, state *AppState) *App

NewAppWithState creates App with an explicit AppState (typically backed by a DirKVStorage rooted at ~/.olares/<did>/).

func (*App) CreateItem

func (a *App) CreateItem(params CreateItemParams) (*VaultItem, error)

CreateItem builds a fresh VaultItem, adds it to the given vault, commits, pushes to the server, and re-unlocks (so the vault is left in a usable state). Mirrors App.createItem → addItems → saveVault → syncVault in TS.

func (*App) Login

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

Login mirrors apps/packages/sdk/src/core/app.ts App.login.

Flow:

  1. SRP negotiate session
  2. GetAccount → Account.Unlock(password) → AppState.SetUnlocked
  3. Persist app state to disk (Save)
  4. Synchronize (AuthInfo + Account + Orgs + Vaults)
  5. If a localvault existed before login (from a prior session), merge its items into the (possibly new) main vault.

func (*App) MainVault

func (a *App) MainVault() *Vault

MainVault returns the (possibly nil) Vault stored locally that corresponds to account.mainVault.id.

func (*App) Signup

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

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

func (*App) Synchronize

func (a *App) Synchronize() error

Synchronize fetches AuthInfo, Account, Orgs and Vaults from the server, merges any local changes back in, and persists everything to the local Storage. Mirrors App.synchronize in apps/packages/sdk/src/core/app.ts.

Requires the AppState to already have an unlocked account (call Account.Unlock before invoking this).

type AppAPI

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

AppAPI interface for app-level operations

type AppState

type AppState struct {
	ID       string      `json:"id"` // "app-state-<did>"
	Device   *DeviceInfo `json:"device,omitempty"`
	Account  *Account    `json:"account,omitempty"`
	AuthInfo *AuthInfo   `json:"authInfo,omitempty"`
	Orgs     []Org       `json:"orgs,omitempty"`
	Vaults   []Vault     `json:"vaults,omitempty"`
	LastSync string      `json:"lastSync,omitempty"`

	// Session and unlocked secrets are intentionally NOT persisted.
	// A Session is bound to a specific server-side record (with its
	// HMAC key) and becomes invalid as soon as the process exits or
	// the server restarts. Persisting it would cause subsequent runs
	// to sign requests with a dead session id, which the server
	// rejects with [invalid_session]. They live in memory only and
	// must be re-established by Login() on every process start.
	Session *Session `json:"-"`
	// contains filtered or unexported fields
}

AppState mirrors the relevant subset of the TS AppState (apps/packages/sdk/src/core/app.ts: class AppState). Persisted to the local Storage as kind="appstate", id="app-state-<did>".

Only fields that we currently need on the CLI are tracked. Runtime-only state (storage handle, unlocked secrets) is annotated with json:"-".

func LoadAppState

func LoadAppState(storage Storage, did string) (*AppState, error)

LoadAppState attempts to load an existing state from storage; if none exists, returns a freshly-initialized AppState.

func NewAppState

func NewAppState(storage Storage, did string) *AppState

NewAppState returns a fresh AppState bound to the given storage and DID. It does NOT load anything from disk — use LoadAppState for that.

func (*AppState) GetAccount

func (s *AppState) GetAccount() *Account

func (*AppState) GetDevice

func (s *AppState) GetDevice() *DeviceInfo

func (*AppState) GetSession

func (s *AppState) GetSession() *Session

func (*AppState) GetVault

func (s *AppState) GetVault(id string) *Vault

GetVault returns a pointer to the vault with the given id, or nil.

func (*AppState) PutVault

func (s *AppState) PutVault(v Vault)

PutVault inserts or replaces the vault with the same id.

func (*AppState) RemoveVault

func (s *AppState) RemoveVault(id string)

RemoveVault deletes the vault with the given id from in-memory state. The change is persisted next time Save() is called (vaults live inline inside the AppState record, so there is no separate file to delete).

func (*AppState) Save

func (s *AppState) Save() error

Save persists the AppState to the storage. Vaults are serialized inline as part of the AppState (see the `Vaults` field above and TS AppState.vaults / App.saveState in apps/packages/sdk/src/core/app.ts), so we do NOT write per-vault files separately.

func (*AppState) SetAccount

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

func (*AppState) SetSession

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

func (*AppState) SetUnlocked

func (s *AppState) SetUnlocked(u *UnlockedAccount)

SetUnlocked stores the unlocked account in memory only.

func (*AppState) Unlocked

func (s *AppState) Unlocked() *UnlockedAccount

Unlocked returns the currently in-memory UnlockedAccount (or nil).

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 AuthInfo

type AuthInfo struct {
	Provisioning *Provisioning `json:"provisioning,omitempty"`
}

AuthInfo is the minimal subset of apps/packages/sdk/src/core/api.ts AuthInfo persisted by the CLI.

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) GetAuthInfo

func (c *Client) GetAuthInfo() (*AuthInfo, error)

GetAuthInfo fetches the AuthInfo for the current session (mirrors api.getAuthInfo in TS).

func (*Client) GetOrg

func (c *Client) GetOrg(id string) (*Org, error)

GetOrg fetches an org by id (mirrors api.getOrg in TS).

func (*Client) GetVault

func (c *Client) GetVault(id string) (*Vault, error)

GetVault fetches a vault by id (mirrors api.getVault in TS).

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 CreateItemParams

type CreateItemParams struct {
	ID     string // optional; if empty, a new UUID is generated
	Name   string
	Vault  *Vault
	Fields []Field
	Tags   []string
	Icon   string
	Type   VaultType
}

CreateItemParams is the Go counterpart of TS CreateItemParams.

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 DirKVStorage

type DirKVStorage struct {
	Root string
	// contains filtered or unexported fields
}

DirKVStorage is a filesystem-backed Storage implementation that stores each (kind, id) entry as a JSON file under Root.

func NewDirKVStorage

func NewDirKVStorage(root string) (*DirKVStorage, error)

NewDirKVStorage creates a new DirKVStorage at the given root. Creates the root directory if it does not exist.

func (*DirKVStorage) Delete

func (s *DirKVStorage) Delete(kind, id string) error

func (*DirKVStorage) Get

func (s *DirKVStorage) Get(kind, id string, out any) error

func (*DirKVStorage) List

func (s *DirKVStorage) List(kind string) ([]string, error)

func (*DirKVStorage) Put

func (s *DirKVStorage) Put(kind, id string, in any) error

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 FrpEnvironment

type FrpEnvironment string

FrpEnvironment selects which public Olares API host to talk to.

const (
	FrpEnvCN FrpEnvironment = "cn"
	FrpEnvEN FrpEnvironment = "en"
)

func FrpEnvironmentForOlaresID

func FrpEnvironmentForOlaresID(olaresID string) FrpEnvironment

FrpEnvironmentForOlaresID picks the right environment based on the olaresId suffix, matching TS userNameToEnvironment().

type FrpListOptions

type FrpListOptions struct {
	// Environment forces the API host. When empty, FetchFrpList falls
	// back to FrpEnvironmentForOlaresID(olaresID).
	Environment FrpEnvironment
	// HTTPClient overrides the default 10s-timeout client. Useful for
	// tests; production callers should leave this nil.
	HTTPClient *http.Client
	// Timeout overrides the default 10s timeout when HTTPClient is
	// nil. Ignored when HTTPClient is set.
	Timeout time.Duration
}

FrpListOptions tunes the FetchFrpList call. The zero value is valid and uses sane defaults.

type FrpMachine

type FrpMachine struct {
	Host string `json:"host"`
}

FrpMachine is one of the (potentially many) reachable hosts for a region. The TS code uses `machine[0].host` as the default selection; we surface every host so callers can decide.

type FrpServer

type FrpServer struct {
	Region  string            `json:"region"`
	Name    map[string]string `json:"name"`
	Machine []FrpMachine      `json:"machine"`
}

FrpServer is one entry of the public Olares-tunnel registry. The `Name` field is a {locale: label} map (e.g. `en-US`, `zh-CN`) — the caller picks which locale to render.

func FetchFrpList

func FetchFrpList(ctx context.Context, olaresID string, opts FrpListOptions) ([]FrpServer, error)

FetchFrpList calls POST <FrpListBaseURL>/v2/servers and returns the decoded server list. The endpoint is unauthenticated; the only input is the olaresId, which the registry uses to scope the response.

func (FrpServer) FirstHost

func (s FrpServer) FirstHost() string

FirstHost returns the first reachable host (matching TS `machine[0].host`), or "" when the entry has no machines.

func (FrpServer) LocalizedName

func (s FrpServer) LocalizedName(locale string) string

LocalizedName returns the label for `locale`, falling back to en-US then any non-empty entry. Mirrors TS olaresTunnelsV2Options() in stores/settings/network.ts.

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.

Mirrors the TS AjaxSender behavior: the caller passes the full endpoint URL, and the sender POSTs to it directly without appending any path.

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 Org

type Org struct {
	ID        string      `json:"id"`
	Name      string      `json:"name,omitempty"`
	Revision  string      `json:"revision,omitempty"`
	PublicKey Base64Bytes `json:"publicKey,omitempty"`
	Vaults    []OrgVault  `json:"vaults,omitempty"`
	Members   []OrgMember `json:"members,omitempty"`
}

Org is the minimal subset of apps/packages/sdk/src/core/org.ts that the CLI needs in order to fetch / iterate vaults shared via an org.

type OrgInfo

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

OrgInfo represents organization information

type OrgMember

type OrgMember struct {
	ID        string      `json:"id,omitempty"`
	AccountID string      `json:"accountId,omitempty"`
	DID       string      `json:"did"`
	Name      string      `json:"name,omitempty"`
	PublicKey Base64Bytes `json:"publicKey,omitempty"`
	Role      int         `json:"role,omitempty"`
	Status    string      `json:"status,omitempty"`
	Vaults    []OrgVault  `json:"vaults,omitempty"`
}

type OrgProvisioning

type OrgProvisioning struct {
	OrgID         string         `json:"orgId"`
	OrgName       string         `json:"orgName,omitempty"`
	Status        string         `json:"status,omitempty"`
	StatusLabel   string         `json:"statusLabel,omitempty"`
	StatusMessage any            `json:"statusMessage,omitempty"`
	ActionURL     *string        `json:"actionUrl,omitempty"`
	ActionLabel   *string        `json:"actionLabel,omitempty"`
	MetaData      map[string]any `json:"metaData,omitempty"`
	AutoCreate    bool           `json:"autoCreate,omitempty"`
	Quota         map[string]any `json:"quota,omitempty"`
	Features      map[string]any `json:"features,omitempty"`
}

OrgProvisioning mirrors the subset of TS OrgProvisioning that can appear inside AuthInfo.provisioning.orgs.

type OrgVault

type OrgVault struct {
	ID       string `json:"id"`
	Name     string `json:"name,omitempty"`
	Revision string `json:"revision,omitempty"`
	Readonly bool   `json:"readonly,omitempty"`
}

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 Provisioning

type Provisioning struct {
	Account *AccountProvisioning `json:"account,omitempty"`
	Orgs    []OrgProvisioning    `json:"orgs,omitempty"`
}

Provisioning mirrors apps/packages/sdk/src/core/provisioning.ts Provisioning.

type RSAEncryptionParams

type RSAEncryptionParams struct {
	Algorithm string `json:"algorithm"` // "RSA-OAEP"
	Hash      string `json:"hash"`      // "SHA-256"
	Kind      string `json:"kind,omitempty"`
	Version   string `json:"version,omitempty"`
}

RSAEncryptionParams mirrors the same-named TS class. Only RSA-OAEP / SHA-256 is supported (matching the server defaults).

func NewRSAEncryptionParams

func NewRSAEncryptionParams() RSAEncryptionParams

NewRSAEncryptionParams constructs the canonical params used by TS.

type Request

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

Request represents an RPC request.

IMPORTANT: do NOT add `omitempty` to Params. The TS client always sends `params: []` on the wire (see apps/packages/sdk/src/core/client.ts line 41-52: `typeof input === 'undefined' ? [] : [...]`), and the server signs against `JSON.stringify(req.params)` (where `[]` -> "[]" but `undefined` -> "undefined"). With `omitempty` Go would drop the field for empty param calls (e.g. `getAccount`), causing a signature mismatch: client signs `..._[]` while server signs `..._undefined`.

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 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 Storage

type Storage interface {
	Get(kind, id string, out any) error
	Put(kind, id string, in any) error
	Delete(kind, id string) error
	List(kind string) ([]string, error)
}

Storage abstracts a small key/value store keyed by (kind, id). CLI uses DirKVStorage to persist AppState/Vault objects under ~/.olares/<did>/{kind}-{id}.json.

func GetGlobalStorage

func GetGlobalStorage() Storage

GetGlobalStorage returns the process-wide DirKVStorage initialized via InitializeGlobalStores. May be nil if init has not yet been called.

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 TagInfo

type TagInfo struct {
	Name     string  `json:"name"`
	Unlisted *bool   `json:"unlisted,omitempty"`
	Color    *string `json:"color,omitempty"`
}

TagInfo mirrors apps/packages/sdk/src/core/item.ts TagInfo.

type TerminusInfo

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

TerminusInfo Terminus information response

type UnlockedAccount

type UnlockedAccount struct {
	Account    *Account
	MasterKey  []byte
	PrivateKey []byte // PKCS1 DER
	SigningKey []byte // HMAC key
}

UnlockedAccount holds the in-memory secrets derived from a successful Account.Unlock call (PBKDF2 → AES-GCM decrypt of EncryptedData).

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) SetAuthURL

func (u *UserStore) SetAuthURL(url string)

SetAuthURL sets a custom auth URL that takes precedence over the auto-derived value returned by GetAuthURL.

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"`
	ID               string              `json:"id"`
	Name             string              `json:"name"`
	Owner            string              `json:"owner"`
	Org              *OrgInfo            `json:"org,omitempty"`
	Created          string              `json:"created"`
	Updated          string              `json:"updated"`
	Revision         string              `json:"revision,omitempty"`
	KeyParams        RSAEncryptionParams `json:"keyParams"`
	EncryptionParams EncryptionParams    `json:"encryptionParams"`
	Accessors        []Accessor          `json:"accessors"`
	EncryptedData    Base64Bytes         `json:"encryptedData,omitempty"`
	Version          string              `json:"version,omitempty"`
	// contains filtered or unexported fields
}

Vault is the Go counterpart of apps/packages/sdk/src/core/vault.ts.

`items` and the cleartext shared key live only in memory after a successful Unlock call; they are not serialized to JSON.

func (*Vault) AddItems

func (v *Vault) AddItems(items ...VaultItem)

AddItems inserts items into the vault's in-memory collection (the caller must subsequently Commit + push to the server).

func (*Vault) Commit

func (v *Vault) Commit() error

Commit re-encrypts the in-memory item collection into EncryptedData. Mirrors Vault.commit in TS.

func (*Vault) ItemsCollection

func (v *Vault) ItemsCollection() *VaultItemCollection

Items returns the in-memory collection (allocating if needed).

func (*Vault) MarkSynced

func (v *Vault) MarkSynced(cutoff time.Time)

MarkSynced clears all change records up to `cutoff` (or all of them if the zero time is passed).

func (*Vault) Merge

func (v *Vault) Merge(other *Vault)

Merge takes the items, name, accessors, etc from `other` while preserving locally-changed items. Mirrors Vault.merge in TS.

func (*Vault) Unlock

func (v *Vault) Unlock(unlocked *UnlockedAccount) error

Unlock decrypts the vault's shared key using the unlocked account's RSA private key, then AES-GCM-decrypts the items blob. Mirrors apps/packages/sdk/src/core/vault.ts Vault.unlock.

func (*Vault) UpdateAccessors

func (v *Vault) UpdateAccessors(subjects []*UnlockedAccount) error

UpdateAccessors generates a fresh shared AES key, re-encrypts any existing data with it, and wraps the new key with each subject's RSA public key. Mirrors SharedContainer.updateAccessors in TS.

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 VaultItemCollection

type VaultItemCollection struct {
	Items   map[string]VaultItem `json:"-"`
	Changes map[string]ISOTime   `json:"-"`
}

VaultItemCollection mirrors apps/packages/sdk/src/core/collection.ts. Items keyed by id; Changes records the last time an item was modified locally so that merge() knows which side wins.

func NewVaultItemCollection

func NewVaultItemCollection() *VaultItemCollection

NewVaultItemCollection returns an empty collection.

func (*VaultItemCollection) ClearChanges

func (c *VaultItemCollection) ClearChanges(before time.Time)

ClearChanges drops change records older than `before` (zero means all).

func (*VaultItemCollection) FromBytes

func (c *VaultItemCollection) FromBytes(data []byte) error

FromBytes deserializes a TS-compatible payload back into the collection.

func (*VaultItemCollection) HasChanges

func (c *VaultItemCollection) HasChanges() bool

HasChanges reports whether any local changes are still pending sync.

func (*VaultItemCollection) Merge

func (c *VaultItemCollection) Merge(other *VaultItemCollection)

Merge mirrors VaultItemCollection.merge in TS: locally-changed items always win, otherwise the other side's items overwrite.

func (*VaultItemCollection) Remove

func (c *VaultItemCollection) Remove(items ...VaultItem)

Remove deletes items by id and records the deletion as a change.

func (*VaultItemCollection) ToBytes

func (c *VaultItemCollection) ToBytes() ([]byte, error)

ToBytes serializes the collection in a way compatible with the TS implementation (items: array, changes: [[id, iso-time], ...]).

func (*VaultItemCollection) Update

func (c *VaultItemCollection) Update(items ...VaultItem)

Update inserts or replaces the given items, marking each as changed.

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