Docs
SDK de JavaScript
Instalación, cliente, métodos, control de etiquetas y verificación de justificantes.
npm i @tripticonsent/sdkCliente
import { TripticonsentClient } from '@tripticonsent/sdk';
const tc = new TripticonsentClient({
baseUrl: 'https://api.tripticonsent.com',
apiKey: 'pk_live_…', // sk_live_… en servidor
cacheTtlMs: 60_000, // opcional
});Métodos
recordConsent(params, { idempotencyKey })·recordConsentBatch(records)·recordPreferences(params)getConsentState(subject, { purpose?, fresh? })·getPreferences(subject): cacheados con ETaggetPurposes({ locale? })·getPurpose(key, { locale? })·getPreferenceTemplate()·getPolicy({ country? })getTcString(subject)·getConsentMode(subject)·applyConsentMode(subject, gtag)getReceipt(id)·verifyReceipt(receipt): Ed25519 sin conexión mediante Web CryptocreateSubject·addIdentifier·mergeSubjects·createDataRequest: requierensk_
Control de etiquetas
// carga tus scripts solo cuando el sujeto ha concedido alguno de estos propósitos
await tc.gate('email:user@example.com', ['analytics'], () => loadAnalytics());
// después de que tu banner escriba consentimiento nuevo:
tc.notifyConsentChanged();