@paypal/checkout-components 5.0.349 → 5.0.350

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paypal/checkout-components",
3
- "version": "5.0.349",
3
+ "version": "5.0.350",
4
4
  "description": "PayPal Checkout components, for integrating checkout products.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -8,7 +8,6 @@ import {
8
8
  } from "@paypal/sdk-client/src";
9
9
  import { destroy as zoidDestroy } from "@krakenjs/zoid/src";
10
10
 
11
- import { devEnvOnlyExport } from "../lib";
12
11
  import type { LazyExport } from "../types";
13
12
 
14
13
  import {
@@ -46,9 +45,9 @@ export const ThreeDomainSecureClient: LazyExport<ThreeDomainSecureComponentInter
46
45
  clientID: getClientID(),
47
46
  },
48
47
  });
49
- return devEnvOnlyExport({
48
+ return {
50
49
  isEligible: (payload) => threeDomainSecureInstance.isEligible(payload),
51
50
  show: () => threeDomainSecureInstance.show(),
52
- });
51
+ };
53
52
  },
54
53
  };
@@ -43,6 +43,7 @@ import {
43
43
  getJsSdkLibrary,
44
44
  wasShopperInsightsUsed,
45
45
  isPayPalTrustedUrl,
46
+ getSDKInitTime,
46
47
  } from "@paypal/sdk-client/src";
47
48
  import {
48
49
  rememberFunding,
@@ -303,7 +304,7 @@ export const getButtonsComponent: () => ButtonsComponent = memoize(() => {
303
304
  type: "function",
304
305
  sendToChild: true,
305
306
  value: () => (url) => {
306
- if (isPayPalTrustedUrl(url)) {
307
+ if (getEnv() === ENV.LOCAL || isPayPalTrustedUrl(url)) {
307
308
  location.href = url;
308
309
  } else {
309
310
  throw new Error(`Unable to redirect to provided url ${url}`);
@@ -1067,6 +1068,47 @@ export const getButtonsComponent: () => ButtonsComponent = memoize(() => {
1067
1068
  queryParam: true,
1068
1069
  },
1069
1070
 
1071
+ sdkInitTimings: {
1072
+ type: "object",
1073
+ queryParam: false,
1074
+ required: false,
1075
+ value: () => {
1076
+ // eslint-disable-next-line compat/compat
1077
+ const sdkScript = window?.performance
1078
+ ?.getEntriesByType("resource")
1079
+ // eslint-disable-next-line security/detect-unsafe-regex
1080
+ .find(({ name }) => /paypal\.com(?::\d+)?\/sdk\/js/.test(name));
1081
+
1082
+ const isCached = (performanceEntry) => {
1083
+ if (
1084
+ !performanceEntry ||
1085
+ typeof performanceEntry.duration === "undefined"
1086
+ ) {
1087
+ return "unknown";
1088
+ }
1089
+
1090
+ return performanceEntry.duration === 0 ? "yes" : "no";
1091
+ };
1092
+
1093
+ let sdkInitTimeStamp;
1094
+
1095
+ // this technically isn't possible with the way paypal-sdk-client
1096
+ // is set up but one day it could be refactored and this would throw
1097
+ // an error and block the button from rendering
1098
+ try {
1099
+ sdkInitTimeStamp = getSDKInitTime();
1100
+ } catch (error) {
1101
+ // do nothing
1102
+ }
1103
+
1104
+ return {
1105
+ sdkInitTimeStamp,
1106
+ sdkScriptDownloadDuration: sdkScript?.duration,
1107
+ isSdkCached: isCached(sdkScript),
1108
+ };
1109
+ },
1110
+ },
1111
+
1070
1112
  sdkMeta: {
1071
1113
  type: "string",
1072
1114
  queryParam: true,