npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

pan-airs-ts

v0.1.0

Published

TypeScript library for Palo Alto Networks AI Runtime Security

Downloads

32

Readme

AI Runtime Security TypeScript Library

A best-practices TypeScript library providing an easier way to interact with Palo Alto Networks AI Runtime Security (AIRS) product. This library is designed to be integrated into modern TypeScript applications (including NestJS backends, RAG applications, and more) to scan and protect AI interactions at runtime.


Table of Contents

  1. Overview
  2. AI Runtime Security in a Nutshell
  3. Installation
  4. Usage
  5. Contributing

Overview

Project Goals:

  • Offer a simple, TypeScript-first interface to AI Runtime Security APIs.
  • Enable developers to quickly integrate runtime scanning and threat prevention for LLM-based apps.
  • Provide a foundation for building secure enterprise AI services in modern JavaScript/TypeScript ecosystems.

This project aims to help developers embed the Palo Alto Networks AI Runtime Security intercept mechanism in their applications with minimal effort, ensuring that both inbound and outbound interactions with LLMs or AI workflows remain safe, monitored, and compliant.


AI Runtime Security in a Nutshell

AI Runtime Security (AIRS) is designed to protect enterprise AI applications from new, AI-specific threats such as prompt injection attacks, malicious URLs, unmoderated data leakage, and model misuse. It seamlessly inspects prompts and responses, enforcing policies to mitigate malicious activity or data exfiltration without disrupting your AI’s normal workflow.

By providing advanced detection and filtering mechanisms, AIRS helps developers guard against model vulnerabilities, data leaks, and other security risks unique to the AI landscape. This ensures that sensitive data is properly handled, potential threats are neutralized, and AI-enabled experiences remain stable and protected.


Installation

npm install pan-airs-ts

Or using Yarn:

yarn add pan-airs-ts

Usage

Below is an example TypeScript file demonstrating how to import and use the PanAirsTsClient in a real application. It shows both synchronous and asynchronous scanning, as well as retrieving scan results and threat reports.

// example-usage.ts
import {
  PanAirsTsClient,
  PanAirsApiError,
  ScanRequest,
  AsyncScanRequest
} from 'pan-airs-ts';

async function main() {
  // 1) Create the client with your API token (and optionally, a custom base URL)
  const client = new PanAirsTsClient({
    apiToken: 'YOUR_AIRS_API_TOKEN',
    // baseURL: 'https://service.api.aisecurity.paloaltonetworks.com' // defaults if omitted
  });

  try {
    // 2) Perform a Synchronous Scan
    const syncRequest: ScanRequest = {
      ai_profile: { profile_name: 'my-airs-profile' },
      metadata: {
        app_name: 'MyApp',
        app_user: 'User123',
        ai_model: 'gpt-4'
      },
      contents: [
        {
          prompt: 'What is the capital of France?',
          response: 'The capital of France is Paris.'
        }
      ]
    };

    console.log('Sending synchronous scan request...');
    const syncResult = await client.scanSyncRequest(syncRequest);
    console.log('Synchronous scan result:', syncResult);

    // 3) Perform an Asynchronous Scan
    const asyncRequest: AsyncScanRequest = [
      {
        req_id: 1,
        scan_req: {
          ai_profile: { profile_name: 'my-airs-profile' },
          contents: [
            {
              prompt: 'Tell me about machine learning.',
              response: 'Machine learning is...'
            }
          ]
        }
      },
      {
        req_id: 2,
        scan_req: {
          ai_profile: { profile_name: 'my-airs-profile' },
          contents: [
            {
              prompt: 'What are neural networks?',
              response: 'Neural networks are...'
            }
          ]
        }
      }
    ];

    console.log('Sending asynchronous scan request...');
    const asyncResult = await client.scanAsyncRequest(asyncRequest);
    console.log('Async scan initial result:', asyncResult);

    // 4) Check results by Scan ID, if provided
    if (asyncResult.scan_id) {
      console.log('Fetching scan results...');
      const scanResults = await client.getScanResultsByScanIds([asyncResult.scan_id]);
      console.log('Scan results:', scanResults);
    }

    // 5) Check threat reports, if provided
    if (asyncResult.report_id) {
      console.log('Fetching threat report...');
      const threatReports = await client.getThreatScanReports([asyncResult.report_id]);
      console.log('Threat reports:', threatReports);
    }

  } catch (error) {
    // 6) Catch and handle PanAirsApiError
    if (error instanceof PanAirsApiError) {
      console.error('AIRS API Error:', {
        statusCode: error.statusCode,
        message: error.message,
        details: error.details,
      });
    } else {
      console.error('Unexpected error:', error);
    }
  }
}

// Execute if this file is run directly (e.g., via ts-node)
if (require.main === module) {
  main().catch(console.error);
}

To run this file in a TypeScript environment, you can do:

npx ts-node example-usage.ts

or compile and run with:

tsc example-usage.ts
node example-usage.js

NestJS Example

Below is a quick snippet showing how you might integrate PanAirsTsClient into a NestJS application:

import { Controller, Post, Body } from '@nestjs/common';
import { PanAirsTsClient } from 'pan-airs-ts';

@Controller('ai')
export class AIController {
  private readonly airsClient: PanAirsTsClient;

  constructor() {
    this.airsClient = new PanAirsTsClient({
      apiToken: process.env.AIRS_API_TOKEN || 'MY_TOKEN'
    });
  }

  @Post('prompt')
  async handlePrompt(@Body() body: { prompt: string, response?: string }) {
    const requestBody = {
      ai_profile: { profile_name: 'my-airs-profile' },
      contents: [{ prompt: body.prompt, response: body.response }],
    };

    // Synchronous scan request
    const scanResult = await this.airsClient.scanSyncRequest(requestBody);
    return scanResult;
  }
}

Contributing

We appreciate all contributions to the pan-airs-ts project! If you’d like to contribute:

  1. Fork this repository and clone it locally.
  2. Install dependencies: npm install
  3. Create a new branch for your feature or fix.
  4. Commit changes with clear messages, and open a Pull Request.
  5. Our team will review your proposal, provide feedback, and merge it if it aligns with the project’s goals.

We strive to maintain a welcoming environment: please be respectful, follow existing coding standards, and ensure your PR passes all checks (lint, tests, etc.).


This project is not an official product of Palo Alto Networks, but rather a community-driven TypeScript library to interface with Palo Alto Networks AI Runtime Security.