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:
- olaresId ending with `olares.cn` → https://api.olares.cn/frp
- everything else → https://api.olares.com/frp
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
- func DefaultStorageRoot(did string) (string, error)
- func FrpListBaseURL(env FrpEnvironment) string
- func GenerateMnemonic() string
- func GetDID(mnemonic string) (string, error)
- func GetPublicJWK(mnemonic string) (*jwk.JWK, error)
- func InitializeGlobalStores(mnemonic, terminusName string) error
- func LoginTerminus(bflUrl, terminusName, localName, password string, needTwoFactor bool) (*auth.Token, error)
- func ResetPassword(baseURL, localName, currentPassword, newPassword, accessToken string) error
- func RunActivationWizard(baseURL, accessToken string, config WizardConfig) error
- func SetPlatform(p Platform)
- func UserBindTerminus(mnemonic, bflUrl, vaultUrl, authUrl, osPwd, terminusName, localName string) (string, error)
- type Accessor
- type Account
- type AccountProvisioning
- type AccountSecrets
- type AccountSettings
- type AccountStatus
- type ActivationWizard
- type ActiveAccountParams
- type App
- type AppAPI
- type AppState
- func (s *AppState) GetAccount() *Account
- func (s *AppState) GetDevice() *DeviceInfo
- func (s *AppState) GetSession() *Session
- func (s *AppState) GetVault(id string) *Vault
- func (s *AppState) PutVault(v Vault)
- func (s *AppState) RemoveVault(id string)
- func (s *AppState) Save() error
- func (s *AppState) SetAccount(account *Account)
- func (s *AppState) SetSession(session *Session)
- func (s *AppState) SetUnlocked(u *UnlockedAccount)
- func (s *AppState) Unlocked() *UnlockedAccount
- type Auth
- type AuthClient
- type AuthError
- type AuthInfo
- type AuthPurpose
- type AuthRequestStatus
- type AuthType
- type AuthenticateRequest
- type AuthenticateResponse
- type Base64Bytes
- type Client
- func (c *Client) ActiveAccount(params ActiveAccountParams) error
- func (c *Client) CompleteAuthRequest(params CompleteAuthRequestParams) (*CompleteAuthRequestResponse, error)
- func (c *Client) CompleteCreateSession(params CompleteCreateSessionParams) (*Session, error)
- func (c *Client) CreateAccount(params CreateAccountParams) (*CreateAccountResponse, error)
- func (c *Client) GetAccount() (*Account, error)
- func (c *Client) GetAuthInfo() (*AuthInfo, error)
- func (c *Client) GetOrg(id string) (*Org, error)
- func (c *Client) GetVault(id string) (*Vault, error)
- func (c *Client) StartAuthRequest(params StartAuthRequestParams) (*StartAuthRequestResponse, error)
- func (c *Client) StartCreateSession(params StartCreateSessionParams) (*StartCreateSessionResponse, error)
- func (c *Client) UpdateVault(vault Vault) (*Vault, error)
- type ClientState
- type CompleteAuthRequestParams
- type CompleteAuthRequestResponse
- type CompleteCreateSessionParams
- type CreateAccountParams
- type CreateAccountResponse
- type CreateItemParams
- type DIDKeyResult
- type DeviceInfo
- type DirKVStorage
- type EncryptionParams
- type ErrorCode
- type ErrorInfo
- type FRPConfig
- type Field
- type FieldType
- type FrpEnvironment
- type FrpListOptions
- type FrpMachine
- type FrpServer
- type HDNode
- type HDWalletGo
- type HTTPSender
- type ISOTime
- type ItemTemplate
- type KeyParams
- type LoginParams
- type MainVault
- type Org
- type OrgInfo
- type OrgMember
- type OrgProvisioning
- type OrgVault
- type PBKDF2Params
- type PasswordConfig
- type Platform
- type Provisioning
- type RSAEncryptionParams
- type Request
- type RequestAuth
- type Response
- type SRPClient
- type SRPCore
- func (c *SRPCore) A(a *big.Int) *big.Int
- func (c *SRPCore) B(v, b *big.Int) (*big.Int, error)
- func (c *SRPCore) ClientS(B, x, a, u *big.Int) (*big.Int, error)
- func (c *SRPCore) H(inputs ...*big.Int) (*big.Int, error)
- func (c *SRPCore) IsZeroWhenModN(n *big.Int) bool
- func (c *SRPCore) K(S *big.Int) (*big.Int, error)
- func (c *SRPCore) K_multiplier() (*big.Int, error)
- func (c *SRPCore) M1(A, B, K *big.Int) (*big.Int, error)
- func (c *SRPCore) M2(A, M1, K *big.Int) (*big.Int, error)
- func (c *SRPCore) ServerS(A, v, u, b *big.Int) *big.Int
- func (c *SRPCore) U(A, B *big.Int) (*big.Int, error)
- func (c *SRPCore) V(x *big.Int) *big.Int
- type SRPGroupLength
- type SRPParams
- type SRPServer
- type SRPSession
- type SSIAuthClient
- type Sender
- type Session
- type SignupParams
- type StartAuthRequestOptions
- type StartAuthRequestParams
- type StartAuthRequestResponse
- type StartCreateSessionParams
- type StartCreateSessionResponse
- type Storage
- type SystemConfig
- type TagInfo
- type TerminusInfo
- type UnlockedAccount
- type UserStore
- func (u *UserStore) GetAuthURL() string
- func (u *UserStore) GetCurrentID() string
- func (u *UserStore) GetCurrentUserPrivateKey() (*jwk.JWK, error)
- func (u *UserStore) GetDid() string
- func (u *UserStore) GetDomainName() string
- func (u *UserStore) GetLocalName() string
- func (u *UserStore) GetMFA() (string, error)
- func (u *UserStore) GetPrivateJWK() *jwk.JWK
- func (u *UserStore) GetTerminusName() string
- func (u *UserStore) GetVaultURL() string
- func (u *UserStore) SetAuthURL(url string)
- func (u *UserStore) SetMFA(mfa string) error
- func (u *UserStore) SignJWS(payload map[string]any) (string, error)
- type Vault
- func (v *Vault) AddItems(items ...VaultItem)
- func (v *Vault) Commit() error
- func (v *Vault) ItemsCollection() *VaultItemCollection
- func (v *Vault) MarkSynced(cutoff time.Time)
- func (v *Vault) Merge(other *Vault)
- func (v *Vault) Unlock(unlocked *UnlockedAccount) error
- func (v *Vault) UpdateAccessors(subjects []*UnlockedAccount) error
- type VaultItem
- type VaultItemCollection
- func (c *VaultItemCollection) ClearChanges(before time.Time)
- func (c *VaultItemCollection) FromBytes(data []byte) error
- func (c *VaultItemCollection) HasChanges() bool
- func (c *VaultItemCollection) Merge(other *VaultItemCollection)
- func (c *VaultItemCollection) Remove(items ...VaultItem)
- func (c *VaultItemCollection) ToBytes() ([]byte, error)
- func (c *VaultItemCollection) Update(items ...VaultItem)
- type VaultType
- type WebPlatform
- type WizardConfig
Constants ¶
const AppStateKind = "appstate"
AppStateKind is the kind used by the local Storage layer.
const ED25519_CODEC_ID = 0xed
Ed25519 multicodec identifier
const TerminusDefaultDomain = "olares.com"
Variables ¶
This section is empty.
Functions ¶
func DefaultStorageRoot ¶
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 GetPublicJWK ¶
GetPublicJWK convenience function: generate public JWK from mnemonic
func InitializeGlobalStores ¶
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:
- pre-compute TOTP eagerly when the caller already knows 2FA is on (`needTwoFactor=true`), so we can submit both factors in one call;
- 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 ¶
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 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 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 ¶
NewApp constructs an App using the given sender and AppState. If state is nil, an in-memory only state is created.
func NewAppWithBaseURL ¶
NewAppWithBaseURL creates App with base URL (convenience function). Uses an in-memory state. Prefer NewAppWithState when you need persistence.
func NewAppWithState ¶
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:
- SRP negotiate session
- GetAccount → Account.Unlock(password) → AppState.SetUnlocked
- Persist app state to disk (Save)
- Synchronize (AuthInfo + Account + Orgs + Vaults)
- If a localvault existed before login (from a prior session), merge its items into the (possibly new) main vault.
func (*App) MainVault ¶
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 ¶
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 ¶
LoadAppState attempts to load an existing state from storage; if none exists, returns a freshly-initialized AppState.
func NewAppState ¶
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 (*AppState) GetDevice ¶
func (s *AppState) GetDevice() *DeviceInfo
func (*AppState) GetSession ¶
func (*AppState) RemoveVault ¶
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 ¶
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 (*AppState) SetSession ¶
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"`
}
type AuthClient ¶
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
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 (*Client) GetAuthInfo ¶
GetAuthInfo fetches the AuthInfo for the current session (mirrors api.getAuthInfo 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)
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 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 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
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 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 ¶
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 ¶
FirstHost returns the first reachable host (matching TS `machine[0].host`), or "" when the entry has no machines.
func (FrpServer) LocalizedName ¶
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 ¶
HTTPSender implements HTTP-based Sender interface
func NewHTTPSender ¶
func NewHTTPSender(baseURL string) *HTTPSender
NewHTTPSender creates new HTTP Sender
type ISOTime ¶
ISOTime is a custom time type that ensures JSON serialization matches JavaScript toISOString() format
func (ISOTime) MarshalJSON ¶
MarshalJSON implements JSON serialization using JavaScript toISOString() format
func (*ISOTime) UnmarshalJSON ¶
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 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 PBKDF2Params ¶
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) Initialize ¶
Initialize initializes SRP client
type SRPCore ¶
type SRPCore struct {
// contains filtered or unexported fields
}
SRPCore implements core SRP algorithms
func NewSRPCore ¶
func NewSRPCore(length SRPGroupLength) *SRPCore
func (*SRPCore) IsZeroWhenModN ¶
IsZeroWhenModN checks if value is zero mod N
func (*SRPCore) K_multiplier ¶
K_multiplier calculates multiplier k = H(N | g)
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 SRPServer ¶
type SRPServer struct {
// contains filtered or unexported fields
}
SRPServer represents SRP server
func NewSRPServer ¶
func NewSRPServer(length SRPGroupLength) *SRPServer
func (*SRPServer) Initialize ¶
Initialize initializes SRP server
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 ¶
PrepareAuthentication implements authentication functionality for SSI client
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 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 ¶
NewUserStore creates user store, generating all keys from mnemonic (using methods from did_key_utils.go)
func (*UserStore) GetAuthURL ¶
func (*UserStore) GetCurrentID ¶
UserStore method implementations
func (*UserStore) GetCurrentUserPrivateKey ¶
func (*UserStore) GetDomainName ¶
func (*UserStore) GetLocalName ¶
func (*UserStore) GetPrivateJWK ¶
func (*UserStore) GetTerminusName ¶
func (*UserStore) GetVaultURL ¶
func (*UserStore) SetAuthURL ¶
SetAuthURL sets a custom auth URL that takes precedence over the auto-derived value returned by GetAuthURL.
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 ¶
AddItems inserts items into the vault's in-memory collection (the caller must subsequently Commit + push to the server).
func (*Vault) Commit ¶
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 ¶
MarkSynced clears all change records up to `cutoff` (or all of them if the zero time is passed).
func (*Vault) Merge ¶
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 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