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

@privacyengine/sdk

v1.1.0

Published

PrivacyEngine Client SDK - Cookie consent banner for Chile's Ley 21.719

Downloads

23

Readme

PrivacyEngine SDK

JavaScript SDK para integración del banner de cookies y consentimiento en sitios web de terceros.

Características

  • Banner de cookies compatible con la Ley 21.719 de Chile
  • Aislamiento de estilos mediante Shadow DOM
  • Integración con Google Consent Mode v2 — actualiza gtag('consent', 'update', ...) cuando el usuario acepta o rechaza
  • Registro de consentimiento en ledger SHA-256
  • Interceptor de formularios para leads
  • API pública para gestión de consentimiento

Instalación

Opción 1: Script tag (CDN)

<script src="https://cdn.privacyengine.cl/pe.js" data-client-id="TU_CLIENT_ID" async></script>

Opción 2: npm

npm install @privacyengine/sdk
import PrivacyEngine from '@privacyengine/sdk';

Opción 3: Descargar

Descarga pe.js directamente y aloja en tu servidor.

Configuración

Atributos del script

| Atributo | Descripción | Requerido | |----------|-------------|-----------| | data-client-id | Identificador único del cliente | Sí | | data-api-host | URL base del API (ej: https://privacyengine.cl) | No |

Ejemplo completo

<script
  src="/pe.js"
  data-client-id="privacyengine-cl"
  data-api-host="https://privacyengine.cl"
  async
></script>

API Pública

Una vez cargado, el SDK expone window.PrivacyEngine:

// Obtener estado actual de consentimiento
PrivacyEngine.getConsent();
// → { essential: true, analytics: false, marketing: false }

// Forzar mostrar banner
PrivacyEngine.showBanner();

// Escuchar cambios de consentimiento
PrivacyEngine.onConsentChange((type, granted) => {
  console.log(`Consentimiento ${type}: ${granted ? 'Concedido' : 'Denegado'}`);
});

Eventos

El SDK dispara eventos personalizados en el document:

| Evento | Descripción | |--------|-------------| | pe_consent_analytics | Consentimiento de cookies analíticas concedido | | pe_consent_marketing | Consentimiento de cookies de marketing concedido |

document.addEventListener('pe_consent_marketing', (e) => {
  console.log('Marketing consent granted:', e.detail);
  // Iniciar pixel de Meta, etc.
});

Formularios de Lead

Para capturar leads con consentimiento, añade el atributo data-pe-form="lead" a tus formularios:

<form data-pe-form="lead" action="/submit" method="POST">
  <input type="email" name="email" placeholder="Tu email" required>
  <button type="submit">Enviar</button>
</form>

El SDK automáticamente:

  1. Añade checkboxes de consentimiento legal
  2. Valida que se acepte la política de privacidad
  3. Registra el email para el ledger de auditoría

CSS Personalizado

El banner usa Shadow DOM, por lo que los estilos de tu página no lo afectan. Para personalizar, puedes recompilar el SDK con tus estilos en src/pe.js.

Cookies

El SDK crea las siguientes cookies:

| Cookie | Descripción | Duración | |--------|-------------|----------| | pe_consent | Preferencia de consentimiento (JSON) | 365 días |

Compatibilidad

  • Chrome 56+
  • Firefox 52+
  • Safari 10.1+
  • Edge 79+
  • IE 11 (con polyfills)

Licencia

MIT License - Copyright 2024 PrivacyEngine

Soporte

Para soporte técnico: [email protected]