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

@qt-test/apex-bridge

v0.1.0

Published

Bridge protocol types and utilities for APEX mini-app platform

Readme

@interswitch/apex-bridge

Bridge protocol types and utilities for APEX mini-app platform

This package provides the core TypeScript types, validation utilities, and permission system for the APEX JS-Native bridge protocol.

Installation

npm install @interswitch/apex-bridge
# or
yarn add @interswitch/apex-bridge

Usage

Message Types

import {
  BridgeRequest,
  BridgeResponse,
  BridgeEvent,
  createRequest,
  createSuccessResponse,
  createErrorResponse,
} from '@interswitch/apex-bridge';

// Create a request
const request = createRequest('device', 'vibrate', { duration: 100 });
// {
//   version: '1.0.0',
//   callbackId: 'cb_1234567890_abc',
//   namespace: 'device',
//   method: 'vibrate',
//   params: { duration: 100 },
//   timestamp: 1234567890
// }

// Create a success response
const response = createSuccessResponse(request.callbackId, { vibrated: true });

// Create an error response
const error = createErrorResponse(request.callbackId, 'PERMISSION_DENIED');

Namespace Types

import { Device, Storage, Payment } from '@interswitch/apex-bridge';

// Typed parameters
const vibrateParams: Device.VibrateParams = {
  duration: 100,
  pattern: 'light',
};

// Typed responses
const deviceInfo: Device.GetInfoResponse = {
  platform: 'ios',
  osVersion: '16.4',
  model: 'iPhone 14 Pro',
  // ...
};

Validation

import {
  validateVibrateParams,
  validateStorageSetParams,
  validatePaymentRequestParams,
} from '@interswitch/apex-bridge';

const result = validatePaymentRequestParams({
  amount: 5000,
  currency: 'NGN',
  description: 'Test payment',
});

if (!result.valid) {
  console.error(result.error?.message);
}

Permissions

import {
  checkPermission,
  getRequiredPermission,
  isUrlAllowed,
} from '@interswitch/apex-bridge';

// Check what permission a method needs
const permission = getRequiredPermission('location', 'get');
// 'location'

// Check if a URL is allowed
const allowed = isUrlAllowed(
  'https://api.example.com/data',
  'request',
  { request: ['api.example.com'] }
);
// true

API Reference

Message Functions

| Function | Description | |----------|-------------| | createRequest(namespace, method, params) | Create a bridge request | | createSuccessResponse(callbackId, data) | Create a success response | | createErrorResponse(callbackId, code, details?) | Create an error response | | createEvent(namespace, event, data) | Create an event message | | generateCallbackId() | Generate a unique callback ID |

Type Guards

| Function | Description | |----------|-------------| | isBridgeResponse(message) | Check if message is a response | | isBridgeEvent(message) | Check if message is an event |

Validators

| Function | Description | |----------|-------------| | validateString(value, field, options?) | Validate string with length limits | | validateNumber(value, field, options?) | Validate number with min/max | | validateBoolean(value, field) | Validate boolean | | validateEnum(value, field, allowed) | Validate against allowed values | | validateUrl(value, field) | Validate URL format | | validateRequired(obj, fields) | Check required fields exist |

Permission Functions

| Function | Description | |----------|-------------| | checkPermission(namespace, method, checker) | Check if call is allowed | | getRequiredPermission(namespace, method) | Get required permission | | requiresExplicitConsent(permission) | Check if needs user prompt | | requiresBiometric(permission) | Check if needs biometric | | isUrlAllowed(url, type, domains) | Check URL against allowlist |

Namespaces

All bridge API types are organized by namespace:

  • Device - Device info, vibration, screen
  • Storage - Key-value storage
  • Network - HTTP requests
  • UI - Toast, modal, navigation bar
  • Location - GPS, geolocation
  • Media - Camera, images, video
  • Auth - Biometrics, user info
  • Payment - Payment requests, wallet
  • Clipboard - Copy/paste

Error Codes

| Code | Description | |------|-------------| | PERMISSION_DENIED | Missing required permission | | INVALID_PARAMS | Parameter validation failed | | NOT_SUPPORTED | Feature not available | | TIMEOUT | Operation timed out | | NETWORK_ERROR | Network request failed | | USER_CANCELLED | User cancelled operation | | SYSTEM_ERROR | Internal error | | RATE_LIMITED | Too many requests | | PAYMENT_FAILED | Payment processing failed | | PAYMENT_CANCELLED | User cancelled payment |

License

MIT