UNPKG

@cedros/pay-react

Version:

React frontend library for Cedros Pay - unified Stripe and Solana x402 payments

2 lines (1 loc) 2.25 kB
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./uuid-C0iMjdcc.js");var c=(e=>(e.DEBUG="debug",e.INFO="info",e.WARNING="warning",e.ERROR="error",e.CRITICAL="critical",e))(c||{});let r={enabled:!1,sanitizePII:!0};function f(e){r={...r,...e}}function m(){return{...r}}function g(){const e=Date.now(),t=l.generateUUID().slice(0,12);return`cedros_${e}_${t}`}const z=[/\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b/g,/\b(\+?\d{1,3}[-.\s]?)?\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}\b/g,/\b\d{4}[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}\b/g,/\b\d{3}-\d{2}-\d{4}\b/g,/\b(?:\d{1,3}\.){3}\d{1,3}\b/g,/\b[1-9A-HJ-NP-Za-km-z]{87,88}\b/g,/\b[1-9A-HJ-NP-Za-km-z]{32,44}\b/g,/\b0x[a-fA-F0-9]{64}\b/g,/\b0x[a-fA-F0-9]{40}\b/g,/\b([a-z]+\s+){11,23}[a-z]+\b/gi,/\beyJ[a-zA-Z0-9_-]+\.eyJ[a-zA-Z0-9_-]+\.[a-zA-Z0-9_-]+\b/g,/\b(sk|pk|api|secret|key)_[a-zA-Z0-9]{16,128}\b/gi,/\bsk_(test|live)_[a-zA-Z0-9]{24,}\b/g,/\b[1-9A-HJ-NP-Za-km-z]{86,90}\b/g,/\b[A-Za-z0-9+/]{100,}={0,2}\b/g,/\b[a-fA-F0-9]{64,}\b/g];function o(e){if(!r.enabled||!r.sanitizePII)return e;let t=e;for(const n of z)t=t.replace(n,"[REDACTED]");return t}function d(e){const t=new Error(o(e.message));return t.name=e.name,e.stack&&(t.stack=o(e.stack)),t}function b(e,t={}){const n=typeof e=="string"?new Error(e):e,a=r.sanitizePII?d(n):n,s=Date.now();return{correlationId:t.correlationId||g(),timestamp:s,timestampISO:new Date(s).toISOString(),severity:t.severity||"error",code:t.code,message:a.message,error:a,stack:a.stack,paymentContext:t.paymentContext,userAgent:typeof navigator<"u"?navigator.userAgent:void 0,sdkVersion:r.sdkVersion,environment:r.environment,tags:{...r.globalTags,...t.tags}}}function u(e,t){if(!r.enabled||!r.onError)return;const n=typeof e=="object"&&"correlationId"in e?e:b(e,t||{});try{r.onError(n)}catch(i){console.error("[CedrosPay] Telemetry hook failed:",i)}}function I(e){return(t,n={})=>{u(t,{...n,tags:{...e,...n.tags}})}}function A(){r={enabled:!1,sanitizePII:!0}}exports.ErrorSeverity=c;exports.configureTelemetry=f;exports.createErrorReporter=I;exports.enrichError=b;exports.generateCorrelationId=g;exports.getTelemetryConfig=m;exports.reportError=u;exports.resetTelemetry=A;exports.sanitizeError=d;exports.sanitizePII=o;