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

@mdpsdk/mdp-sdk

v0.3.7

Published

Mesa de Pagos SDK — auth y onboarding Persona/Borderless (BYOK)

Readme

@mdp/sdk

SDK de Mesa de Pagos — auth + onboarding hacia Persona y Borderless (BYOK).

Instalación

npm install @alvarochaval/mdp-sdk

Variables de entorno

Auth (obligatorias)

| Variable | Descripción | |----------|-------------| | PERSONA_API_KEY | API key Persona | | PERSONA_API_URL | Default: https://api.withpersona.com/api/v1/ | | BORDERLESS_API_URL | Base URL Borderless | | BORDERLESS_CLIENT_ID | M2M client id | | BORDERLESS_CLIENT_SECRET | M2M secret |

Onboarding (obligatorias para sdk.onboarding)

| Variable | Descripción | |----------|-------------| | PERSONA_API_TEMPLATE_PERSONA | Template inquiry KYC personal | | PERSONA_API_TEMPLATE_BUSINESS_DEFAULT | KYB empresa — país distinto de CL/US/ES/AR/BR o sin address.country | | PERSONA_API_TEMPLATE_BUSINESS_CL | KYB Chile | | PERSONA_API_TEMPLATE_BUSINESS_US | KYB USA | | PERSONA_API_TEMPLATE_BUSINESS_ES | KYB España | | PERSONA_API_TEMPLATE_BUSINESS_AR | KYB Argentina | | PERSONA_API_TEMPLATE_BUSINESS_BR | KYB Brasil |

Compatibilidad: si no defines PERSONA_API_TEMPLATE_BUSINESS_DEFAULT, se usa PERSONA_API_TEMPLATE_BUSISNESS o PERSONA_API_TEMPLATE_BUSINESS.

En start({ type: 'business', profile: { address: { country: 'CL' } } }) se elige el template según ISO 3166-1 alpha-2 del país.

Sincronizar campos al inquiry Persona (PATCH)

En start el email es obligatorio (email en el body o profile.email). Tras crear el inquiry el SDK siempre guarda el email en Persona (email-address + email_address para personal). En submit-eu-us no hace falta repetir el email.

| Campo integrador | Key Persona (personal) | Key Persona (business) | |------------------|------------------------|-------------------------| | email | email_address | form_filler_email_address | | phone | phone_number | input_phone_number | | firstName / legalName | name_first / — | business_name | | lastName | name_last | — | | taxId | identification_number | business_tax_identification_number | | address.* | address_street_1, … | business_physical_address_* |

Override por template: createMdpSdk({ onboarding: { personaFieldMaps: { personal: { email: 'mi_campo_email' } } } }).

Sin email en inquiry ni en profile → ONBOARDING_MISSING_EMAIL antes de llamar a Borderless.

Uso

import { createMdpSdk } from '@alvarochaval/mdp-sdk'

const sdk = createMdpSdk()

// --- Fase 1: verificación básica (personal) ---
const { inquiryId, verificationUrl } = await sdk.onboarding.start({
  type: 'personal',
  externalCustomerId: 'cust_123',
  profile: { email: '[email protected]' }
})
// Guardar en TU BD: inquiryId, externalCustomerId

const status = await sdk.onboarding.getStatus({
  externalCustomerId: 'cust_123',
  inquiryId,
  type: 'personal'
})

// --- Fase 2: Europa/EE.UU. (opt-in) — paso 1: identidad + documentos + términos ---
const euUs = await sdk.onboarding.submitEuUs({
  externalCustomerId: 'cust_123',
  inquiryId,
  input: {
    target: 'person',
    operationType: 'send' // opcional; email desde inquiry (profile en start)
  }
})
// Guardar euUs.identityId; revisar euUs.documentUpload (éxito parcial no aborta el flujo)
// Enviar euUs.termsOfServiceUrl al usuario

// Usuario acepta términos en Borderless (sin webhook)

// --- paso 2: tras aceptar TOS ---
await sdk.onboarding.activateComplianceCheck({
  identityId: euUs.identityId
})

// Renovar URL de términos si hace falta:
await sdk.onboarding.getTermsOfServiceUrl({
  externalCustomerId: 'cust_123',
  identityId: euUs.identityId,
  country: 'US',
  regenerate: true
})

API pública

  • createMdpSdk(){ auth, onboarding }
  • Tipos exportados desde el paquete (OnboardingStartInput, OnboardingStatusResponse, etc.)
  • OnboardingError para errores con code y retryable

sdk.onboarding

| Método | Descripción | |--------|-------------| | start | Inquiry Persona + verificationUrl | | getVerificationUrl | Renovar enlace (requiere inquiryId) | | getStatus | Estado básico + EU/US (requiere inquiryId; identityId?) | | submitEuUs | Fase 2: identidad Borderless + documentos desde Persona included + URL términos | | activateComplianceCheck | Tras aceptar TOS: refresca compliance (idempotente si ya existe) | | getTermsOfServiceUrl | Obtener o regenerar URL términos (regenerate?, country?) | | listOwners | Socios KYB (requiere businessInquiryId + mapas opcionales de ids) | | getOwnerVerificationUrl | Enlace básico del socio | | getOwnerStatus | Estado del socio | | saveOwnerOccupation | Dato auxiliar (memoria del proceso) | | handleWebhook | Normalizar evento Persona/Borderless | | syncOwnerStatus | Debug: estado inquiry |

Qué guardar en la BD del integrador

| Dato | Cuándo | |------|--------| | externalCustomerId | Siempre (tu PK) | | inquiryId | Tras start | | identityId | Tras submitEuUs | | ownerIdownerInquiryId / ownerIdentityId | KYB, por socio |

KYB (resumen)

  1. start({ type: 'business', ... })
  2. Representante completa KYB → listOwners({ businessInquiryId, ownerInquiryIds? })
  3. Por socio: getOwnerVerificationUrl / submitEuUs({ target: 'person', ownerId, ownerInquiryId })
  4. Cuando canSubmitBusiness: submitEuUs({ target: 'business', ownerBorderlessIdentityIds: [...] })

Scripts

npm run build
npm test

Documentación

OpenAPI: docs/openapi/mdp-onboarding-sdk.yaml en el monorepo MDP.