Skip to content

Islamic-Open-Finance/iof-devtools

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

IOF DevTools

Command-line tools and utilities for developing with the Islamic Open Finance™ (IOF) Platform.

npm License

What you're building against

IOF is a banking-grade Shariah-native platform: 109 rails across 19 categories (142+ endpoints) composed from 10 native domain engines over a single double-entry ledger. Two of those engines are the platform's defensible moats — the surfaces iof CLI exercises most:

  • Settlement Engineiof settlement * exercises 24×7×365 DvP/FOP/RVP/DFP finality for Murabaha, Ijarah, Salam, Sukuk. AAOIFI SS-1/8/10/17/21/30 enforced at the state machine; CSDR Art. 7 penalties priced pre-confirm. Reclaims 60–140 bps per corridor.
  • Evidence Engineiof evidence export pulls signed, tamper-evident compliance packs: 47/54 controls across SOC 2, ISO 27001, AAOIFI, GDPR, PSD2, IFSB, ISO 20022, SHA-256 Merkle + HMAC, one-call verification. Reclaims 30–55 bps on audit + re-papering.

Combined: 100–195 bps of Islamic-finance friction reclaimed per corridor — no core replacement.

Features

API Testing - Test API endpoints from command line ✅ Contract Validation - Validate Shariah compliance ✅ SDK Generation - Generate client SDKs in multiple languages ✅ Mock Data - Generate realistic test data ✅ Webhook Testing - Test webhook integrations ✅ Environment Management - Switch between environments ✅ Logging - Beautiful formatted logs and debugging ✅ Scaffolding - Bootstrap new projects

Installation

Global Installation (Recommended)

npm install -g @iof/devtools

Local Installation

npm install --save-dev @iof/devtools

Quick Start

# Login to IOF Platform
iof login

# Test API endpoint
iof api call POST /api/v1/contracts/murabaha \
  --data '{"customer_id": "CUST-123", ...}'

# Validate Shariah compliance
iof shariah validate murabaha.json

# Generate SDK
iof sdk generate --lang typescript --output ./sdk

# Start mock server
iof mock start

# View logs
iof logs --follow

Commands

Authentication

iof login

Login to IOF Platform:

# Interactive login
iof login

# With API key
iof login --api-key $IOF_API_KEY

# With OAuth
iof login --oauth

iof logout

Logout from current session:

iof logout

iof whoami

Show current user/organization:

iof whoami

API Testing

iof api call

Make API requests:

# GET request
iof api call GET /api/v1/contracts/murabaha

# POST with data
iof api call POST /api/v1/contracts/murabaha \
  --data '{"customer_id": "CUST-123", ...}'

# POST with file
iof api call POST /api/v1/contracts/murabaha \
  --file contract.json

# Custom headers
iof api call POST /api/v1/contracts/murabaha \
  --header "X-Idempotency-Key: abc123" \
  --data contract.json

iof api test

Run API test suite:

# Run all tests
iof api test

# Run specific test file
iof api test tests/contracts.yaml

# Run with coverage
iof api test --coverage

Example test file (tests/contracts.yaml):

name: Murabaha Contract Tests
tests:
  - name: Create valid contract
    request:
      method: POST
      path: /api/v1/contracts/murabaha
      body:
        customer_id: CUST-123
        asset_category: VEHICLE
        cost_price: 50000
        profit_amount: 5000
    expect:
      status: 201
      body:
        status: DRAFT

  - name: Reject Shariah-violating contract
    request:
      method: POST
      path: /api/v1/contracts/murabaha
      body:
        customer_id: CUST-123
        asset_category: ALCOHOL
    expect:
      status: 422
      body:
        error.code: SHARIAH_BREACH

Shariah Compliance

iof shariah validate

Validate Shariah compliance:

# Validate contract
iof shariah validate contract.json

# Validate with specific rules
iof shariah validate contract.json --rules murabaha

# Show detailed report
iof shariah validate contract.json --verbose

iof shariah rules

List Shariah rules:

# List all rules
iof shariah rules

# Filter by category
iof shariah rules --category CONTRACTS

# Show rule details
iof shariah rules --rule MUR_ASSET_HALAL

Contract Management

iof contracts create

Create contract from template:

# Interactive creation
iof contracts create murabaha

# From file
iof contracts create murabaha --file template.json

# With parameters
iof contracts create murabaha \
  --customer CUST-123 \
  --asset "Toyota Camry 2024" \
  --cost 50000 \
  --profit 5000

iof contracts list

List contracts:

# List all contracts
iof contracts list

# Filter by status
iof contracts list --status ACTIVE

# Filter by type
iof contracts list --type MURABAHA

# JSON output
iof contracts list --format json

iof contracts get

Get contract details:

iof contracts get CNT-789

# Show payment schedule
iof contracts get CNT-789 --schedule

# Show lineage
iof contracts get CNT-789 --lineage

SDK Generation

iof sdk generate

Generate client SDK:

# TypeScript
iof sdk generate --lang typescript --output ./sdk

# Python
iof sdk generate --lang python --output ./sdk

# Java
iof sdk generate --lang java --output ./sdk

# Go
iof sdk generate --lang go --output ./sdk

# All languages
iof sdk generate --lang all --output ./sdks

iof sdk update

Update existing SDK:

iof sdk update ./sdk

Mock Server

iof mock start

Start mock server:

# Default mode (stateless)
iof mock start

# Stateful mode
iof mock start --stateful

# With seed data
iof mock start --seed

# Custom port
iof mock start --port 9000

iof mock seed

Load seed data:

# Load default seed data
iof mock seed

# Load custom data
iof mock seed --file custom-data.json

# Clear all data
iof mock seed --clear

Webhooks

iof webhooks listen

Listen for webhook events:

# Start webhook listener
iof webhooks listen --port 3000

# Filter events
iof webhooks listen --events contract.created,contract.activated

# Save events to file
iof webhooks listen --save events.jsonl

iof webhooks test

Test webhook delivery:

# Test webhook URL
iof webhooks test https://your-app.com/webhooks

# Send test event
iof webhooks test https://your-app.com/webhooks \
  --event contract.created \
  --data contract.json

Environment Management

iof env

Manage environments:

# List environments
iof env list

# Switch environment
iof env use production

# Show current environment
iof env current

# Add custom environment
iof env add staging \
  --url https://api.staging.islamicopenfinance.com \
  --api-key iof_staging_abc123

Data Generation

iof generate

Generate mock data:

# Generate contracts
iof generate contracts --count 100 --output contracts.json

# Generate customers
iof generate customers --count 50 --output customers.json

# Generate cards
iof generate cards --count 30 --output cards.json

# Generate all
iof generate all --output test-data/

Logs

iof logs

View logs:

# View recent logs
iof logs

# Follow logs (tail -f)
iof logs --follow

# Filter by service
iof logs --service contracts

# Filter by level
iof logs --level error

# Search logs
iof logs --grep "Shariah breach"

# JSON output
iof logs --format json

Scaffolding

iof init

Initialize new project:

# Interactive setup
iof init

# Specify template
iof init --template typescript-express

# Specify language
iof init --lang typescript --framework fastify

Templates:

  • typescript-express - TypeScript + Express
  • typescript-fastify - TypeScript + Fastify
  • python-fastapi - Python + FastAPI
  • java-spring - Java + Spring Boot
  • go-gin - Go + Gin

Developer Portal

iof portal

Open developer portal:

# Open in browser
iof portal

# Open API keys page
iof portal keys

# Open documentation
iof portal docs

Configuration

iof config

Manage configuration:

# Show configuration
iof config list

# Set value
iof config set api_key $IOF_API_KEY

# Get value
iof config get api_key

# Reset configuration
iof config reset

Configuration File

Configuration is stored in ~/.iof/config.json:

{
  "environment": "production",
  "api_key": "<IOF_API_KEY>",
  "environments": {
    "production": {
      "url": "https://api.islamicopenfinance.com",
      "api_key": "<IOF_API_KEY>"
    },
    "sandbox": {
      "url": "https://api.sandbox.islamicopenfinance.com",
      "api_key": "<IOF_API_KEY>"
    }
  },
  "defaults": {
    "format": "table",
    "timeout": 30000,
    "retry": 3
  }
}

Environment Variables

Configure via environment variables:

export IOF_API_KEY=<your-api-key>
export IOF_ENVIRONMENT=production
export IOF_LOG_LEVEL=debug
export IOF_TIMEOUT=30000

Examples

Complete Workflow

# 1. Login
iof login --api-key $IOF_API_KEY

# 2. Switch to sandbox
iof env use sandbox

# 3. Create customer
iof api call POST /api/v1/customers \
  --file customer.json

# 4. Create Murabaha contract
iof contracts create murabaha \
  --customer CUST-123 \
  --asset "Toyota Camry 2024" \
  --cost 50000 \
  --profit 5000 \
  > contract.json

# 5. Validate Shariah compliance
iof shariah validate contract.json

# 6. Get contract details
iof contracts get CNT-789 --schedule

# 7. View logs
iof logs --service contracts --follow

Testing Workflow

# 1. Start mock server
iof mock start --stateful --seed &

# 2. Generate test data
iof generate all --output test-data/

# 3. Run API tests
iof api test tests/

# 4. View results
iof logs --level error

CI/CD Integration

name: API Tests

on: [push]

jobs:
  test:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v3

      - name: Setup Node.js
        uses: actions/setup-node@v3
        with:
          node-version: 18

      - name: Install IOF DevTools
        run: npm install -g @iof/devtools

      - name: Login
        run: iof login --api-key ${{ secrets.IOF_API_KEY }}

      - name: Run tests
        run: iof api test tests/

      - name: Validate contracts
        run: iof shariah validate contracts/

Output Formats

All commands support multiple output formats:

# Table (default)
iof contracts list

# JSON
iof contracts list --format json

# YAML
iof contracts list --format yaml

# CSV
iof contracts list --format csv

# Pretty print
iof contracts list --format pretty

Debugging

Enable debug mode:

# Enable debug logging
iof --debug api call POST /api/v1/contracts

# Very verbose
iof --verbose api call POST /api/v1/contracts

# Save debug log
iof --debug api call POST /api/v1/contracts > debug.log 2>&1

Plugins

Extend functionality with plugins:

# Install plugin
iof plugins install @iof/plugin-analytics

# List plugins
iof plugins list

# Remove plugin
iof plugins remove @iof/plugin-analytics

Development

Build from Source

git clone https://github.com/Islamic-Open-Finance/iof-devtools.git
cd iof-devtools

npm install
npm run build
npm link

Run Tests

npm test

Create Plugin

iof plugins create my-plugin

Troubleshooting

Command Not Found

Make sure @iof/devtools is installed globally:

npm install -g @iof/devtools

Authentication Error

Re-login:

iof logout
iof login

API Timeout

Increase timeout:

iof config set timeout 60000  # 60 seconds

Support

License

Apache License 2.0 - see LICENSE file for details.

Related Projects


Built with ❤️ for the Islamic finance community

About

Developer CLI for Islamic Open Finance™ — login, run API requests, generate SDK code, validate Shariah contracts.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors