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

@swig-wallet/developer

v1.0.0

Published

TypeScript SDK for the Swig Portal API with rich SDK types and query methods.

Readme

@swig-wallet/developer

TypeScript SDK for the Swig Portal API with rich SDK types and query methods.

Installation

npm install @swig-wallet/developer
# or
bun install @swig-wallet/developer

Features

  • Single unified client: SwigClient for all Portal operations
  • Rich SDK types: Converts API responses to SDK types with query methods
  • AuthorityInfo: Wrapper with type checking methods
  • Actions queries: canSpendSol(), isRoot(), canUseProgram(), and more
  • Throws errors: Uses SwigError for error handling
  • Retry logic: Automatic retries with exponential backoff

Usage

import { SwigClient, SwigError } from '@swig-wallet/developer';

const client = new SwigClient({
  apiKey: 'sk_xxx...',
  baseUrl: 'https://dashboard.onswig.com',
});

try {
  // Get policy with rich SDK types
  const policy = await client.getPolicy('policy-id');

  console.log(policy.name);

  // Authority is an AuthorityInfo instance
  if (policy.authority) {
    console.log('Authority type:', policy.authority.type);

    if (policy.authority.isSession()) {
      console.log(
        'Session duration:',
        policy.authority.maxDurationSlots,
        'slots',
      );
    }
  }

  // Query permissions using SDK methods
  if (policy.actions.canSpendSol(100_000n)) {
    console.log('Can spend 100k lamports');
  }

  const solLimit = policy.actions.solSpendLimit();
  console.log('SOL limit:', solLimit);

  if (
    policy.actions.canUseProgram('TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA')
  ) {
    console.log('Can interact with Token program');
  }

  // Create wallet
  const wallet = await client.createWallet({
    policyId: 'policy-id',
    network: 'mainnet',
    paymasterPubkey: 'PaymasterPubkey...',
  });

  console.log('Wallet address:', wallet.swigAddress);
} catch (error) {
  if (error instanceof SwigError) {
    console.error('API Error:', error.code, error.message);
  }
}

Error Handling

This SDK throws errors instead of returning { data, error }:

import { SwigClient, SwigError } from '@swig-wallet/developer';

try {
  const policy = await client.getPolicy('policy-id');
  // Use policy...
} catch (error) {
  if (error instanceof SwigError) {
    console.error('Code:', error.code); // e.g., 'POLICY_NOT_FOUND'
    console.error('Status:', error.statusCode); // e.g., 404
    console.error('Message:', error.message);
  }
}

API Reference

SwigClient

| Method | Description | | ----------------------- | ---------------------------------- | | getPolicy(id) | Get a policy with SDK types | | createWallet(request) | Create a Swig wallet from a policy |

Policy

The Policy model has:

  • id, name - policy metadata
  • authority: AuthorityInfo | null - authority configuration
  • actions: Actions - permissions with query methods

Actions (via policy.actions)

| Method | Description | | ------------------------------ | ------------------------------------ | | isRoot() | Check if policy has root permissions | | canManageAuthority() | Check if can manage authority | | canSpendSol(amount?) | Check SOL spend permission | | solSpendLimit() | Get SOL spend limit | | canSpendToken(mint, amount?) | Check token spend permission | | canUseProgram(programId) | Check program access |

AuthorityInfo (via policy.authority)

| Method | Description | | --------------- | -------------------------- | | isSession() | Check if session authority | | isEd25519() | Check if Ed25519 type | | isSecp256k1() | Check if Secp256k1 type | | isSecp256r1() | Check if Secp256r1 type |

License

AGPL-3.0