raulcnadal/applivery-esim-manager

By raulcnadal

โ€ขUpdated about 19 hours ago

Image
0

1.9K

raulcnadal/applivery-esim-manager repository overview

โ ๐Ÿ“ก Applivery eSIM Manager

Image: raulcnadal/applivery-esim-manager | Stack: Next.js 16 ยท Prisma 7 ยท PostgreSQL ยท Docker (AMD64/ARM64)


โ ๐Ÿ“‹ Overview & Architecture

Applivery eSIM Manager is a full-stack UEM companion app bridging Appliveryโ  mobile device management with EMNifyโ  eSIM connectivity.

  • Inventory & Fleet Control: View Applivery-managed devices enriched with EID/ICCID data. Track profiles, assignments, and activation codes.
  • Provisioning Engine: Deploy eSIM profiles to iOS/Android via MDM commands or Agent push notifications.
  • EMNify Sync: Manage Connected Devices (endpoints), toggle states (activate/suspend), and sync device Smart Attributes.
  • Secure API Pipeline: All external API calls run server-side; credentials are never exposed to the browser.
Next.js 16 (Server Pages / Actions / API Routes) โ”€โ”€โ–บ Prisma 7 ORM โ”€โ”€โ–บ PostgreSQL 15+
   โ”œโ”€โ”€ Server-side Outbound Only โ”€โ”€โ–บ Applivery API v1 (api.applivery.io)
   โ””โ”€โ”€ Server-side Outbound Only โ”€โ”€โ–บ EMNify API v1 (cdn.emnify.net)


โ โš™๏ธ Prerequisites & Environment Variables

RequirementMin. VersionNotes
Docker / PostgreSQLDocker 24+ / Postgres 15+Multi-platform builds require BuildKit
Applivery AccountEnterprise / PartnerRequires regular console credentials (email/password)
EMNify Accountโ€”Optional; required only for EMNify integration
DATABASE_URL=postgresql://user:password@host:5432/esim_manager
SESSION_SECRET=change_me_to_a_long_random_secret

# Optional Configuration
APPLIVERY_TOKEN=optional_fallback_service_account_token # Used only for SSR passes without active session
EMNIFY_APP_TOKEN=your_emnify_application_token # Can also be configured inside Settings UI

โ„น๏ธ Authentication Note: DATABASE_URL and SESSION_SECRET are the only core requirements at startup. Day-to-day Applivery operations leverage a human session token generated dynamically when an admin logs in via the UI with their Applivery console credentials.


โ ๐Ÿš€ Deployment

โ Docker Run
docker run -d --name applivery-esim-manager --restart unless-stopped -p 3000:3000 \
  -e DATABASE_URL="postgresql://user:pass@host:5432/esim_manager" \
  -e SESSION_SECRET="your_long_random_secret" \
  raulcnadal/applivery-esim-manager:latest

Note: Prisma migrations execute automatically on initial container startup.

โ Docker Compose
version: '3.9'
services:
  esim-manager:
    image: raulcnadal/applivery-esim-manager:latest
    restart: unless-stopped
    ports: ["3000:3000"]
    environment:
      DATABASE_URL: postgresql://esim:esim_pass@db:5432/esim_manager
      SESSION_SECRET: ${SESSION_SECRET}
    depends_on:
      db: { condition: service_healthy }
    networks: [esim-net]
  db:
    image: postgres:15-alpine
    restart: unless-stopped
    environment:
      POSTGRES_DB: esim_manager
      POSTGRES_USER: esim
      POSTGRES_PASSWORD: esim_pass
    volumes: [postgres_data:/var/lib/postgresql/data]
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U esim -d esim_manager"]
      interval: 10s; timeout: 5s; retries: 5
    networks: [esim-net]
volumes: { postgres_data: }
networks: { esim-net: }

Health Check Endpoint: GET /api/auth/session-check (Returns 200 OK with { authenticated: true/false }).


โ ๐Ÿ› ๏ธ Configuration & Initial Setup

  1. First Login: Route to http://localhost:3000 and use your standard Applivery Console credentials. Local cookie sessions expire after a 60-minute idle timeout. Multi-workspace selectors populate in the top right.
  2. Smart Attributes Setup: Navigate to Settings โ†’ Applivery API and provide your IDs (Applivery Console โ†’ Automation โ†’ Smart Attributes):
  • EID Smart Attribute ID: MongoDB ObjectId storing device eUICC chip identifiers.
  • ICCID Smart Attribute ID (Optional): Automatically writes or clears the assigned eSIM ICCID on the device record during lifecycle events.

โ ๐Ÿ“ˆ Platform Lifecycle & Management

โ Device Fleet & Inventory Status Matrix
  • ๐ŸŸข Available: Profile is free in local inventory and unassigned.
  • ๐ŸŸก Assigned: Profile is linked to an EMNify endpoint mapping. (Note: This indicates the mapping exists; actual physical installation tracking must be confirmed out-of-band).
  • ๐Ÿ”ด Failed: Provisioning command returned an explicit FAILED or CANCELLED response from the Applivery MDM pipeline.
  • โšซ Removed: Profile has been actively deleted from the target device's physical eUICC chip.
[Import/Add] โ”€โ”€โ–บ Available โ”€โ”€โ–บ [Assign to Device / Bind EID] โ”€โ”€โ–บ Assigned โ”€โ”€โ–บ [MDM Payload Pushed] 
                     โ–ฒ                                              โ”‚
                     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ [Release Action Executed] โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ–บ (If MDM Fails) โ”€โ”€โ–บ Failed

โ Provisioning Flow Architecture
โ 1. Single Device Flow
  • iOS (Supervised): Triggers RefreshCellularPlans MDM command. The device handles cryptographic profile negotiation dynamically using its EID against the target SM-DP+ server address.
  • iOS (Non-Supervised): Triggers an Agent Deep Link layout via Applivery push notification containing raw LPA activation codes to the native Applivery Agent (mdmAgent).
  • Android: Requires a pre-recorded EID to push explicit LPA activation codes to the device local profile assistant (EuiccManager).
โ 2. Bulk Provisioning (By Group/Tag)
  • Administrators select an Applivery device tag (supporting mixed iOS/Android assets) and designate an eSIM provider. The automation engine breaks these out into parallel, native, platform-specific command lines.

โ ๐Ÿ“ก EMNify Integration Deep Dive

Configured via Settings โ†’ Integrations โ†’ EMNify. Tracks credentials inside the local database instead of transient environment properties.

โ Configuration Reference
  • Application Token: Long-lived credential generated from EMNify Portal โ†’ Settings โ†’ API. Handles internal token rotations automatically.
  • Profile Mappings: Requires active numeric IDs for Service Profile, Tariff Profile, and your specific SM-DP+ Server Address.
โ Sync & Mechanics Mapping Rules
  • SIM without Endpoint: Status set to AVAILABLE.
  • SIM with Endpoint: Status set to ASSIGNED (Preserved if currently marked FAILED to prevent metadata overwrites).
  • SIM Suspended (Status 2): Matches AVAILABLE or ASSIGNED labeled with "EMNify: Suspended".
  • Enable Mechanics: Executed via PATCH /api/v1/sim/{id} { status: { id: 1 } }. (Endpoint status configuration id:0 functions as a silent API no-op; activating the underlying SIM resolves endpoint state natively).
  • Disable Mechanics: Executed via PATCH /api/v1/endpoint/{id} { status: { id: 1 } }.
โ Cryptographic EID Binding via API
  • Link by SIM (Action 1): Sends POST [https://cdn.emnify.net/api/v1/sim/operation](https://cdn.emnify.net/api/v1/sim/operation) with data structure:
{ "action": { "id": 1 }, "target": [{ "sim": { "id": <simId> }, "eid": "<deviceEid>" }] }

  • Unlink by SIM (Action 3): Sends same structure using action id: 3. Critical Rule: The target profile must be in a GSMA "Released" state (physically deleted from the user handset and reported to the SM-DP+ server) or the API command will fail.
โ EMNify Endpoints & Latency Reference
  • Bulk Ops Rate-Limiter: Chunks assignments (5 per batch/500ms delay). Device toggles trigger 200ms delays; SIM state transitions use 300ms windows; orphan cleanups process at 400ms intervals.
  • Core Endpoints Mapping:
  • Auth: POST /api/v1/authenticate
  • SIM Fetch/Update: GET /api/v1/sim?per_page=2500 | PATCH /api/v1/sim/{id}
  • Endpoint Configurations: GET /api/v1/endpoint?per_page=2500 | POST /api/v1/endpoint | PATCH /api/v1/endpoint/{id}

โ โš ๏ธ Known Limitations & Workarounds

  • Endpoint SIM Erasure Bug: Executing PATCH /endpoint/{id} { sim: null } returns a false positive HTTP 204 while leaving the SIM attached on EMNify's network backend. Workaround: Administrators should use the Release (local only) feature flag within the database UI, clear assignments manually in the EMNify platform, and run a fresh sync profile command.
  • Applivery Agent Prerequisite: Non-supervised iOS push execution will fail with FbToken not found if the application instance has not established target presence on the local device.

โ ๐Ÿ”ง Troubleshooting Matrix

SymptomProbable CauseAction
PrismaClientKnownRequestError: ETIMEDOUTConnectivity FailureValidate that the container environment can resolve the specified DATABASE_URL string.
DYNAMIC_SERVER_USAGE LogsNext.js Server RenderingInformational only. This reflects standard runtime behavior during initialization passes.
EID Unlink API FailuresGSMA State LockoutEnsure the profile has been manually wiped via device system menus (Settings โ†’ Cellular โ†’ Delete eSIM) and wait 1โ€“5 minutes for server propagation before re-executing.
Policy Operations Return 404Schema/Permission MismatchVerify the Target Policy ID exists inside the Applivery system, and confirm the current account holds explicit policy management permissions.

โ ๐Ÿ” Security Configuration

  • Network Perimeter: Requires outbound HTTPS paths to api.applivery.io and cdn.emnify.net. No exposed inbound ingress tunnels are necessary.
  • Token Access Scopes: Session tokens are held strictly within an encrypted, HTTP-only, SameSite=Lax cookie architecture named applivery_esim_session. Rotating the value of SESSION_SECRET instantly flushes and invalidates all active admin sessions globally.

Tag summary

Content type

Image

Digest

sha256:1a0b3351dโ€ฆ

Size

346 MB

Last updated

about 19 hours ago

docker pull raulcnadal/applivery-esim-manager:e556b200b87025c50518d218bc0448ea62f16804