Skip to main content

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

ParameterTypeRequiredDefaultDescription
baseUrlStringyesAuthCentral backend URL
originSsoOriginyesOrigin header sent with every request (see values below)
appNameStringyesApp display name shown in auth screens
logoString?nonullLogo asset path or URL
themeSsoResolvedTheme?nochatoshiDarkVisual theme
localeLocale?nonull (auto)Force a language for the SDK
textOverridesMap<String, String>?nonullOverride any SDK string by key
appSchemeString?nonullURL scheme for deep link callbacks
walletConfigSsoWalletConfig?nonullWalletConnect / TON config
analyticsSsoAnalyticsConfig?nonullEvent and error callbacks
onAuthSuccessFunction(SsoTokens)?nonullGlobal auth success callback
onAuthFailureFunction()?nonullGlobal auth failure callback
environmentSsoEnvironmentnoproductionTarget backend environment
debugboolnofalseVerbose logging
connectTimeoutDurationno30sHTTP connection timeout
receiveTimeoutDurationno30sHTTP response timeout
allowInsecureDevicesboolnofalseAllow rooted/jailbroken devices
tokenStorageAdapterTokenStorageAdapter?nonullCustom token storage
httpInterceptorsList<dynamic>?nonullExtra Dio interceptors

SsoOrigin values

ValueURLDescription
SsoOrigin.heroProdhttps://auth.hero.ioHero production
SsoOrigin.heroDevhttps://authcentral-1.hero-dev.xyzHero development
SsoOrigin.chatoshiDevhttps://auth.chatoshi.devChatoshi development
SsoOrigin.chatoshiProdhttps://auth.chatoshi.aiChatoshi production
SsoOrigin.vipDevhttps://authcentral-1.dev-vip.netVIP development
SsoOrigin.vipProdhttps://auth.vip.aiVIP 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.