@paypal/checkout-components 5.0.433 → 5.0.434
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.
package/package.json
CHANGED
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
noop,
|
|
26
26
|
supportsPopups,
|
|
27
27
|
inlineMemoize,
|
|
28
|
+
stringifyError,
|
|
28
29
|
} from "@krakenjs/belter/src";
|
|
29
30
|
import { FUNDING } from "@paypal/sdk-constants/src";
|
|
30
31
|
import {
|
|
@@ -42,6 +43,50 @@ import { DEFAULT_POPUP_SIZE } from "./config";
|
|
|
42
43
|
|
|
43
44
|
export type CheckoutComponent = ZoidComponent<CheckoutPropsType>;
|
|
44
45
|
|
|
46
|
+
const WINDOW_NAME_LOG_TRUNCATION_LENGTH = 50;
|
|
47
|
+
// Matches window names zoid itself writes, eg `__zoid__paypal_checkout__<payload>__`.
|
|
48
|
+
// See buildChildWindowName in @krakenjs/zoid.
|
|
49
|
+
const ZOID_WINDOW_NAME_PATTERN = /^__zoid__.+__$/;
|
|
50
|
+
|
|
51
|
+
function spyOnWindowNameAssignment(): void {
|
|
52
|
+
try {
|
|
53
|
+
let currentWindowName = window.name;
|
|
54
|
+
|
|
55
|
+
Object.defineProperty(window, "name", {
|
|
56
|
+
configurable: true,
|
|
57
|
+
get(): string {
|
|
58
|
+
return currentWindowName;
|
|
59
|
+
},
|
|
60
|
+
set(value: string): void {
|
|
61
|
+
if (ZOID_WINDOW_NAME_PATTERN.test(value)) {
|
|
62
|
+
currentWindowName = value;
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
getLogger().error("checkout_window_name_overwritten", {
|
|
67
|
+
err: stringifyError(
|
|
68
|
+
new Error(
|
|
69
|
+
`window.name was overwritten: ${String(value).slice(
|
|
70
|
+
0,
|
|
71
|
+
WINDOW_NAME_LOG_TRUNCATION_LENGTH,
|
|
72
|
+
)}`,
|
|
73
|
+
),
|
|
74
|
+
),
|
|
75
|
+
originalValue: String(currentWindowName).slice(
|
|
76
|
+
0,
|
|
77
|
+
WINDOW_NAME_LOG_TRUNCATION_LENGTH,
|
|
78
|
+
),
|
|
79
|
+
});
|
|
80
|
+
currentWindowName = value;
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
} catch (error) {
|
|
84
|
+
getLogger().error("checkout_window_name_spy_error", {
|
|
85
|
+
err: stringifyError(error),
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
45
90
|
export function getCheckoutComponent(): CheckoutComponent {
|
|
46
91
|
return inlineMemoize(getCheckoutComponent, () => {
|
|
47
92
|
const component = create({
|
|
@@ -382,6 +427,8 @@ export function getCheckoutComponent(): CheckoutComponent {
|
|
|
382
427
|
});
|
|
383
428
|
|
|
384
429
|
if (component.isChild()) {
|
|
430
|
+
spyOnWindowNameAssignment();
|
|
431
|
+
|
|
385
432
|
window.xchild = {
|
|
386
433
|
props: component.xprops,
|
|
387
434
|
show: noop,
|