@ozura/elements 1.1.0-next.21 → 1.1.0-next.23
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/README.md +73 -71
- package/dist/oz-elements.esm.js +254 -239
- package/dist/oz-elements.esm.js.map +1 -1
- package/dist/oz-elements.umd.js +255 -239
- package/dist/oz-elements.umd.js.map +1 -1
- package/dist/react/index.cjs.js +129 -108
- package/dist/react/index.cjs.js.map +1 -1
- package/dist/react/index.esm.js +129 -108
- package/dist/react/index.esm.js.map +1 -1
- package/dist/react/react/index.d.ts +46 -29
- package/dist/react/sdk/OzVault.d.ts +6 -5
- package/dist/react/sdk/createSessionFetcher.d.ts +29 -0
- package/dist/react/sdk/index.d.ts +6 -26
- package/dist/react/server/index.d.ts +126 -74
- package/dist/react/types/index.d.ts +52 -31
- package/dist/server/index.cjs.js +165 -76
- package/dist/server/index.cjs.js.map +1 -1
- package/dist/server/index.esm.js +164 -77
- package/dist/server/index.esm.js.map +1 -1
- package/dist/server/sdk/OzVault.d.ts +6 -5
- package/dist/server/sdk/createSessionFetcher.d.ts +29 -0
- package/dist/server/sdk/index.d.ts +6 -26
- package/dist/server/server/index.d.ts +126 -74
- package/dist/server/types/index.d.ts +52 -31
- package/dist/types/sdk/OzVault.d.ts +6 -5
- package/dist/types/sdk/createSessionFetcher.d.ts +29 -0
- package/dist/types/sdk/index.d.ts +6 -26
- package/dist/types/server/index.d.ts +126 -74
- package/dist/types/types/index.d.ts +52 -31
- package/package.json +1 -1
package/dist/react/index.esm.js
CHANGED
|
@@ -838,6 +838,85 @@ function validateBilling(billing) {
|
|
|
838
838
|
*/
|
|
839
839
|
const PROTOCOL_VERSION = 1;
|
|
840
840
|
|
|
841
|
+
/**
|
|
842
|
+
* Creates a `getSessionKey` callback for `OzVault.create()` and `<OzElements>`.
|
|
843
|
+
*
|
|
844
|
+
* This is the recommended way to wire the SDK to your backend session endpoint.
|
|
845
|
+
* If you don't need custom headers or auth logic, pass `sessionUrl` directly to
|
|
846
|
+
* `OzVault.create()` or `<OzElements>` — it calls this helper internally.
|
|
847
|
+
*
|
|
848
|
+
* The callback POSTs `{ sessionId }` to `url` and reads `sessionKey` (or the
|
|
849
|
+
* legacy `waxKey`) from the JSON response, so it is compatible with both the
|
|
850
|
+
* new `createSessionMiddleware` and the old `createMintWaxMiddleware` backends.
|
|
851
|
+
*
|
|
852
|
+
* Each call enforces a **10-second timeout**. On pure network failures
|
|
853
|
+
* (offline, DNS, connection refused) the request is retried **once after 750ms**.
|
|
854
|
+
* HTTP 4xx/5xx errors are never retried — they indicate misconfiguration.
|
|
855
|
+
*
|
|
856
|
+
* @param url - Absolute or relative URL of your session endpoint, e.g. `'/api/oz-session'`.
|
|
857
|
+
*
|
|
858
|
+
* @example
|
|
859
|
+
* // Simplest — just pass sessionUrl, no need to call this directly
|
|
860
|
+
* const vault = await OzVault.create({ pubKey: 'pk_live_...', sessionUrl: '/api/oz-session' });
|
|
861
|
+
*
|
|
862
|
+
* @example
|
|
863
|
+
* // Manual — use when you need custom headers
|
|
864
|
+
* const vault = await OzVault.create({
|
|
865
|
+
* pubKey: 'pk_live_...',
|
|
866
|
+
* getSessionKey: createSessionFetcher('/api/oz-session'),
|
|
867
|
+
* });
|
|
868
|
+
*/
|
|
869
|
+
function createSessionFetcher(url) {
|
|
870
|
+
const TIMEOUT_MS = 10000;
|
|
871
|
+
// Each attempt gets its own AbortController so a timeout on attempt 1 does
|
|
872
|
+
// not bleed into the retry.
|
|
873
|
+
const attemptFetch = (sessionId) => {
|
|
874
|
+
const controller = new AbortController();
|
|
875
|
+
const timer = setTimeout(() => controller.abort(), TIMEOUT_MS);
|
|
876
|
+
return fetch(url, {
|
|
877
|
+
method: 'POST',
|
|
878
|
+
headers: { 'Content-Type': 'application/json' },
|
|
879
|
+
body: JSON.stringify({ sessionId }),
|
|
880
|
+
signal: controller.signal,
|
|
881
|
+
}).finally(() => clearTimeout(timer));
|
|
882
|
+
};
|
|
883
|
+
return async (sessionId) => {
|
|
884
|
+
let res;
|
|
885
|
+
try {
|
|
886
|
+
res = await attemptFetch(sessionId);
|
|
887
|
+
}
|
|
888
|
+
catch (firstErr) {
|
|
889
|
+
// Timeout/abort — don't retry, we already waited the full duration.
|
|
890
|
+
if (firstErr instanceof Error && (firstErr.name === 'AbortError' || firstErr.name === 'TimeoutError')) {
|
|
891
|
+
throw new OzError(`Session endpoint timed out after ${TIMEOUT_MS / 1000}s (${url})`, undefined, 'timeout');
|
|
892
|
+
}
|
|
893
|
+
// Pure network error — retry once after a short pause.
|
|
894
|
+
await new Promise(resolve => setTimeout(resolve, 750));
|
|
895
|
+
try {
|
|
896
|
+
res = await attemptFetch(sessionId);
|
|
897
|
+
}
|
|
898
|
+
catch (retryErr) {
|
|
899
|
+
const msg = retryErr instanceof Error ? retryErr.message : 'Network error';
|
|
900
|
+
throw new OzError(`Could not reach session endpoint (${url}): ${msg}`, undefined, 'network');
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
const data = await res.json().catch(() => ({}));
|
|
904
|
+
if (!res.ok) {
|
|
905
|
+
throw new OzError(typeof data.error === 'string' && data.error
|
|
906
|
+
? data.error
|
|
907
|
+
: `Session endpoint returned HTTP ${res.status}`, undefined, res.status >= 500 ? 'server' : res.status === 401 || res.status === 403 ? 'auth' : 'validation');
|
|
908
|
+
}
|
|
909
|
+
// Accept both new `sessionKey` and legacy `waxKey` for backward compatibility
|
|
910
|
+
// with backends that haven't migrated to createSessionMiddleware yet.
|
|
911
|
+
const key = (typeof data.sessionKey === 'string' ? data.sessionKey : '') ||
|
|
912
|
+
(typeof data.waxKey === 'string' ? data.waxKey : '');
|
|
913
|
+
if (!key.trim()) {
|
|
914
|
+
throw new OzError('Session endpoint response is missing sessionKey. Check your /api/oz-session implementation.', undefined, 'validation');
|
|
915
|
+
}
|
|
916
|
+
return key;
|
|
917
|
+
};
|
|
918
|
+
}
|
|
919
|
+
|
|
841
920
|
function isCardMetadata(v) {
|
|
842
921
|
return !!v && typeof v === 'object' && typeof v.last4 === 'string';
|
|
843
922
|
}
|
|
@@ -877,7 +956,7 @@ class OzVault {
|
|
|
877
956
|
* @internal
|
|
878
957
|
*/
|
|
879
958
|
constructor(options, waxKey, tokenizationSessionId) {
|
|
880
|
-
var _a, _b, _c, _d;
|
|
959
|
+
var _a, _b, _c, _d, _e, _f;
|
|
881
960
|
this.elements = new Map();
|
|
882
961
|
this.elementsByType = new Map();
|
|
883
962
|
this.bankElementsByType = new Map();
|
|
@@ -911,15 +990,16 @@ class OzVault {
|
|
|
911
990
|
this.fonts = (_a = options.fonts) !== null && _a !== void 0 ? _a : [];
|
|
912
991
|
this.resolvedAppearance = resolveAppearance(options.appearance);
|
|
913
992
|
this.vaultId = `vault-${uuid()}`;
|
|
914
|
-
|
|
915
|
-
this.
|
|
993
|
+
// sessionLimit takes precedence over legacy maxTokenizeCalls
|
|
994
|
+
this._maxTokenizeCalls = (_c = (_b = options.sessionLimit) !== null && _b !== void 0 ? _b : options.maxTokenizeCalls) !== null && _c !== void 0 ? _c : 3;
|
|
995
|
+
this._debug = (_d = options.debug) !== null && _d !== void 0 ? _d : false;
|
|
916
996
|
this.boundHandleMessage = this.handleMessage.bind(this);
|
|
917
997
|
window.addEventListener('message', this.boundHandleMessage);
|
|
918
998
|
this.boundHandleVisibility = this.handleVisibilityChange.bind(this);
|
|
919
999
|
document.addEventListener('visibilitychange', this.boundHandleVisibility);
|
|
920
1000
|
this.mountTokenizerFrame();
|
|
921
1001
|
if (options.onLoadError) {
|
|
922
|
-
const timeout = (
|
|
1002
|
+
const timeout = (_e = options.loadTimeoutMs) !== null && _e !== void 0 ? _e : 10000;
|
|
923
1003
|
this.loadErrorTimeoutId = setTimeout(() => {
|
|
924
1004
|
this.loadErrorTimeoutId = null;
|
|
925
1005
|
if (!this._destroyed && !this.tokenizerReady) {
|
|
@@ -927,7 +1007,8 @@ class OzVault {
|
|
|
927
1007
|
}
|
|
928
1008
|
}, timeout);
|
|
929
1009
|
}
|
|
930
|
-
|
|
1010
|
+
// onSessionRefresh takes precedence over legacy onWaxRefresh
|
|
1011
|
+
this._onWaxRefresh = (_f = options.onSessionRefresh) !== null && _f !== void 0 ? _f : options.onWaxRefresh;
|
|
931
1012
|
this._onReady = options.onReady;
|
|
932
1013
|
this.log('vault created', { vaultId: this.vaultId, frameBaseUrl: this.frameBaseUrl, maxTokenizeCalls: this._maxTokenizeCalls });
|
|
933
1014
|
}
|
|
@@ -935,47 +1016,59 @@ class OzVault {
|
|
|
935
1016
|
* Creates and returns a ready `OzVault` instance.
|
|
936
1017
|
*
|
|
937
1018
|
* Internally this:
|
|
938
|
-
* 1. Generates a
|
|
1019
|
+
* 1. Generates a session UUID.
|
|
939
1020
|
* 2. Starts loading the hidden tokenizer iframe immediately.
|
|
940
|
-
* 3.
|
|
941
|
-
*
|
|
942
|
-
*
|
|
1021
|
+
* 3. Fetches a session key from your backend concurrently — either via
|
|
1022
|
+
* `sessionUrl` (simplest), `getSessionKey` (custom headers/auth), or the
|
|
1023
|
+
* deprecated `fetchWaxKey` callback.
|
|
1024
|
+
* 4. Resolves with the vault instance once the session key is stored. The iframe
|
|
943
1025
|
* has been loading the whole time, so `isReady` may already be true or
|
|
944
1026
|
* will fire shortly after.
|
|
945
1027
|
*
|
|
946
1028
|
* The returned vault is ready to create elements immediately. `createToken()`
|
|
947
1029
|
* additionally requires `vault.isReady` (tokenizer iframe loaded).
|
|
948
1030
|
*
|
|
949
|
-
* @throws {OzError} if
|
|
1031
|
+
* @throws {OzError} if the session fetch fails, times out, or returns an empty string.
|
|
950
1032
|
*/
|
|
951
1033
|
static async create(options, signal) {
|
|
952
1034
|
if (!options.pubKey || !options.pubKey.trim()) {
|
|
953
1035
|
throw new OzError('pubKey is required in options. Obtain your public key from the Ozura admin.');
|
|
954
1036
|
}
|
|
955
|
-
|
|
956
|
-
|
|
1037
|
+
// Normalize the session callback. Priority: sessionUrl > getSessionKey > fetchWaxKey (deprecated).
|
|
1038
|
+
// This allows merchants to use the clean new API without touching legacy code.
|
|
1039
|
+
let resolvedFetchKey;
|
|
1040
|
+
if (options.sessionUrl) {
|
|
1041
|
+
resolvedFetchKey = createSessionFetcher(options.sessionUrl);
|
|
1042
|
+
}
|
|
1043
|
+
else if (typeof options.getSessionKey === 'function') {
|
|
1044
|
+
resolvedFetchKey = options.getSessionKey;
|
|
1045
|
+
}
|
|
1046
|
+
else if (typeof options.fetchWaxKey === 'function') {
|
|
1047
|
+
resolvedFetchKey = options.fetchWaxKey;
|
|
1048
|
+
}
|
|
1049
|
+
else {
|
|
1050
|
+
throw new OzError('A session URL or callback is required. Pass sessionUrl, getSessionKey, or fetchWaxKey to OzVault.create().');
|
|
957
1051
|
}
|
|
958
1052
|
const tokenizationSessionId = uuid();
|
|
959
1053
|
// Construct the vault immediately — this mounts the tokenizer iframe so it
|
|
960
|
-
// starts loading while
|
|
961
|
-
// empty and is set below before create() returns.
|
|
1054
|
+
// starts loading while the session fetch is in flight.
|
|
962
1055
|
const vault = new OzVault(options, '', tokenizationSessionId);
|
|
963
1056
|
// If the caller provides an AbortSignal (e.g. React useEffect cleanup),
|
|
964
1057
|
// destroy the vault immediately on abort so the tokenizer iframe and message
|
|
965
|
-
// listener are removed synchronously rather than waiting for
|
|
966
|
-
// settle. This eliminates the brief double-iframe window in React StrictMode.
|
|
1058
|
+
// listener are removed synchronously rather than waiting for the session fetch
|
|
1059
|
+
// to settle. This eliminates the brief double-iframe window in React StrictMode.
|
|
967
1060
|
const onAbort = () => vault.destroy();
|
|
968
1061
|
signal === null || signal === void 0 ? void 0 : signal.addEventListener('abort', onAbort, { once: true });
|
|
969
1062
|
let waxKey;
|
|
970
1063
|
try {
|
|
971
|
-
waxKey = await
|
|
1064
|
+
waxKey = await resolvedFetchKey(tokenizationSessionId);
|
|
972
1065
|
}
|
|
973
1066
|
catch (err) {
|
|
974
1067
|
signal === null || signal === void 0 ? void 0 : signal.removeEventListener('abort', onAbort);
|
|
975
1068
|
vault.destroy();
|
|
976
1069
|
if (signal === null || signal === void 0 ? void 0 : signal.aborted)
|
|
977
1070
|
throw new OzError('OzVault.create() was cancelled.');
|
|
978
|
-
// Preserve errorCode/retryable from OzError (e.g. timeout/network from
|
|
1071
|
+
// Preserve errorCode/retryable from OzError (e.g. timeout/network from createSessionFetcher)
|
|
979
1072
|
// so callers can distinguish transient failures from config errors.
|
|
980
1073
|
const originalCode = err instanceof OzError ? err.errorCode : undefined;
|
|
981
1074
|
const msg = err instanceof Error ? err.message : 'Unknown error';
|
|
@@ -992,7 +1085,7 @@ class OzVault {
|
|
|
992
1085
|
}
|
|
993
1086
|
// Static methods can access private fields of instances of the same class.
|
|
994
1087
|
vault.waxKey = waxKey;
|
|
995
|
-
vault._storedFetchWaxKey =
|
|
1088
|
+
vault._storedFetchWaxKey = resolvedFetchKey;
|
|
996
1089
|
// If the tokenizer iframe fired OZ_FRAME_READY before fetchWaxKey resolved,
|
|
997
1090
|
// the OZ_INIT sent at that point had an empty waxKey. Send a follow-up now
|
|
998
1091
|
// so the tokenizer has the key stored before any createToken() call.
|
|
@@ -1906,84 +1999,6 @@ class OzVault {
|
|
|
1906
1999
|
}
|
|
1907
2000
|
}
|
|
1908
2001
|
|
|
1909
|
-
/**
|
|
1910
|
-
* Creates a ready-to-use `fetchWaxKey` callback for `OzVault.create()` and `<OzElements>`.
|
|
1911
|
-
*
|
|
1912
|
-
* Calls your backend mint endpoint with `{ sessionId }` and returns the wax key string.
|
|
1913
|
-
* Throws on non-OK responses or a missing `waxKey` field so the vault can surface the
|
|
1914
|
-
* error through its normal error path.
|
|
1915
|
-
*
|
|
1916
|
-
* Each call enforces a 10-second per-attempt timeout. On a pure network-level
|
|
1917
|
-
* failure (connection refused, DNS failure, etc.) the call is retried once after
|
|
1918
|
-
* 750ms before throwing. HTTP errors (4xx/5xx) are never retried — they indicate
|
|
1919
|
-
* an endpoint misconfiguration or an invalid key, not a transient failure.
|
|
1920
|
-
*
|
|
1921
|
-
* The mint endpoint is typically the one-line `createMintWaxHandler` / `createMintWaxMiddleware`
|
|
1922
|
-
* from `@ozura/elements/server`.
|
|
1923
|
-
*
|
|
1924
|
-
* @param mintUrl - Absolute or relative URL of your wax-key mint endpoint, e.g. `'/api/mint-wax'`.
|
|
1925
|
-
*
|
|
1926
|
-
* @example
|
|
1927
|
-
* // Vanilla JS
|
|
1928
|
-
* const vault = await OzVault.create({
|
|
1929
|
-
* pubKey: 'pk_live_...',
|
|
1930
|
-
* fetchWaxKey: createFetchWaxKey('/api/mint-wax'),
|
|
1931
|
-
* });
|
|
1932
|
-
*
|
|
1933
|
-
* @example
|
|
1934
|
-
* // React
|
|
1935
|
-
* <OzElements pubKey="pk_live_..." fetchWaxKey={createFetchWaxKey('/api/mint-wax')}>
|
|
1936
|
-
*/
|
|
1937
|
-
function createFetchWaxKey(mintUrl) {
|
|
1938
|
-
const TIMEOUT_MS = 10000;
|
|
1939
|
-
// Each attempt gets its own AbortController so a timeout on attempt 1 does
|
|
1940
|
-
// not bleed into the retry. Uses AbortController + setTimeout instead of
|
|
1941
|
-
// AbortSignal.timeout() to support environments without that API.
|
|
1942
|
-
const attemptFetch = (sessionId) => {
|
|
1943
|
-
const controller = new AbortController();
|
|
1944
|
-
const timer = setTimeout(() => controller.abort(), TIMEOUT_MS);
|
|
1945
|
-
return fetch(mintUrl, {
|
|
1946
|
-
method: 'POST',
|
|
1947
|
-
headers: { 'Content-Type': 'application/json' },
|
|
1948
|
-
body: JSON.stringify({ sessionId }),
|
|
1949
|
-
signal: controller.signal,
|
|
1950
|
-
}).finally(() => clearTimeout(timer));
|
|
1951
|
-
};
|
|
1952
|
-
return async (sessionId) => {
|
|
1953
|
-
let res;
|
|
1954
|
-
try {
|
|
1955
|
-
res = await attemptFetch(sessionId);
|
|
1956
|
-
}
|
|
1957
|
-
catch (firstErr) {
|
|
1958
|
-
// Abort/timeout should not be retried — the server received nothing or
|
|
1959
|
-
// we already waited the full timeout duration.
|
|
1960
|
-
if (firstErr instanceof Error && (firstErr.name === 'AbortError' || firstErr.name === 'TimeoutError')) {
|
|
1961
|
-
throw new OzError(`Wax key mint timed out after ${TIMEOUT_MS / 1000}s (${mintUrl})`, undefined, 'timeout');
|
|
1962
|
-
}
|
|
1963
|
-
// Pure network error (offline, DNS, connection refused) — retry once
|
|
1964
|
-
// after a short pause in case of a transient blip.
|
|
1965
|
-
await new Promise(resolve => setTimeout(resolve, 750));
|
|
1966
|
-
try {
|
|
1967
|
-
res = await attemptFetch(sessionId);
|
|
1968
|
-
}
|
|
1969
|
-
catch (retryErr) {
|
|
1970
|
-
const msg = retryErr instanceof Error ? retryErr.message : 'Network error';
|
|
1971
|
-
throw new OzError(`Could not reach wax key mint endpoint (${mintUrl}): ${msg}`, undefined, 'network');
|
|
1972
|
-
}
|
|
1973
|
-
}
|
|
1974
|
-
const data = await res.json().catch(() => ({}));
|
|
1975
|
-
if (!res.ok) {
|
|
1976
|
-
throw new OzError(typeof data.error === 'string' && data.error
|
|
1977
|
-
? data.error
|
|
1978
|
-
: `Wax key mint failed (HTTP ${res.status})`, undefined, res.status >= 500 ? 'server' : res.status === 401 || res.status === 403 ? 'auth' : 'validation');
|
|
1979
|
-
}
|
|
1980
|
-
if (typeof data.waxKey !== 'string' || !data.waxKey.trim()) {
|
|
1981
|
-
throw new OzError('Mint endpoint response is missing waxKey. Check your /api/mint-wax implementation.', undefined, 'validation');
|
|
1982
|
-
}
|
|
1983
|
-
return data.waxKey;
|
|
1984
|
-
};
|
|
1985
|
-
}
|
|
1986
|
-
|
|
1987
2002
|
const OzContext = createContext({
|
|
1988
2003
|
vault: null,
|
|
1989
2004
|
initError: null,
|
|
@@ -2000,7 +2015,7 @@ const OzContext = createContext({
|
|
|
2000
2015
|
* All `<OzCardNumber />`, `<OzExpiry />`, and `<OzCvv />` children must be
|
|
2001
2016
|
* rendered inside this provider.
|
|
2002
2017
|
*/
|
|
2003
|
-
function OzElements({ fetchWaxKey, pubKey, frameBaseUrl, fonts, onLoadError, loadTimeoutMs, onWaxRefresh, onReady, appearance, maxTokenizeCalls, debug, children }) {
|
|
2018
|
+
function OzElements({ sessionUrl, getSessionKey, fetchWaxKey, pubKey, frameBaseUrl, fonts, onLoadError, loadTimeoutMs, onSessionRefresh, onWaxRefresh, onReady, appearance, sessionLimit, maxTokenizeCalls, debug, children }) {
|
|
2004
2019
|
const [vault, setVault] = useState(null);
|
|
2005
2020
|
const [initError, setInitError] = useState(null);
|
|
2006
2021
|
const [mountedCount, setMountedCount] = useState(0);
|
|
@@ -2008,13 +2023,14 @@ function OzElements({ fetchWaxKey, pubKey, frameBaseUrl, fonts, onLoadError, loa
|
|
|
2008
2023
|
const [tokenizeCount, setTokenizeCount] = useState(0);
|
|
2009
2024
|
const onLoadErrorRef = useRef(onLoadError);
|
|
2010
2025
|
onLoadErrorRef.current = onLoadError;
|
|
2011
|
-
const onWaxRefreshRef = useRef(onWaxRefresh);
|
|
2012
|
-
onWaxRefreshRef.current = onWaxRefresh;
|
|
2026
|
+
const onWaxRefreshRef = useRef(onSessionRefresh !== null && onSessionRefresh !== void 0 ? onSessionRefresh : onWaxRefresh);
|
|
2027
|
+
onWaxRefreshRef.current = onSessionRefresh !== null && onSessionRefresh !== void 0 ? onSessionRefresh : onWaxRefresh;
|
|
2013
2028
|
const onReadyRef = useRef(onReady);
|
|
2014
2029
|
onReadyRef.current = onReady;
|
|
2015
|
-
// Keep a ref to
|
|
2016
|
-
|
|
2017
|
-
|
|
2030
|
+
// Keep a ref to the session callback so changes don't trigger vault recreation.
|
|
2031
|
+
// Priority mirrors OzVault.create(): sessionUrl > getSessionKey > fetchWaxKey.
|
|
2032
|
+
const getSessionKeyRef = useRef(getSessionKey !== null && getSessionKey !== void 0 ? getSessionKey : fetchWaxKey);
|
|
2033
|
+
getSessionKeyRef.current = getSessionKey !== null && getSessionKey !== void 0 ? getSessionKey : fetchWaxKey;
|
|
2018
2034
|
const appearanceKey = useMemo(() => appearance ? JSON.stringify(appearance) : '', [appearance]);
|
|
2019
2035
|
const fontsKey = useMemo(() => fonts ? JSON.stringify(fonts) : '', [fonts]);
|
|
2020
2036
|
useEffect(() => {
|
|
@@ -2041,7 +2057,11 @@ function OzElements({ fetchWaxKey, pubKey, frameBaseUrl, fonts, onLoadError, loa
|
|
|
2041
2057
|
// synchronously rather than waiting for the promise to settle. Without this,
|
|
2042
2058
|
// two hidden iframes and two window listeners briefly coexist.
|
|
2043
2059
|
const abortController = new AbortController();
|
|
2044
|
-
OzVault.create(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(
|
|
2060
|
+
OzVault.create(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ pubKey }, (sessionUrl
|
|
2061
|
+
? { sessionUrl }
|
|
2062
|
+
: getSessionKeyRef.current
|
|
2063
|
+
? { getSessionKey: (sessionId) => getSessionKeyRef.current(sessionId) }
|
|
2064
|
+
: {})), (frameBaseUrl ? { frameBaseUrl } : {})), (parsedFonts ? { fonts: parsedFonts } : {})), (parsedAppearance ? { appearance: parsedAppearance } : {})), (onLoadErrorRef.current ? { onLoadError: fireLoadError, loadTimeoutMs } : {})), {
|
|
2045
2065
|
// Always install onWaxRefresh internally so we can reset tokenizeCount
|
|
2046
2066
|
// when any wax key refresh occurs (reactive TTL expiry, post-budget
|
|
2047
2067
|
// proactive, or visibility-change proactive). Without this the React
|
|
@@ -2063,11 +2083,12 @@ function OzElements({ fetchWaxKey, pubKey, frameBaseUrl, fonts, onLoadError, loa
|
|
|
2063
2083
|
// the retry tokenization completes (a full fetchWaxKey + tokenize round-
|
|
2064
2084
|
// trip separates them), so the count correctly resets to 0 then rises to
|
|
2065
2085
|
// 1 after the retry notifyTokenize fires.
|
|
2066
|
-
|
|
2086
|
+
onSessionRefresh: () => {
|
|
2067
2087
|
var _a;
|
|
2068
2088
|
Promise.resolve().then(() => setTokenizeCount(0));
|
|
2069
2089
|
(_a = onWaxRefreshRef.current) === null || _a === void 0 ? void 0 : _a.call(onWaxRefreshRef);
|
|
2070
|
-
}, onReady: () => { var _a; return (_a = onReadyRef.current) === null || _a === void 0 ? void 0 : _a.call(onReadyRef); } }), (
|
|
2090
|
+
}, onReady: () => { var _a; return (_a = onReadyRef.current) === null || _a === void 0 ? void 0 : _a.call(onReadyRef); } }), (sessionLimit !== undefined ? { sessionLimit }
|
|
2091
|
+
: maxTokenizeCalls !== undefined ? { maxTokenizeCalls } : {})), (debug ? { debug: true } : {})), abortController.signal).then(v => {
|
|
2071
2092
|
if (cancelled) {
|
|
2072
2093
|
v.destroy();
|
|
2073
2094
|
return;
|
|
@@ -2100,7 +2121,7 @@ function OzElements({ fetchWaxKey, pubKey, frameBaseUrl, fonts, onLoadError, loa
|
|
|
2100
2121
|
setVault(null);
|
|
2101
2122
|
setInitError(null);
|
|
2102
2123
|
};
|
|
2103
|
-
}, [pubKey, frameBaseUrl, loadTimeoutMs, appearanceKey, fontsKey, maxTokenizeCalls, debug]);
|
|
2124
|
+
}, [pubKey, sessionUrl, frameBaseUrl, loadTimeoutMs, appearanceKey, fontsKey, sessionLimit, maxTokenizeCalls, debug]);
|
|
2104
2125
|
const notifyMount = useCallback(() => setMountedCount(n => n + 1), []);
|
|
2105
2126
|
const notifyReady = useCallback(() => setReadyCount(n => n + 1), []);
|
|
2106
2127
|
const notifyUnmount = useCallback(() => {
|
|
@@ -2436,5 +2457,5 @@ function OzBankCard({ style, styles, classNames, labels, labelStyle, labelClassN
|
|
|
2436
2457
|
return (jsxs("div", { className: className, style: { width: '100%', display: 'flex', flexDirection: 'column', gap: gapStr }, children: [jsxs("div", { children: [renderLabel(labels === null || labels === void 0 ? void 0 : labels.accountNumber), jsx(OzBankAccountNumber, { style: mergeStyles(style, styles === null || styles === void 0 ? void 0 : styles.accountNumber), className: classNames === null || classNames === void 0 ? void 0 : classNames.accountNumber, placeholder: (_a = placeholders === null || placeholders === void 0 ? void 0 : placeholders.accountNumber) !== null && _a !== void 0 ? _a : 'Account number', disabled: disabled, onChange: (e) => { fieldState.current.accountNumber = e; emitChange(); }, onFocus: () => { var _a; return (_a = onFocusRef.current) === null || _a === void 0 ? void 0 : _a.call(onFocusRef, 'accountNumber'); }, onBlur: () => { var _a; return (_a = onBlurRef.current) === null || _a === void 0 ? void 0 : _a.call(onBlurRef, 'accountNumber'); }, onReady: readyHandlers['accountNumber'] })] }), jsxs("div", { children: [renderLabel(labels === null || labels === void 0 ? void 0 : labels.routingNumber), jsx(OzBankRoutingNumber, { style: mergeStyles(style, styles === null || styles === void 0 ? void 0 : styles.routingNumber), className: classNames === null || classNames === void 0 ? void 0 : classNames.routingNumber, placeholder: (_b = placeholders === null || placeholders === void 0 ? void 0 : placeholders.routingNumber) !== null && _b !== void 0 ? _b : 'Routing number', disabled: disabled, onChange: (e) => { fieldState.current.routingNumber = e; emitChange(); }, onFocus: () => { var _a; return (_a = onFocusRef.current) === null || _a === void 0 ? void 0 : _a.call(onFocusRef, 'routingNumber'); }, onBlur: () => { var _a; return (_a = onBlurRef.current) === null || _a === void 0 ? void 0 : _a.call(onBlurRef, 'routingNumber'); }, onReady: readyHandlers['routingNumber'] })] }), errorNode] }));
|
|
2437
2458
|
}
|
|
2438
2459
|
|
|
2439
|
-
export { OzBankAccountNumber, OzBankCard, OzBankRoutingNumber, OzCard, OzCardNumber, OzCvv, OzElements, OzExpiry, createFetchWaxKey, useOzElements };
|
|
2460
|
+
export { OzBankAccountNumber, OzBankCard, OzBankRoutingNumber, OzCard, OzCardNumber, OzCvv, OzElements, OzExpiry, createSessionFetcher as createFetchWaxKey, useOzElements };
|
|
2440
2461
|
//# sourceMappingURL=index.esm.js.map
|