polar-auth-monorepo
v0.11.2
Published
Official SDK monorepo for [Pollar](https://pollar.xyz) — authentication and transaction infrastructure for Stellar and Solana applications.
Readme
@pollar
Official SDK monorepo for Pollar — authentication and transaction infrastructure for Stellar and Solana applications.
This repository is managed with Turborepo and contains the following published packages.
Packages
0.11.2 is additive (no breaking changes). New
client.stellarnamespace: sign SEP-53 message and SEP-10 challenge ownership proofs across custodial and external wallets, both returning the samesep53scheme so a verifier treats them alike. The Transaction History modal goes multichain (network picker, per-chain explorer links, unified{ amount, unit }fees), and the Freighter adapter runs on@stellar/freighter-api6.0.0.Latest break — 0.11.1:
WalletBalanceRecord.balanceand.availablearestring | null—nullmeans the chain could not be read and must render as unavailable, never as0. Every chain reports its native coin plus each token the app enabled (0.11.0 reported only the native token off Stellar).@pollar/reactgained a network picker (<ChainSelect>) that scopes the wallet-balance, enabled-assets, send and receive modals to one chain instead of tagging every row.Earlier breaks worth knowing before you jump versions: 0.11.0 moved every request to the
/v2API and went multichain (Solana joins Stellar). 0.10.0 replaced the singularwalletAdapterresolver andloginWallet(id)with awalletAdapters: WalletAdapter[]array (login({ provider: id })), and forced every user to re-authenticate once.Read UPGRADE.md for the migration steps and the CHANGELOG for the full version history before upgrading.
@pollar/core
Version: 0.11.2 | Registry: npm
Framework-agnostic TypeScript SDK. Provides the PollarClient class and all lower-level utilities needed to integrate
Pollar authentication and multichain (Stellar + Solana) transactions into any JavaScript environment.
Key features:
- Authentication via Google, GitHub, Email OTP, Stellar wallets (Freighter, Albedo), and Solana wallets (Phantom, Solflare, Backpack)
- DPoP-bound access + refresh tokens (RFC 9449) — stolen tokens are useless without the per-session keypair. Web keypair is non-extractable; React Native keypair lives in Keychain / EncryptedSharedPreferences
- Pluggable
Storageadapter — autodetectslocalStorageon web with in-memory fallback; first-class adapters for Expo SecureStore andreact-native-keychainshipped as sub-path exports - Pluggable
KeyManager—WebCryptoKeyManager(browsers) orNobleKeyManager(RN) with autodetection - Race-safe
client.refresh()— concurrent 401 retries coalesce into one refresh; auto-retry on 401 withDPoP-Noncerotation - Stellar transaction building and submission through the Pollar API; balances via
refreshBalance()/getWalletBalance()onPollarClient - Multichain (Stellar + Solana) - v2 wallet balances are tagged by
chain, and every chain reports its native coin plus each token the app enabled. A balance isnullwhen the chain could not be read, which must render as unavailable rather than as zero. Login supports Sign In With Solana (SIWS) and the SDK signs Solana transactions for sponsored external transfers. Solana external-wallet connect ships via@pollar/solana-wallet-standard-adapter - Real-time state management with a typed event system (
onAuthStateChange) - Multi-venue swaps -
getSwapQuote()ranks routes across SDEX / Soroswap / Aquarius;swap()sets the trustline and executes through the standard tx pipeline with on-chainminReceivedslippage. All three venues execute; which ones an app offers is driven by its per-appGET /swap/config - Earn (yield + lending) -
getEarnProviders()/getEarnOpportunities()/getEarnPosition()/earnDeposit()/earnWithdraw()unify DeFindex vaults and Blend pools behind one provider-selected API, each opportunity carrying its live APY - SEP-24 on/off-ramps - anchor deposit/withdraw interactive flow via the
rampsendpoints - Account creation -
createAccount()puts an external wallet's classic account on-chain via a sponsoredcreateAccount; the wallet surfacesexistsOnStellar+fundingMode - Sponsored trustlines -
setTrustlinelets the app config decide who pays (server-side): custodial wallets hit the sponsored/self-pay trustline endpoint, external wallets co-sign whichever XDR the server returns. PassskipSponsorshipto force the user's own wallet to pay viachange_trust - Stellar ownership proofs (SEP-53 / SEP-10) -
client.stellar.sep53.signMessage()andclient.stellar.sep10.sign()prove wallet ownership to a verifier. External wallets sign client-side via their adapter, custodial wallets sign server-side, and both return the samesep53scheme - Network resilience - per-request timeout (default 10s) and idempotent-request retry; typed
PollarNetworkError - KYC verification flow - provider selection, session start, and status polling
- Transaction history - paginated fetch with status tracking
- Built-in wallet adapters (
FreighterAdapter,AlbedoAdapter) plus awalletAdapters: WalletAdapter[]array for external wallet stacks (each adapter auto-renders as a login entry and overrides a built-in by itstype) AdapterFn,PollarAdapter, andPollarAdapterstypes — generic adapter contract for custom signing flows (e.g. Trustless Work SDK)- Active-session management —
listSessions()/revokeSession(familyId)/logoutEverywhere()against the refresh-token family on the server getUserProfile()for in-memory PII access;destroy()to tear down the client cleanly- Full TypeScript typings, ships with ESM and CJS builds
npm install @pollar/coreWeb (no extra setup):
import { PollarClient } from '@pollar/core';
const client = new PollarClient({ apiKey: 'pk_...' });Expo / React Native:
import 'react-native-get-random-values'; // at app entry
import { PollarClient } from '@pollar/core';
import { createSecureStoreAdapter } from '@pollar/core/adapters/expo';
const storage = await createSecureStoreAdapter();
const client = new PollarClient({ apiKey: 'pk_...', storage });HTTPS is required — DPoP needs
SubtleCryptoandcrypto.randomUUID, both secure-context only.
@pollar/react
Version: 0.11.2 | Registry: npm
React bindings built on top of @pollar/core. Provides a context provider, hook, and pre-built UI components for
drop-in authentication in React applications.
Key features:
<PollarProvider>— wraps your app and initialises the Pollar client; acceptsadaptersfor custom signing flowsusePollar()— hook exposing session state,login,logout, balances, transaction/history state, and modal entry points<WalletButton>— ready-made button that opens the authentication modal; dropdown includes Send, Receive, balance, and tx history; shows an inline spinner during in-progress transactions<SendModal>— full send flow in a single modal: asset picker, amount input, destination address, and inline transaction status (build → sign → success/error)<ReceiveModal>— displays the connected wallet address as a QR code with copy-to-clipboard; no external QR dependency required<SwapModal>- multi-venue swap UI over the core swap API, with a route selector across venues and paste-a-custom-token<EarnModal>- deposit/withdraw across DeFindex vaults and Blend pools, with live APY, wallet balance, over-spend guards, and auto-trustline on deposit;usePollar()mirrors the earn methods<RampWidget>- SEP-24 buy/sell flow wired to the core ramps endpoints (external wallets sign the pending XDR inline)<KycModal>- identity verification flow with provider selection and status polling (UI preview - backend coming soon)<TxHistoryModal>— paginated multichain transaction history viewer with auto-fetch on open, a network picker that filters server-side, per-chain explorer links (stellar.expert for Stellar, explorer.solana.com for Solana), and the unified{ amount, unit }fee per row<WalletBalanceModal>— multichain wallet balances (Stellar, Polygon, Solana): a<ChainSelect>picks the network and the rows are scoped to it; an unreadable chain shows a dash, never0<EnabledAssetsModal>— the app's dashboard-enabled assets for the network picked in the header, with per-asset trustline state; establish/remove trustlines (Stellar only — other chains are informational)<DistributionRulesModal>— manage the wallet's distribution rules<ChainSelect>— the shared network picker, exported alongsidechainsOf()/addressForChain()/resolveChain()so you can drive the templates that takechains/selectedChain/onSelectChainyourselfuseChains()— the recommended hook for the app's configured chain order and primary address (returns{ chains, primaryChain, primaryAddress, ready }); what the built-in wallet button and pickers read from<SessionsModal>— drop-in active-sessions UI: lists every refresh-token family for the current user, per-row revoke, and a "Sign out everywhere" buttoncreatePollarAdapterHook(key)— factory for fully-typed hooks that wrap custom adapters with automatic XDR signing- Template components for every modal — pure presentational layer for fully custom UIs
- Bundled stylesheet (
@pollar/react/styles.css) withpollar-namespaced class names - Peer dependency on React >= 18
npm install @pollar/react @pollar/core@pollar/privy-adapter
Version: 0.11.2 | Registry: npm
Client-side Privy wallet adapter for @pollar/core. It drives the whole Privy flow itself - email / Google / GitHub
login, creating the user's Privy embedded wallet (Stellar or Solana), and raw-hash signing - then hands the signature to Pollar for
the standard SEP-10 (Stellar) or SIWS (Solana) login + transaction flow. Self-driving: you configure it once and register it in walletAdapters,
you do not wire up Privy's hooks yourself.
Key features:
createPrivyAdapter(config)+<PrivyAdapterProvider>- aWalletAdapterplus interactive-login methods the Pollar login modal drives (renders a Privy button and sub-modal for the configuredloginMethods)- Web and React Native / Expo - the right build is picked automatically (
@privy-io/react-authon web,@privy-io/expoon RN); a non-React host fails fast withPrivyAdapterUnsupportedError - Auto-sync host login (
onProviderAuthChange) that recovers web OAuth redirects and persisted Privy sessions; optionalcleanupOAuthRedirectanddebuglogging - For server-side custody instead, use
@pollar/privy-server-adapterbelow
npm install @pollar/privy-adapter @pollar/core @stellar/stellar-sdk @privy-io/react-auth react react-dom@pollar/privy-server-adapter
Version: 0.11.2 | Registry: npm
Server-side Privy adapter. A stateless HTTP proxy that lets Pollar sign Stellar or Solana transactions through your Privy
server-wallet account without your PRIVY_APP_SECRET ever leaving your infrastructure. You run it in your own backend
and point Pollar at its URL. (Formerly published as @pollar/privy-adapter, before the client-side rewrite took that
name.)
Key features:
createPollarPrivyAdapter(config)- boots a Hono server (default port3001) exposingPOST /wallets/create,POST /wallets/sign,GET /wallets/:userId/address, andGET /health. Returns{ start, stop }for lifecycle control- Async
getCredentials()resolver so any secret manager (AWS Secrets Manager, GCP Secret Manager, Vault) works; cached for 5 min by default and rebuilt automatically on rotation - Bearer auth on
/wallets/*using constant-time comparison (crypto.timingSafeEqual) - Configurable body-size cap (
maxBodyBytes, default 64 KiB) and per-request timeout (requestTimeoutMs, default 10 s) - Per-userId wallet-address LRU cache (1000 entries, 10 min TTL) - no persistent state
- Operation allowlist - optional
allowedOperations/restrictToTrustlinescap what/wallets/signwill sign; disallowed transactions are rejected withTX_OPERATION_NOT_ALLOWED(403) before any Privy round-trip - Server-side only (Node 20+); do not import it in a client bundle
npm install @pollar/privy-server-adapter@pollar/accesly-adapter
Version: 0.11.2 | Registry: npm
Client-side Accesly smart-account wallet adapter for @pollar/core. Signs Stellar transactions with a user's
Accesly C-address (passkey + MPC) smart wallet, client-side.
Key features:
createAcceslyAdapter({ address, signXdr, meta? })- wraps an Accesly session (useAcceslyfrom@accesly/react) as a PollarWalletAdapter; renders as anacceslylogin entry (login({ provider: 'accesly' }))
npm install @pollar/accesly-adapter @pollar/core @accesly/react @accesly/core@pollar/stellar-wallets-kit-adapter
Version: 0.11.2 | Registry: npm
Plugs Stellar Wallets Kit into Pollar as a set of wallet adapters, without
@pollar/core having to depend on the kit. One install gives Pollar access to every wallet module the kit
supports - Freighter, Albedo, xBull, Lobstr, Rabet, Hana, Bitget, OneKey, Klever, Fordefi, CactusLink, HotWallet,
plus Ledger / Trezor / WalletConnect via opt-in.
Key features:
stellarWalletsKitAdapters(options?)- factory that returns aWalletAdapter[]you pass toPollarClientConfig.walletAdapters(one adapter per module)StellarWalletsKitAdapter- directWalletAdapterimplementation for use outsidePollarClient- Defaults to 12 zero-setup modules; pass an explicit
moduleslist to add Ledger / Trezor / WalletConnect or to trim the bundle - SSR-safe:
stellarWalletsKitAdapters()returns[]when there is nowindow(Next.js / Remix) and builds the real list when it re-runs on the client - Peer deps:
@creit.tech/stellar-wallets-kit@^2.0.0and@pollar/core@^0.11.2(the kit is not bundled)
npm install @pollar/stellar-wallets-kit-adapter @pollar/core @creit.tech/stellar-wallets-kit@pollar/solana-wallet-standard-adapter
Version: 0.11.2 | Registry: npm
The Solana counterpart to @pollar/stellar-wallets-kit-adapter. Connects user-controlled Solana wallets (Phantom,
Solflare, Backpack, ...) to @pollar/core through the Wallet Standard,
without bundling any wallet SDK into @pollar/core. Login uses SIWS (Sign In With Solana) via each wallet's native
solana:signIn feature - the Solana analogue of Stellar's SEP-10 challenge.
Key features:
solanaWalletStandardAdapters(options?)- discovers every installed Solana wallet and returns oneWalletAdaptereach to pass toPollarClientConfig.walletAdapters; SSR-safe (returns[]when there is nowindow)SolanaWalletStandardAdapter- directWalletAdapterimplementation for use outsidePollarClient- Peer dep:
@pollar/core@^0.11.2only. The@wallet-standard/*packages and@solana/wallet-standard-featuresare bundled as regular dependencies, so consumers don't install them; no wallet SDK is bundled
npm install @pollar/solana-wallet-standard-adapter @pollar/coreRepository Structure
@pollar/
├── packages/
│ ├── core/ # @pollar/core - framework-agnostic SDK
│ ├── react/ # @pollar/react - React bindings and UI components
│ ├── privy-adapter/ # @pollar/privy-adapter - client-side Privy wallet adapter (web + RN)
│ ├── privy-server-adapter/ # @pollar/privy-server-adapter - server-side Privy signing proxy
│ ├── accesly-adapter/ # @pollar/accesly-adapter - client-side Accesly smart-wallet adapter
│ ├── stellar-wallets-kit-adapter/ # @pollar/stellar-wallets-kit-adapter - Stellar Wallets Kit bridge
│ └── solana-wallet-standard-adapter/ # @pollar/solana-wallet-standard-adapter - Solana Wallet Standard bridge
├── examples/ # Example apps (e.g. privy-web)
├── docs/ # API reference documentation
├── tests/ # Smoke tests for the built SDK
├── turbo.json # Turborepo pipeline configuration
└── tsconfig.base.json # Shared TypeScript base configurationDevelopment
This monorepo uses Turborepo for task orchestration and npm
workspaces as the package manager (pinned via packageManager in the root package.json).
Prerequisites
- Node.js >= 20 (matches the
enginesfloor declared by every published package) - npm >= 10
Install dependencies
npm installBuild all packages
npm run buildBuild in watch mode
npm run devType-check all packages
npm run lintClean build artifacts
npm run cleanLicense
MIT
