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

@spektre/veil

v1.0.4

Published

Security and monitoring wrapper for React apps built with AI tools

Readme

@spektre/react

React security and monitoring wrapper for Spektre platform. Protect your React applications with real-time security scanning, monitoring, and active protection.

Installation

npm install @spektre/veil

Quick Start

Wrap your application with SecurityGate to enable security monitoring and protection:

import { SecurityGate } from '@spektre/veil';

function App() {
  return (
    <SecurityGate apiKey="your-spektre-api-key">
      <YourApp />
    </SecurityGate>
  );
}

That's it! Your app is now protected with Spektre security monitoring.

Full Usage Example

Configure security modules and add custom handlers:

import { SecurityGate } from '@spektre/veil';

function App() {
  return (
    <SecurityGate
      apiKey="your-spektre-api-key"
      config={{
        environment: 'prod',
        enabledEnvironments: ['prod', 'staging'],
        modules: {
          performanceMonitoring: true,
          secretDetection: true,
          scriptProfiling: true,
          supplyChainDetection: true,
          sessionProtection: true,
          activeProtection: true,
        },
        onSecurityFailed: (error) => {
          console.error('Security verification failed:', error);
        },
        onAttackBlocked: (attack) => {
          console.warn('Attack blocked:', attack);
        },
        onTamperingDetected: (details) => {
          console.warn('Tampering detected:', details);
        },
      }}
      loadingComponent={<CustomLoadingScreen />}
      fallback={<SecurityErrorScreen />}
    >
      <YourApp />
    </SecurityGate>
  );
}

Using Hooks

useSpektre Hook

Access security status and monitoring data throughout your application:

import { useSpektre } from '@spektre/veil';

function SecurityDashboard() {
  const {
    isVerified,
    sessionId,
    protectionEnabled,
    blockedRequests,
    totalBlocked,
    secretExposures,
    scriptProfiles,
    supplyChainAlerts,
    sessionAnomalies,
    runScan,
    getTelemetry,
    getProtectionStats,
  } = useSpektre();

  const handleManualScan = async () => {
    await runScan();
    console.log('Security scan completed');
  };

  return (
    <div>
      <h2>Security Status</h2>
      <p>Verified: {isVerified ? 'Yes' : 'No'}</p>
      <p>Session ID: {sessionId}</p>
      <p>Protection: {protectionEnabled ? 'Active' : 'Inactive'}</p>
      <p>Total Blocked Requests: {totalBlocked}</p>
      <p>Secret Exposures: {secretExposures}</p>
      <p>Script Profiles: {scriptProfiles}</p>
      <p>Supply Chain Alerts: {supplyChainAlerts}</p>
      <p>Session Anomalies: {sessionAnomalies}</p>
      <button onClick={handleManualScan}>Run Security Scan</button>
    </div>
  );
}

useProtectedFetch Hook

Make secure API calls that are only executed after security verification:

import { useProtectedFetch } from '@spektre/veil';

function DataComponent() {
  const fetch = useProtectedFetch();
  const [data, setData] = useState(null);

  const loadData = async () => {
    try {
      const response = await fetch('/api/sensitive-data');
      const json = await response.json();
      setData(json);
    } catch (error) {
      console.error('Fetch failed:', error);
    }
  };

  return (
    <div>
      <button onClick={loadData}>Load Data</button>
      {data && <pre>{JSON.stringify(data, null, 2)}</pre>}
    </div>
  );
}

API Reference

SecurityGate Component

The main component that wraps your application and provides security monitoring.

Props

| Prop | Type | Required | Description | |------|------|----------|-------------| | apiKey | string | Yes | Your Spektre API key from the dashboard | | children | ReactNode | Yes | Your application components | | config | SpektreConfig | No | Configuration options (see below) | | fallback | ReactNode | No | Custom component to show on security failure | | loadingComponent | ReactNode | No | Custom component to show during initialization |

Config Options

interface SpektreConfig {
  // Environment settings
  environment?: 'dev' | 'staging' | 'prod';
  enabledEnvironments?: string[];

  // Security modules
  modules?: {
    performanceMonitoring?: boolean;
    secretDetection?: boolean;
    scriptProfiling?: boolean;
    supplyChainDetection?: boolean;
    sessionProtection?: boolean;
    activeProtection?: boolean;
  };

  // Event handlers
  onSecurityFailed?: (error: string) => void;
  onAttackBlocked?: (attack: BlockedAttack) => void;
  onTamperingDetected?: (details: TamperingDetails) => void;
}

useSpektre Hook

Returns security status and monitoring data.

Return Values

| Property | Type | Description | |----------|------|-------------| | isVerified | boolean | Whether security verification passed | | sessionId | string \| null | Current Spektre session ID | | protectionEnabled | boolean | Whether active protection is enabled | | blockedRequests | BlockedRequest[] | List of blocked malicious requests | | totalBlocked | number | Total count of blocked requests | | secretExposures | number | Number of detected secret exposures | | scriptProfiles | number | Number of profiled scripts | | supplyChainAlerts | number | Number of supply chain alerts | | sessionAnomalies | number | Number of session anomalies detected | | runScan | () => Promise<void> | Manually trigger a security scan | | getTelemetry | () => MonitoringState | Get current monitoring telemetry | | getProtectionStats | () => ProtectionState | Get current protection statistics |

useProtectedFetch Hook

Returns a fetch function that only executes after security verification.

const fetch: ProtectedFetch = useProtectedFetch();

The returned fetch function has the same signature as the native fetch API but throws an error if called before security verification is complete.

Security Modules

Performance Monitoring

Tracks application performance metrics and identifies performance anomalies that could indicate security issues.

Secret Detection

Scans for exposed API keys, tokens, and other sensitive credentials in your application code and network requests.

Script Profiling

Analyzes all scripts loaded by your application to detect malicious or suspicious code.

Supply Chain Detection

Monitors third-party dependencies and detects compromised or vulnerable packages.

Session Protection

Protects user sessions from hijacking, fixation, and other session-based attacks.

Active Protection

Actively blocks malicious requests and attacks in real-time.

Environment Configuration

Control when security monitoring is active:

<SecurityGate
  apiKey="your-api-key"
  config={{
    environment: 'prod',
    enabledEnvironments: ['prod', 'staging'],
  }}
>
  <App />
</SecurityGate>

In this example, security monitoring only runs in production and staging environments. In other environments (like development), the SecurityGate passes through without performing security checks.

Custom UI Components

Custom Loading Screen

<SecurityGate
  apiKey="your-api-key"
  loadingComponent={
    <div className="loading-screen">
      <Spinner />
      <p>Initializing security...</p>
    </div>
  }
>
  <App />
</SecurityGate>

Custom Error Fallback

<SecurityGate
  apiKey="your-api-key"
  fallback={
    <div className="error-screen">
      <h1>Security Verification Failed</h1>
      <p>Please contact support</p>
    </div>
  }
>
  <App />
</SecurityGate>

Links

License

MIT


Built with Spektre - Securing the future of web applications