✳ Lambatoken / Mobile DocsAUTH 0.7.0 · WALLET 0.2.0
Start here / 02

Installation and app setup

Configure one auth instance and initialize wallet services only after authentication.

Install packages

For HOL Mobile use the local MA07 tarball and vendored wallet package. Keep the existing lockfile and use the Expo-compatible native dependencies. The auth package is not assumed to be published. For new applications copy the matching artifacts first.

bash
npm install ./packages/lambabros-mobile-auth-sdk-0.7.0.tgz ./packages/lbt-wallet-sdk
npx expo install expo-secure-store expo-crypto expo-local-authentication
npm --prefix packages/lbt-wallet-sdk run build

Expo Go is useful for initial checks; use a development build for native modules or Face ID/provider features not available in Expo Go. Check all wallet peer dependencies.

Configure public environment

Central Auth is an HTTPS origin without /api/v1. User and Wallet API bases include /api/v1. Use actual deployment addresses and verified chain configuration; never use placeholder contract addresses for transactions.

dotenv
EXPO_PUBLIC_AUTH_API_ORIGIN=https://YOUR_AUTH_HOST
EXPO_PUBLIC_USER_API_URL=https://YOUR_USER_HOST/api/v1
EXPO_PUBLIC_WALLET_API_URL=https://wallet-api.lambatoken.com/api/v1
EXPO_PUBLIC_CHAIN_ID=YOUR_CHAIN_ID
EXPO_PUBLIC_LBT_TOKEN_CONTRACT_ADDRESS=YOUR_TOKEN_ADDRESS
EXPO_PUBLIC_LBT_VERIFYING_CONTRACT=YOUR_VERIFYING_ADDRESS

Create singleton auth client

Create once in a module, not on each render. The storage namespace must belong to exactly one runtime. The audience registry prevents arbitrary origins receiving tokens.

typescript
import * as SecureStore from 'expo-secure-store';
import * as Crypto from 'expo-crypto';
import { fetch as expoFetch } from 'expo/fetch';
import { createAuthClient, createExpoSessionStorage } from '@lambabros/mobile-auth-sdk';

const userUrl = process.env.EXPO_PUBLIC_USER_API_URL!;
const walletUrl = process.env.EXPO_PUBLIC_WALLET_API_URL!;
export const auth = createAuthClient({
  baseUrl: process.env.EXPO_PUBLIC_AUTH_API_ORIGIN!,
  storage: createExpoSessionStorage(SecureStore, 'hol.central-auth.v1'),
  randomUUID: () => Crypto.randomUUID(),
  fetchImpl: expoFetch as typeof fetch,
  audiences: ['lbt-user-api', 'lbt-wallet-api'],
  resourceOrigins: {
    'lbt-user-api': new URL(userUrl).origin,
    'lbt-wallet-api': new URL(walletUrl).origin,
  },
});

Mount the React provider

The provider initializes the SDK and handles foreground resumption. Use useSession() for route state and useAuthClient() for operations. Do not initialize a second SDK in a feature screen.

tsx
import { AppState } from 'react-native';
import { AuthProvider } from '@lambabros/mobile-auth-sdk/react';
import { auth } from './auth';

export default function Root() {
  return <AuthProvider client={auth} appState={AppState}>
    <RootNavigator />
  </AuthProvider>;
}

Create wallet instance per session

Use the existing walletSdkConfig with verified public values. Import the random-values polyfill at application startup. The SDK constructor rejects unauthenticated sessions. Dispose of references and clear application data on account change.

tsx
import 'react-native-get-random-values';
import { LbtWalletSDK } from 'lbt-wallet-sdk';
import { useAuthClient, useSession } from '@lambabros/mobile-auth-sdk/react';
import { useMemo } from 'react';

function useSessionWallet() {
  const auth = useAuthClient();
  const session = useSession();
  return useMemo(() => session.status === 'authenticated'
    ? new LbtWalletSDK({ ...walletSdkConfig, authProvider: auth })
    : null, [auth, session.status, session.userId, session.sessionId]);
}

walletSdkConfig is your application configuration (tokenSymbol, tokenContractAddress, chainId, apiBaseUrl, environment, backupVersion, allowTestnet, verifyingContract; optional chain). No setAccessToken or separate authApiBaseUrl.