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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@nmipayments/nmi-core

v1.0.0-beta.3

Published

NMI Embedded Components Core Utilities

Downloads

1,253

Readme

@nmipayments/nmi-core

Core utilities and shared types for NMI Embedded Components

Overview

@nmipayments/nmi-core is a foundational package that provides shared utilities, types, themes, and services used across all NMI Embedded Components. It serves as the common foundation for both Svelte and React implementations of NMI payment and reporting components.

Installation

npm install @nmipayments/nmi-core

What's Included

Types

  • Payment Types: Payment method definitions, layout configurations, and API interfaces
  • Appearance Types: Theme and styling configurations
  • Core API Types: Token requests/responses and common data structures

Utilities

  • fetchUtils: HTTP client utilities for API communication
  • themeUtils: Theme application and CSS variable management
  • densityUtils: Layout density and spacing calculations

Themes

  • Default Themes: Pre-built light and dark themes
  • Theme System: Extensible theming architecture with CSS custom properties

Services

  • tokenService: Token validation and management utilities

Usage

Types

import type { 
  PaymentMethod, 
  Appearance, 
  NmiTokenRequest,
  NmiTokenResponse,
  LayoutType 
} from '@nmipayments/nmi-core';

const paymentConfig: {
  methods: PaymentMethod[];
  layout: LayoutType;
  appearance: Appearance;
} = {
  methods: ['card', 'ach'],
  layout: 'multiLine',
  appearance: {
    theme: 'light',
    layoutSpacing: 'default'
  }
};

Utilities

import { fetchUtils, themeUtils } from '@nmipayments/nmi-core';

// HTTP utilities
const response = await fetchUtils.post('/api/tokens', {
  amount: 1000,
  currency: 'USD'
});

// Theme utilities
themeUtils.applyTheme(document.body, {
  theme: 'dark',
  primaryColor: '#8b5cf6'
});

Themes

import { themes } from '@nmipayments/nmi-core';

// Access pre-built themes
const lightTheme = themes.light;
const darkTheme = themes.dark;

// Create custom theme
const customTheme = {
  ...themes.light,
  primaryColor: '#8b5cf6',
  borderRadius: '8px'
};

Services

import { tokenService } from '@nmipayments/nmi-core';

// Validate tokenization key format
const isValid = tokenService.validateTokenizationKey('your-key');

// Extract environment from key
const environment = tokenService.getEnvironment('your-key');

API Reference

PaymentMethod

type PaymentMethod = 'card' | 'ach' | 'apple-pay' | 'google-pay';

LayoutType

type LayoutType = 'singleLine' | 'multiLine' | 'stacked';

Appearance

interface Appearance {
  theme?: 'light' | 'dark';
  layoutSpacing?: 'compact' | 'default' | 'spacious';
  textSize?: 'small' | 'default' | 'large';
  radiusSize?: 'none' | 'small' | 'default' | 'large';
  primaryColor?: string;
  backgroundColor?: string;
  borderColor?: string;
  textColor?: string;
}

NmiTokenRequest

interface NmiTokenRequest {
  tokenization_key: string;
  amount?: string;
  currency?: string;
  [key: string]: any;
}

Framework Compatibility

This package is framework-agnostic and provides utilities that work in:

  • Vanilla JavaScript/TypeScript
  • Svelte (used by @nmipayments/nmi-pay and @nmipayments/nmi-reporting)
  • React (used by React wrapper packages)
  • Vue (future compatibility)
  • Angular (future compatibility)

Bundle Information

  • Format: ES modules and CommonJS
  • Tree-shakeable: Yes, import only what you need
  • TypeScript: Full TypeScript support with declaration files
  • Dependencies: Zero runtime dependencies

Architecture

This package follows a modular architecture where each feature is separated into its own directory:

src/
├── types/          # TypeScript type definitions
├── utils/          # Utility functions
├── themes/         # Theme definitions
├── services/       # Shared services
└── index.ts        # Main export file

License

MIT