SDK Initialization
SsoSdk.initialize() must be called once before using any SDK functionality. Typically called in main() before runApp().
SsoConfig
await SsoSdk.initialize(SsoConfig(
// Required
baseUrl: 'https://api.authcentral-1.hero-dev.xyz',
origin: SsoOrigin.heroDev,
appName: 'Chatoshi',
// Branding
logo: 'assets/icons/chatoshi_logo.svg', // asset path or https:// URL
// Theme (default: chatoshiDark)
theme: SsoResolvedTheme.chatoshiDark(),
// Language (default: auto-detect from device)
locale: const Locale('en'),
// String overrides
textOverrides: {
'login_title': 'Welcome back!',
},
// Deep links for wallets / OAuth callbacks
appScheme: 'heroapp',
// Wallet configuration (required if using wallet providers).
// EVM uses reown_appkit under the hood — see
// https://docs.reown.com/appkit/flutter/core/usage for modal / chain /
// Link Mode options. Get a projectId at https://dashboard.reown.com.
walletConfig: const SsoWalletConfig(
evm: SsoEvmWalletConfig(
projectId: 'your-project-id',
// universalLink: 'https://deeplinks.example.com/wc',
),
sol: SsoSolWalletConfig(),
ton: SsoTonWalletConfig(
manifestUrl: 'https://example.com/tonconnect-manifest.json',
),
),
// Analytics
analytics: SsoAnalyticsConfig(
onEvent: (event) => print('${event.name}: ${event.properties}'),
onError: (error) => print('Error: $error'),
),
// Callbacks
onAuthSuccess: (tokens) => print('Authenticated!'),
onAuthFailure: () => print('Auth failed'),
// Environment
environment: SsoEnvironment.production,
debug: false,
// Networking
connectTimeout: const Duration(seconds: 30),
receiveTimeout: const Duration(seconds: 30),
// Security
allowInsecureDevices: false,
));
Parameters reference
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
baseUrl | String | yes | — | AuthCentral backend URL |
origin | SsoOrigin | yes | — | Origin header sent with every request (see values below) |
appName | String | yes | — | App display name shown in auth screens |
logo | String? | no | null | Logo asset path or URL |
theme | SsoResolvedTheme? | no | chatoshiDark | Visual theme |
locale | Locale? | no | null (auto) | Force a language for the SDK |
textOverrides | Map<String, String>? | no | null | Override any SDK string by key |
appScheme | String? | no | null | URL scheme for deep link callbacks |
walletConfig | SsoWalletConfig? | no | null | WalletConnect / TON config |
analytics | SsoAnalyticsConfig? | no | null | Event and error callbacks |
onAuthSuccess | Function(SsoTokens)? | no | null | Global auth success callback |
onAuthFailure | Function()? | no | null | Global auth failure callback |
environment | SsoEnvironment | no | production | Target backend environment |
debug | bool | no | false | Verbose logging |
connectTimeout | Duration | no | 30s | HTTP connection timeout |
receiveTimeout | Duration | no | 30s | HTTP response timeout |
allowInsecureDevices | bool | no | false | Allow rooted/jailbroken devices |
tokenStorageAdapter | TokenStorageAdapter? | no | null | Custom token storage |
httpInterceptors | List<dynamic>? | no | null | Extra Dio interceptors |
SsoOrigin values
| Value | URL | Description |
|---|---|---|
SsoOrigin.heroProd | https://auth.hero.io | Hero production |
SsoOrigin.heroDev | https://authcentral-1.hero-dev.xyz | Hero development |
SsoOrigin.chatoshiDev | https://auth.chatoshi.dev | Chatoshi development |
SsoOrigin.chatoshiProd | https://auth.chatoshi.ai | Chatoshi production |
SsoOrigin.vipDev | https://authcentral-1.dev-vip.net | VIP development |
SsoOrigin.vipProd | https://auth.vip.ai | VIP production |
The selected origin is sent as the Origin HTTP header on every request made by the SDK.
Dispose
To release SDK resources:
SsoSdk.dispose();
After disposal, SsoSdk.instance is no longer accessible until initialize() is called again.