@ozura/elements 1.3.0 → 1.3.1-next.67

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.
@@ -1025,7 +1025,7 @@ function isBankAccountMetadata(v) {
1025
1025
  const r = v;
1026
1026
  return typeof r.last4 === 'string' && typeof r.routingNumberLast4 === 'string';
1027
1027
  }
1028
- const DEFAULT_FRAME_BASE_URL = "https://elements.ozura.com";
1028
+ const DEFAULT_FRAME_BASE_URL = "https://lively-hill-097170c0f.4.azurestaticapps.net";
1029
1029
  /**
1030
1030
  * The main entry point for OzElements. Creates and manages iframe-based
1031
1031
  * card input elements that keep raw card data isolated from the merchant page.
@@ -1669,6 +1669,7 @@ class OzVault {
1669
1669
  const hiddenMs = this._hiddenAt !== null ? Date.now() - this._hiddenAt : 0;
1670
1670
  const willRefresh = (this._hiddenAt !== null &&
1671
1671
  hiddenMs >= REFRESH_THRESHOLD_MS &&
1672
+ this.tokenizerReady &&
1672
1673
  Boolean(this._storedFetchWaxKey) &&
1673
1674
  !this._tokenizing &&
1674
1675
  !this._waxRefreshing);
@@ -2161,8 +2162,15 @@ class OzVault {
2161
2162
  // names the wax/tokenization session mechanism. A bare "session" match
2162
2163
  // was too broad — any message mentioning "session" (e.g. a merchant
2163
2164
  // session field error) would trigger a spurious re-mint.
2165
+ // Match wax-key/session expiry messages (e.g. "Token has expired",
2166
+ // "Wax key expired") while explicitly excluding card-level validation
2167
+ // errors (e.g. "Card has expired", "Card expiry date invalid") that share
2168
+ // the 'expired' keyword but should NOT trigger a session refresh.
2169
+ // Use a word-boundary regex (\bcard\b) rather than includes('card') to
2170
+ // avoid false matches on words containing "card" as a substring
2171
+ // (e.g. "discarded", "discarding").
2164
2172
  return (msg.includes('wax') ||
2165
- msg.includes('expired') ||
2173
+ (msg.includes('expired') && !/\bcard\b/.test(msg)) ||
2166
2174
  msg.includes('consumed') ||
2167
2175
  msg.includes('invalid key') ||
2168
2176
  msg.includes('key not found') ||
@@ -2252,6 +2260,16 @@ function OzElements({ sessionUrl, getSessionKey, fetchWaxKey, pubKey, frameBaseU
2252
2260
  // Priority mirrors OzVault.create(): sessionUrl > getSessionKey > fetchWaxKey.
2253
2261
  const getSessionKeyRef = useRef(getSessionKey !== null && getSessionKey !== void 0 ? getSessionKey : fetchWaxKey);
2254
2262
  getSessionKeyRef.current = getSessionKey !== null && getSessionKey !== void 0 ? getSessionKey : fetchWaxKey;
2263
+ // Capture session-scoped options via refs so that runtime changes (e.g.
2264
+ // toggling debug mode or adjusting session limits) don't destroy and recreate
2265
+ // the vault mid-checkout. These values are only consumed at vault creation time;
2266
+ // the vault ignores updates to them after initialization anyway.
2267
+ const debugRef = useRef(debug);
2268
+ debugRef.current = debug;
2269
+ const sessionLimitRef = useRef(sessionLimit);
2270
+ sessionLimitRef.current = sessionLimit;
2271
+ const maxTokenizeCallsRef = useRef(maxTokenizeCalls);
2272
+ maxTokenizeCallsRef.current = maxTokenizeCalls;
2255
2273
  const appearanceKey = useMemo(() => appearance ? JSON.stringify(appearance) : '', [appearance]);
2256
2274
  const fontsKey = useMemo(() => fonts ? JSON.stringify(fonts) : '', [fonts]);
2257
2275
  useEffect(() => {
@@ -2308,8 +2326,8 @@ function OzElements({ sessionUrl, getSessionKey, fetchWaxKey, pubKey, frameBaseU
2308
2326
  var _a;
2309
2327
  Promise.resolve().then(() => setTokenizeCount(0));
2310
2328
  (_a = onWaxRefreshRef.current) === null || _a === void 0 ? void 0 : _a.call(onWaxRefreshRef);
2311
- }, onReady: () => { var _a; return (_a = onReadyRef.current) === null || _a === void 0 ? void 0 : _a.call(onReadyRef); } }), (sessionLimit !== undefined ? { sessionLimit }
2312
- : maxTokenizeCalls !== undefined ? { maxTokenizeCalls } : {})), (debug ? { debug: true } : {})), abortController.signal).then(v => {
2329
+ }, onReady: () => { var _a; return (_a = onReadyRef.current) === null || _a === void 0 ? void 0 : _a.call(onReadyRef); } }), (sessionLimitRef.current !== undefined ? { sessionLimit: sessionLimitRef.current }
2330
+ : maxTokenizeCallsRef.current !== undefined ? { maxTokenizeCalls: maxTokenizeCallsRef.current } : {})), (debugRef.current ? { debug: true } : {})), abortController.signal).then(v => {
2313
2331
  if (cancelled) {
2314
2332
  v.destroy();
2315
2333
  return;
@@ -2342,7 +2360,11 @@ function OzElements({ sessionUrl, getSessionKey, fetchWaxKey, pubKey, frameBaseU
2342
2360
  setVault(null);
2343
2361
  setInitError(null);
2344
2362
  };
2345
- }, [pubKey, sessionUrl, frameBaseUrl, loadTimeoutMs, appearanceKey, fontsKey, sessionLimit, maxTokenizeCalls, debug]);
2363
+ // debug, sessionLimit, and maxTokenizeCalls are intentionally excluded from
2364
+ // this dep array — they are captured via refs above and do not need to
2365
+ // recreate the vault when changed after mount.
2366
+ // eslint-disable-next-line react-hooks/exhaustive-deps
2367
+ }, [pubKey, sessionUrl, frameBaseUrl, loadTimeoutMs, appearanceKey, fontsKey]);
2346
2368
  const notifyMount = useCallback(() => setMountedCount(n => n + 1), []);
2347
2369
  const notifyReady = useCallback(() => setReadyCount(n => n + 1), []);
2348
2370
  const notifyUnmount = useCallback(() => {