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

@debridge-finance/borderless-validation-sdk

v0.10.0

Published

Validation SDK for deBridge borderless intents API responses

Readme

@debridge-finance/borderless-validation-sdk

Validation SDK for deBridge borderless intents API (POST /v1.0/bundle) responses.

Purpose

When a user submits a bundle request to the deBridge API, the response contains transactions and signable payloads (EIP-712 messages, permits, Solana transactions, etc.) that the user is expected to sign.

Every field the user signs is a potential attack vector. If the API is compromised (MITM, server bug, malicious rewrite), the user could unknowingly sign a transaction that drains their funds.

This SDK runs on the client before signing. It validates the response structure and checks signable payloads against the original request, protocol invariants, and environment-specific whitelists.

Threats mitigated

  • MITM attacks against the API endpoint.
  • Bugs on the API side that produce subtly wrong responses.
  • Reduced API trust — the client no longer has to take API responses on faith.
  • Regression safety net when testing new API versions.

Installation

npm install @debridge-finance/borderless-validation-sdk

Declared peer dependency ranges:

  • @solana/web3.js >= 1.90.0
  • bs58 >= 5.0.0
  • viem >= 2.0.0
  • zod ^3.0.0 || ^4.0.0

Basic usage

import {
    createValidator,
    Environment,
    ViolationCode,
} from "@debridge-finance/borderless-validation-sdk";

const validator = createValidator({ environment: Environment.Prod });

const url = "https://cross-chain-api.debridge.finance/v1.0/bundle";

const response = await fetch(url, {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify(request),
}).then(res => res.json());

const result = validator.validate(url, request, response);

if (!result.ok) {
    if (result.violations.some(v => v.code === ViolationCode.HigherApiVersion)) {
        // Special case: the API response was produced for a newer validation
        // version than this SDK supports. The SDK cannot reliably validate it.
        // Decide in your app whether to block, warn, update the SDK, or use
        // another fallback flow.
        console.error("API validation version is newer than SDK support:", result.violations);
        return;
    }

    if (result.violations.some(v => v.code === ViolationCode.UnexpectedValidationError)) {
        // Special case: this indicates an internal Validation SDK error.
        // The client app must decide how to handle it: block signing, report
        // telemetry, retry after SDK update, or use another fallback flow.
        console.error("Validation SDK internal error:", result.violations);
        return;
    }

    console.error("Validation failed:", result.violations);
    // Do NOT let the user sign anything.
    return;
}

// Safe to proceed with signing.

API

createValidator(config: ValidatorConfig): Validator

type ValidatorConfig = {
    environment: Environment;
};

type Validator = {
    validate(url: string, request: object, response: object): ValidationResult;
};

type ValidationResult = {
    ok: boolean;             // true if no violations
    violations: Violation[]; // all issues found
};

type Violation = {
    code: ViolationCode;     // machine-readable identifier
    message: string;         // human-readable description
    path: string;            // JSON path of the offending field
    expected?: unknown;      // the value the validator expected (concrete, comparable to `actual`)
    actual?: unknown;        // the value found in the response (concrete, comparable to `expected`)
    details?: unknown;       // extra machine-readable context (e.g. caught error object)
};

validator.validate() never throws — every error condition is reported as a Violation. Safe to call in any code path.

Integration guide for UI teams

The SDK is designed to run between receiving the API response and presenting it to the user for signing. Wire it into that seam.

1. Where to call

┌───────────────┐     ┌─────────┐     ┌────────────────────┐     ┌───────────────┐
│ Build request │ ──▶ │ fetch() │ ──▶ │ validator.validate │ ──▶ │ Sign / submit │
└───────────────┘     └─────────┘     └────────────────────┘     └───────────────┘
                                              │
                                              ▼
                                     ok ? proceed : block
  • Before validate: the user has not yet seen or signed anything.
  • After validate: if result.ok === false, do not forward any signable payload (intent message, permit, transaction) to the wallet. The API response cannot be trusted.

2. Choosing the environment

import { Environment } from "@debridge-finance/borderless-validation-sdk";
  • Environment.Prod — production without gasless features.
  • Environment.Gasless — production with gasless features.
  • Environment.Dev — developer environment (also known as Stage).

Pass the same environment your app is already configured for — don't make it user-selectable.

3. Pass the exact URL you called

const url = "https://cross-chain-api.debridge.finance/v1.0/bundle";
const response = await fetch(url, { ... });
const result = validator.validate(url, request, response);

The url argument is accepted for API compatibility and future endpoint checks. Pass the same string you handed to fetch; do not rely on URL validation until it is explicitly enabled in a release.

4. Handling violations

On result.ok === false:

  1. Block the signing flow. Do not show a wallet popup or write any pending tx to state.
  2. Log the full violations array to your error reporting system (Sentry / Datadog / etc.). Include code, path, expected, actual, details.
  3. Show the user a generic error. Do not leak raw Violation data into the UI — messages are for developers, not end-users. A single "Quote is invalid, please retry" is enough.
  4. Do not retry automatically. If the API is compromised, retries make it worse. Let the user manually trigger a retry.

5. Browser compatibility

The SDK is published as both CJS and ESM and uses only browser-compatible APIs (no fs, crypto, Buffer, process).

Tree-shaking: the ESM build preserves named exports. Importing only createValidator will not pull in unused validators.

6. Bundle size

Roughly 1 MB unpacked (a lot of it is source maps — drop them in production). The heaviest peer dep is @solana/web3.js; if your app only deals with EVM trades, your bundler's tree-shaking should eliminate most of it.

7. TypeScript

Full type declarations ship in dist/types/. ValidatorConfig, ValidationResult, Violation, and ViolationCode are all exported — use them directly, don't re-declare.

8. What NOT to do

  • ❌ Don't skip validation because "the API is our own." Compromise detection is the whole point.
  • ❌ Don't mutate request or response between the API call and validate() — the validator needs the exact payload the user received.
  • ❌ Don't interpret violations[].message programmatically — message wording may change between versions. Branch on code instead.
  • ❌ Don't cache the validator if environment changes. Create a new instance via createValidator for each environment.

Development

For repository development, testing, releases, and Java parity checks, see the development guide.

License

BUSL-1.1