Flutter
The Dart client is kataflax_client_sdk and is not published to pub.dev (publish_to: none). From this monorepo:
dependencies: kataflax_client_sdk: path: ../kataflax_sdks/dart/sdkPass --dart-define=TEFILY_PROJECT_ID=... at build time, or load the project id from your own config. Do not --dart-define a service token into a mobile or web client. The SDK does not depend on a storage package.
login stores the JWT on the client. client.token and session.token are the same string. Persist session.token in whatever secure storage the app already uses for session secrets, then client.setToken on the next launch. setToken is only for restoring a saved JWT.
Email verification is required before login, and the link opens on https://app.tefily.com, not inside the Flutter app. See Auth and owner rules.
import 'package:kataflax_client_sdk/kataflax_client_sdk.dart';
final client = KataflaxClient( baseUrl: const String.fromEnvironment( 'TEFILY_API_URL', defaultValue: 'https://api.tefily.com', ), projectId: const String.fromEnvironment('TEFILY_PROJECT_ID'),);
// First launch, after the verification email (see the auth guide):final session = await client.auth.login(email: email, password: password);final jwt = session.token; // persist this; do not persist a kfxs_ tokenfinal authorId = session.user['_id'] as String;
await client.collection('posts').create({ 'title': 'Hello Tefily', 'status': 'draft', 'authorId': authorId,});
final page = await client.collection('posts').list(page: 1, pageSize: 20);// page.items only includes this user's rows once owner rules existRestore a saved JWT:
client.setToken(savedJwt);final page = await client.collection('posts').list(page: 1, pageSize: 20);An extra filter is optional. The server still applies the owner rule:
final drafts = await client .collection('posts') .where('status', isEqualTo: 'draft') .list();See Auth and owner rules, Dart SDK, and Security.