JSPM

@4fly/external-apps-sdk

1.1.3
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 9
  • Score
    100M100P100Q54751F
  • License MIT

SDK officiel pour les applications externes 4Fly - v1.1.0 avec middleware Express et factory d'apps

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-sdk

Option 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 CORRECTE
  • getCurrentUser() - Informations utilisateur
  • isAuthenticated() - Statut de connexion

Données

  • getFlights(options?) - Récupère les vols
  • getAircraft() - Récupère les avions
  • isAppInstalled(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

  1. Phase 1 : Publier le package NPM
  2. Phase 2 : Migrer les apps existantes une par une
  3. Phase 3 : Supprimer les copies locales
  4. 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