Interface: UpbondClient
The browser client returned by createUpbond — the entire supported
@upbond/sdk runtime surface. It combines the OIDC auth leg (login, session,
claims) with the wallet leg (connect, unlock, sign, recovery) in either
redirect or embedded mode. Read UpbondClient.state synchronously or
observe it via UpbondClient.subscribe.
Properties
state
readonlystate:UpbondState
The current client state (auth + wallet status, claims, address, phase). Always up to date.
Methods
addPasscodeSealer()
addPasscodeSealer():
Promise<void>
Add a passcode sealer to this device's factor vault (docs/23): the same
wallet afterwards unlocks via passkey OR passcode. Requires an unlocked
wallet (wallet_locked otherwise); the core re-gates with a fresh user
verification and collects the passcode via wallet.promptPasscode.
Refused with passcode_not_allowed under a 'passkey-strict' policy.
Returns
Promise<void>
closeWallet()
closeWallet():
void
Hide the wallet overlay.
Returns
void
connect()
connect():
Promise<string[]>
Connect the embedded wallet. Requires a signed-in session — call
login() first (D20 A-3): the RP authenticates under its own client and
the wallet-origin popup only consumes that issuer session as silent SSO
(+ passkey onboarding on first use); throws not_signed_in otherwise,
before opening anything. MUST be called synchronously from a user
gesture (it opens the popup). Returns the connected accounts.
Returns
Promise<string[]>
connectExternal()
connectExternal(
options):Promise<ExternalWalletSession>
Connect an external wallet: an EIP-6963 injected wallet (MetaMask by
default) or WalletConnect v2. Returns a self-contained session exposing
the wallet's own EIP-1193 provider — the UPBOND auth session and
embedded/redirect wallet are unaffected. The WalletConnect connector
needs wallet.walletConnectProjectId and lazy-loads its relay stack
(plus QR modal) on first use.
Parameters
options
Returns
Promise<ExternalWalletSession>
connectWallet()
connectWallet():
Promise<{status:WalletStatus;walletAddress:string|null; }>
Layer 1 wallet session; also resolves needs-setup vs needs-recovery for new devices.
Returns
Promise<{ status: WalletStatus; walletAddress: string | null; }>
getAccessToken()
getAccessToken():
string|null
The OAuth access token for the issuer's userinfo/management APIs, or null when unavailable.
Returns
string | null
getEthereumProvider()
getEthereumProvider():
Promise<WidgetProvider>
EIP-1193 provider over the widget (ethers/viem plug in directly). Mounts the widget on first call.
Returns
Promise<WidgetProvider>
getIdToken()
getIdToken():
string|null
The raw id_token for downstream verification, or null when there is no valid session.
Returns
string | null
getRecoveryStatus()
getRecoveryStatus():
Promise<RecoveryStatus>
Recovery status (enrollment + masked OTP contact). Layer 1 — works right after connectWallet, no unlock.
Returns
Promise<RecoveryStatus>
getSuiAccount()
getSuiAccount():
Promise<SuiAccount>
The wallet's Sui-on-secp256k1 account (docs/00-BUILD-SPEC.md §3, issue
#205 Option C) — same MPC key as the EVM address, Sui address derivation.
Served from state.suiAccount when the session already captured it (zero
prompts); otherwise establishes the Layer 2 ceremony, which for a locked
wallet means one biometric — call from a user gesture. Throws
wallet_not_set_up for a brand-new wallet.
Returns
Promise<SuiAccount>
getUser()
getUser():
IdTokenClaims|null
The signed-in user's id_token claims, or null when signed out or the token has expired.
Returns
IdTokenClaims | null
init()
init():
Promise<void>
Call once on page load: consumes the redirect callback (and cleans the URL) or restores a persisted session.
Returns
Promise<void>
issueApiFactor()
issueApiFactor(
label):Promise<ApiFactorIssue>
Issue an API factor (docs/37): a new signing factor whose 32-byte key
is returned ONCE (secret, base64) for the owner to store outside
UPBOND. It signs through an authorised signing service; it is a full MPC
factor, so treat it like a private key. Requires an unlocked wallet
(wallet_locked otherwise); the core re-gates with a fresh user
verification. invalid_api_factor_label for a blank/over-long label,
factor_limit_reached at the network cap.
Disabled for clients created by the public createUpbond entry
(api_factors_disabled after unlock); only the workspace wallet host can enable it.
Parameters
label
string
Returns
Promise<ApiFactorIssue>
listExternalWallets()
listExternalWallets():
ExternalWalletInfo[]
The EIP-6963-announced injected wallets currently available in this browser (for install badges / wallet pickers). Announced means installed and responding. Works in every mode; never prompts the user.
Returns
listFactors()
listFactors():
Promise<WalletFactor[]>
List the account's registered key factors (Layer 2 required — the listing runs behind a biometric).
Returns
Promise<WalletFactor[]>
login()
login(
hints?):Promise<void>
Persists PKCE state, then navigates to the issuer. Optional hints (connection, loginHint) skip the issuer's provider chooser. Does not resolve into app code.
Parameters
hints?
Returns
Promise<void>
loginAndConnect()
loginAndConnect(
hints?):Promise<string[]>
One user click → sign-in AND wallet connect (docs/24 1.0.0). Opens a
popup synchronously, runs the OIDC login under the RP's own client inside
it (the registered redirectUri page loads there briefly — its init()
relays the callback automatically), exchanges the code on THIS page, then
the SAME popup continues into the wallet leg. Resolves with the connected
accounts. Already signed in? Behaves exactly like connect.
MUST be called synchronously from a user gesture. Concurrent calls (and
concurrent connect()) share one flow.
Error contract: unsupported_browser (in-app browser — guide the user to
an external browser), popup_blocked (fall back to login()),
popup_closed (the user cancelled), the auth-leg codes
(authorization_error, state_mismatch, ...) if the login fails, and
connect()'s codes for the wallet leg. If the login succeeded but the
wallet leg failed, the session REMAINS signed in — retry with
connect().
Requires the RP pages (this one and the callback) to not sever
window.opener (Cross-Origin-Opener-Policy: same-origin breaks the
relay — use same-origin-allow-popups or none).
Parameters
hints?
Returns
Promise<string[]>
logout()
logout(
options?):Promise<void>
Wallet session first (embedded mode: the widget's wallet-origin session too, via wallet_disconnect), then RP-initiated issuer logout redirect. Clears storage; keeps the device factor (B1).
Parameters
options?
postLogoutRedirectUri?
string
Returns
Promise<void>
openWallet()
openWallet(
view?,options?):Promise<void>
Open the wallet overlay on a view (RP-initiated, e.g. a "wallet" button).
options suggests starting values for that view's form — see
WalletViewOptions.
Parameters
view?
options?
Returns
Promise<void>
recoverWallet()
recoverWallet():
Promise<string>
New-device recovery: synced-passkey restore first, recoverian ceremony fallback.
Returns
Promise<string>
removeFactor()
removeFactor(
factorPubHex):Promise<void>
Remove a stale device factor by its public key (Layer 2 required). Recovery factors and this device's own factor are refused (factor_not_deletable).
Parameters
factorPubHex
string
Returns
Promise<void>
removePasscodeSealer()
removePasscodeSealer():
Promise<void>
Remove the passcode sealer (never the last sealer). Same unlocked-wallet contract as addPasscodeSealer.
Returns
Promise<void>
revokeApiFactor()
revokeApiFactor(
factorPubHex):Promise<void>
Revoke an API factor by its public key (the key is re-shared, the secret stops working). Disabled on the public createUpbond entry, with the same unlocked-wallet contract as issueApiFactor; other factor kinds are refused (factor_not_deletable).
Parameters
factorPubHex
string
Returns
Promise<void>
rotateRecoveryFactor()
rotateRecoveryFactor():
Promise<void>
Rotate the recovery factor (Layer 2 required).
Returns
Promise<void>
setupWallet()
setupWallet():
Promise<string>
First-time onboarding — the first unlock creates the wallet.
Returns
Promise<string>
signMessage()
signMessage(
message):Promise<`0x${string}`>
EIP-191 personal message signature. Same ceremony semantics as signTransaction.
Parameters
message
Uint8Array
Returns
Promise<`0x${string}`>
signTransaction()
signTransaction(
request):Promise<`0x${string}`>
Signs with the session ceremony; every signature re-gates with a fresh biometric. Call from a user gesture.
Parameters
request
Returns
Promise<`0x${string}`>
signTypedData()
signTypedData(
request,opts?):Promise<`0x${string}`>
EIP-712 typed-data signature (eth_signTypedData_v4). Same ceremony
semantics as signTransaction. Pass the struct, not a digest — the wallet
derives the hash itself, and types may keep the redundant
EIP712Domain entry that dApps include. opts.verification: 'fresh'
(1.2.0) demands a new user verification for this signature even inside
a live L1 window — for statements that change who may sign.
Parameters
request
opts?
Returns
Promise<`0x${string}`>
subscribe()
subscribe(
listener): () =>void
Observe state changes; returns an unsubscribe function.
Parameters
listener
(state) => void
Returns
() => void
unlockWallet()
unlockWallet():
Promise<string>
Establishes the session's Layer 2 ceremony (device factor + passkey biometric) and returns the wallet address. Call from a user gesture. One ceremony per session (A2): signatures reuse it, each behind a fresh biometric; logout disposes it.
Returns
Promise<string>
updateRecoveryContact()
updateRecoveryContact(
opts?):Promise<void>
Re-register the recovery contact from the current session's claims
(recovery change → Layer 2). Requires an unlocked wallet (wallet_locked
otherwise); rebinding an already-bound contact runs an OTP ceremony
against the OLD contact via wallet.recovery.promptOtp.
Parameters
opts?
channel?
"email" | "sms"
Returns
Promise<void>