@funnelsgrove/payments 0.1.25 → 0.1.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -527,12 +527,50 @@ export const resolveCheckoutPlanRecurringConfig = (plan) => {
|
|
|
527
527
|
inferCheckoutPlanRecurringFromText(plan.id) ||
|
|
528
528
|
inferCheckoutPlanRecurringFromText(plan.description));
|
|
529
529
|
};
|
|
530
|
-
const
|
|
531
|
-
|
|
530
|
+
const SENSITIVE_CHECKOUT_URL_QUERY_KEYS = new Set([
|
|
531
|
+
'customeremail',
|
|
532
|
+
'customer_email',
|
|
533
|
+
'email',
|
|
534
|
+
'fullname',
|
|
535
|
+
'full_name',
|
|
536
|
+
'name',
|
|
537
|
+
'phone',
|
|
538
|
+
'phonenumber',
|
|
539
|
+
'phone_number',
|
|
540
|
+
]);
|
|
541
|
+
const sanitizeCheckoutUrl = (value) => {
|
|
542
|
+
if (typeof value !== 'string') {
|
|
543
|
+
return undefined;
|
|
544
|
+
}
|
|
545
|
+
const trimmed = value.trim();
|
|
546
|
+
if (!trimmed) {
|
|
532
547
|
return undefined;
|
|
533
548
|
}
|
|
534
|
-
|
|
535
|
-
|
|
549
|
+
try {
|
|
550
|
+
const parsed = new URL(trimmed, typeof window !== 'undefined' ? window.location.origin : 'https://example.invalid');
|
|
551
|
+
for (const key of Array.from(parsed.searchParams.keys())) {
|
|
552
|
+
if (SENSITIVE_CHECKOUT_URL_QUERY_KEYS.has(key.trim().toLowerCase())) {
|
|
553
|
+
parsed.searchParams.delete(key);
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
return parsed.toString();
|
|
557
|
+
}
|
|
558
|
+
catch (_a) {
|
|
559
|
+
return trimmed;
|
|
560
|
+
}
|
|
561
|
+
};
|
|
562
|
+
const currentCheckoutUrl = () => {
|
|
563
|
+
var _a;
|
|
564
|
+
if (typeof window === 'undefined') {
|
|
565
|
+
return undefined;
|
|
566
|
+
}
|
|
567
|
+
return sanitizeCheckoutUrl((_a = window.location) === null || _a === void 0 ? void 0 : _a.href);
|
|
568
|
+
};
|
|
569
|
+
const normalizeAnalyticsMetadata = (metadata) => {
|
|
570
|
+
const normalized = Object.fromEntries(Object.entries(isRecord(metadata) ? metadata : {}).filter(([, value]) => value !== undefined && value !== null && value !== ''));
|
|
571
|
+
const checkoutUrl = sanitizeCheckoutUrl(normalized.url) || currentCheckoutUrl();
|
|
572
|
+
const withCheckoutUrl = checkoutUrl ? Object.assign(Object.assign({}, normalized), { url: checkoutUrl }) : normalized;
|
|
573
|
+
return Object.keys(withCheckoutUrl).length > 0 ? withCheckoutUrl : undefined;
|
|
536
574
|
};
|
|
537
575
|
export async function createStripePaymentIntent(input) {
|
|
538
576
|
var _a, _b;
|