Package Exports
- @4fly/external-apps-sdk
- @4fly/external-apps-sdk/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@4fly/external-apps-sdk) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
@4fly/external-apps-sdk
SDK officiel pour les applications externes 4Fly.
🎯 Objectif
Centraliser le code d'authentification et d'accès aux données 4Fly pour éviter la duplication entre les applications externes.
📦 Installation
Option 1 : Package NPM (Recommandée)
npm install @4fly/external-apps-sdkOption 2 : Copie locale (temporaire)
cp /path/to/4fly/sdk/index.js ./fourfly-sdk.js🚀 Usage
const FourFlySDK = require("@4fly/external-apps-sdk");
// Configuration
const sdk = new FourFlySDK({
supabaseUrl: process.env.SUPABASE_URL,
supabaseAnonKey: process.env.SUPABASE_ANON_KEY,
});
// Authentification avec JWT 4Fly
const result = await sdk.setUserToken(token);
if (result.success) {
console.log("Utilisateur connecté:", result.user.email);
// Récupérer des données
const flights = await sdk.getFlights({ limit: 10 });
const aircraft = await sdk.getAircraft();
}🔧 API
Constructor
new FourFlySDK({ supabaseUrl, supabaseAnonKey, userToken? })Authentification
setUserToken(token)- Configure le JWT utilisateur ✅ MÉTHODE CORRECTEgetCurrentUser()- Informations utilisateurisAuthenticated()- Statut de connexion
Données
getFlights(options?)- Récupère les volsgetAircraft()- Récupère les avionsisAppInstalled(appId)- Vérifie l'installation d'une app
Configuration
setCurrentClub(clubId)- Définit le club actuel
⚠️ Migration depuis l'ancien SDK
Code à remplacer :
// ❌ ANCIEN (ne fonctionne pas)
await this.supabase.auth.setSession({
access_token: token,
refresh_token: null,
});Code correct :
// ✅ NOUVEAU (fonctionne)
this.supabase = createClient(supabaseUrl, supabaseAnonKey, {
global: { headers: { Authorization: `Bearer ${token}` } }
});📋 Apps compatibles
- ✅
apps/duty-manager - ✅
apps/gamification - ✅
apps/aviation-schedule - ✅
apps/ecoflight - 🔄
apps/notam-manager(à migrer)
🔄 Plan de migration
- Phase 1 : Publier le package NPM
- Phase 2 : Migrer les apps existantes une par une
- Phase 3 : Supprimer les copies locales
- Phase 4 : Mandatory pour les nouvelles apps
📝 Changelog
v1.0.0
- Version initiale centralisée
- Méthode
setUserToken()corrigée - Support des vols et avions
- Vérification d'installation d'apps