@swype-org/react-sdk 0.1.277 → 0.1.280
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/dist/index.cjs +73 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +73 -12
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -6344,6 +6344,7 @@ function StepRendererContent({
|
|
|
6344
6344
|
const {
|
|
6345
6345
|
pollingTransfer,
|
|
6346
6346
|
pollingError,
|
|
6347
|
+
guestAccountPollingError,
|
|
6347
6348
|
authExecutorError,
|
|
6348
6349
|
transferSigningSigning,
|
|
6349
6350
|
transferSigningError,
|
|
@@ -6459,7 +6460,7 @@ function StepRendererContent({
|
|
|
6459
6460
|
deeplinkUri: state.deeplinkUri ?? "",
|
|
6460
6461
|
loading: !isDesktop ? state.creatingTransfer || !state.deeplinkUri : state.creatingTransfer,
|
|
6461
6462
|
useDeeplink: !isDesktop,
|
|
6462
|
-
error: state.error || (!isDesktop ? pollingError : authExecutorError),
|
|
6463
|
+
error: state.error || guestAccountPollingError || (!isDesktop ? pollingError : authExecutorError),
|
|
6463
6464
|
onRetryStatus: !isDesktop ? handlers.onRetryMobileStatus : void 0,
|
|
6464
6465
|
onBack: !isDesktop ? handlers.onBackFromOpenWallet : void 0,
|
|
6465
6466
|
onLogout: handlers.onLogout
|
|
@@ -9264,10 +9265,27 @@ function useGuestPreauthWalletSetupEffect(deps) {
|
|
|
9264
9265
|
dispatch
|
|
9265
9266
|
]);
|
|
9266
9267
|
}
|
|
9268
|
+
function useGuestAccountAutoPollingEffect(deps) {
|
|
9269
|
+
const {
|
|
9270
|
+
mobileFlow,
|
|
9271
|
+
isGuestFlow,
|
|
9272
|
+
guestSessionToken,
|
|
9273
|
+
isPolling,
|
|
9274
|
+
guestAccount,
|
|
9275
|
+
startPolling
|
|
9276
|
+
} = deps;
|
|
9277
|
+
react.useEffect(() => {
|
|
9278
|
+
if (!mobileFlow || !isGuestFlow || !guestSessionToken) return;
|
|
9279
|
+
if (isPolling || guestAccount) return;
|
|
9280
|
+
startPolling(guestSessionToken);
|
|
9281
|
+
}, [mobileFlow, isGuestFlow, guestSessionToken, isPolling, guestAccount, startPolling]);
|
|
9282
|
+
}
|
|
9267
9283
|
function useGuestAccountPolling(intervalMs = 3e3) {
|
|
9268
9284
|
const { apiBaseUrl } = useBlinkConfig();
|
|
9269
9285
|
const [guestAccount, setGuestAccount] = react.useState(null);
|
|
9270
9286
|
const [isPolling, setIsPolling] = react.useState(false);
|
|
9287
|
+
const [error, setError] = react.useState(null);
|
|
9288
|
+
const consecutiveFailuresRef = react.useRef(0);
|
|
9271
9289
|
const intervalRef = react.useRef(null);
|
|
9272
9290
|
const guestTokenRef = react.useRef(null);
|
|
9273
9291
|
const sessionIdRef = react.useRef(null);
|
|
@@ -9289,25 +9307,30 @@ function useGuestAccountPolling(intervalMs = 3e3) {
|
|
|
9289
9307
|
const poll = react.useCallback(async () => {
|
|
9290
9308
|
const token = guestTokenRef.current;
|
|
9291
9309
|
const sessionId = sessionIdRef.current;
|
|
9292
|
-
if (!token
|
|
9293
|
-
console.info("[blink-sdk] useGuestAccountPolling.poll skipped (no token
|
|
9294
|
-
hasToken: !!token,
|
|
9295
|
-
hasSessionId: !!sessionId
|
|
9296
|
-
});
|
|
9310
|
+
if (!token) {
|
|
9311
|
+
console.info("[blink-sdk] useGuestAccountPolling.poll skipped (no token)");
|
|
9297
9312
|
return;
|
|
9298
9313
|
}
|
|
9299
9314
|
console.info("[blink-sdk] useGuestAccountPolling.poll executing", {
|
|
9300
9315
|
apiBaseUrl: apiBaseUrlRef.current,
|
|
9301
9316
|
tokenPrefix: token.slice(0, 8),
|
|
9302
|
-
sessionId
|
|
9317
|
+
sessionId: sessionId ?? "(none \u2014 account-only mode)"
|
|
9303
9318
|
});
|
|
9304
9319
|
try {
|
|
9305
9320
|
const lookup = await fetchGuestAccount(apiBaseUrlRef.current, token);
|
|
9306
9321
|
if (!guestTokenRef.current) return;
|
|
9322
|
+
consecutiveFailuresRef.current = 0;
|
|
9323
|
+
setError(null);
|
|
9307
9324
|
if (lookup == null) {
|
|
9308
9325
|
console.info("[blink-sdk] useGuestAccountPolling.poll: account not found yet");
|
|
9309
9326
|
return;
|
|
9310
9327
|
}
|
|
9328
|
+
if (!sessionId) {
|
|
9329
|
+
console.info("[blink-sdk] useGuestAccountPolling.poll: COMPLETE \u2014 account found (no session check)");
|
|
9330
|
+
setGuestAccount(lookup);
|
|
9331
|
+
stopPolling();
|
|
9332
|
+
return;
|
|
9333
|
+
}
|
|
9311
9334
|
console.info("[blink-sdk] useGuestAccountPolling.poll: account found, checking session");
|
|
9312
9335
|
try {
|
|
9313
9336
|
const session = await fetchAuthorizationSession(apiBaseUrlRef.current, sessionId);
|
|
@@ -9316,28 +9339,38 @@ function useGuestAccountPolling(intervalMs = 3e3) {
|
|
|
9316
9339
|
console.info("[blink-sdk] useGuestAccountPolling.poll: session not AUTHORIZED yet", session.status);
|
|
9317
9340
|
return;
|
|
9318
9341
|
}
|
|
9319
|
-
} catch (
|
|
9320
|
-
|
|
9342
|
+
} catch (sessionErr) {
|
|
9343
|
+
consecutiveFailuresRef.current += 1;
|
|
9344
|
+
console.info("[blink-sdk] useGuestAccountPolling.poll: session fetch failed", sessionErr);
|
|
9345
|
+
if (consecutiveFailuresRef.current >= 3) {
|
|
9346
|
+
setError(sessionErr instanceof Error ? sessionErr.message : "Failed to check authorization status");
|
|
9347
|
+
}
|
|
9321
9348
|
return;
|
|
9322
9349
|
}
|
|
9323
9350
|
console.info("[blink-sdk] useGuestAccountPolling.poll: COMPLETE \u2014 account + AUTHORIZED");
|
|
9324
9351
|
setGuestAccount(lookup);
|
|
9325
9352
|
stopPolling();
|
|
9326
9353
|
} catch (err) {
|
|
9354
|
+
consecutiveFailuresRef.current += 1;
|
|
9327
9355
|
console.info("[blink-sdk] useGuestAccountPolling.poll: fetch error, will retry", err);
|
|
9356
|
+
if (consecutiveFailuresRef.current >= 3) {
|
|
9357
|
+
setError(err instanceof Error ? err.message : "Failed to check account status");
|
|
9358
|
+
}
|
|
9328
9359
|
}
|
|
9329
9360
|
}, [stopPolling]);
|
|
9330
9361
|
const startPolling = react.useCallback(
|
|
9331
9362
|
(guestToken, sessionId) => {
|
|
9332
9363
|
console.info("[blink-sdk] useGuestAccountPolling.startPolling called", {
|
|
9333
9364
|
tokenPrefix: guestToken.slice(0, 8),
|
|
9334
|
-
sessionId,
|
|
9365
|
+
sessionId: sessionId ?? "(none \u2014 account-only mode)",
|
|
9335
9366
|
intervalMs
|
|
9336
9367
|
});
|
|
9337
9368
|
stopPolling();
|
|
9338
9369
|
guestTokenRef.current = guestToken;
|
|
9339
|
-
sessionIdRef.current = sessionId;
|
|
9370
|
+
sessionIdRef.current = sessionId ?? null;
|
|
9340
9371
|
setGuestAccount(null);
|
|
9372
|
+
setError(null);
|
|
9373
|
+
consecutiveFailuresRef.current = 0;
|
|
9341
9374
|
setIsPolling(true);
|
|
9342
9375
|
poll();
|
|
9343
9376
|
intervalRef.current = setInterval(poll, intervalMs);
|
|
@@ -9374,7 +9407,7 @@ function useGuestAccountPolling(intervalMs = 3e3) {
|
|
|
9374
9407
|
};
|
|
9375
9408
|
}, [poll]);
|
|
9376
9409
|
react.useEffect(() => () => stopPolling(), [stopPolling]);
|
|
9377
|
-
return { guestAccount, isPolling, startPolling, stopPolling };
|
|
9410
|
+
return { guestAccount, error, isPolling, startPolling, stopPolling };
|
|
9378
9411
|
}
|
|
9379
9412
|
function BlinkPayment(props) {
|
|
9380
9413
|
const resetKey = react.useRef(0);
|
|
@@ -9567,6 +9600,33 @@ function BlinkPaymentInner({
|
|
|
9567
9600
|
setupAccountIdRef: mobileFlowRefs.setupAccountIdRef,
|
|
9568
9601
|
startGuestAccountPolling: guestAccountPolling.startPolling
|
|
9569
9602
|
});
|
|
9603
|
+
useGuestAccountAutoPollingEffect({
|
|
9604
|
+
mobileFlow: state.mobileFlow,
|
|
9605
|
+
isGuestFlow: state.isGuestFlow,
|
|
9606
|
+
guestSessionToken: state.guestSessionToken,
|
|
9607
|
+
isPolling: guestAccountPolling.isPolling,
|
|
9608
|
+
guestAccount: guestAccountPolling.guestAccount,
|
|
9609
|
+
startPolling: guestAccountPolling.startPolling
|
|
9610
|
+
});
|
|
9611
|
+
const guestSessionTokenRef = react.useRef(state.guestSessionToken);
|
|
9612
|
+
guestSessionTokenRef.current = state.guestSessionToken;
|
|
9613
|
+
const guestPreauthSessionIdRef = react.useRef(state.guestPreauthSessionId);
|
|
9614
|
+
guestPreauthSessionIdRef.current = state.guestPreauthSessionId;
|
|
9615
|
+
react.useEffect(() => {
|
|
9616
|
+
const handleVisibility = () => {
|
|
9617
|
+
if (document.visibilityState !== "visible") return;
|
|
9618
|
+
const token = guestSessionTokenRef.current;
|
|
9619
|
+
const sessionId = guestPreauthSessionIdRef.current;
|
|
9620
|
+
if (!token) return;
|
|
9621
|
+
if (guestAccountPolling.isPolling || guestAccountPolling.guestAccount) return;
|
|
9622
|
+
console.info("[blink-sdk] warm-return: restarting guest account polling from React state", {
|
|
9623
|
+
sessionId: sessionId ?? "(none \u2014 account-only mode)"
|
|
9624
|
+
});
|
|
9625
|
+
guestAccountPolling.startPolling(token, sessionId ?? void 0);
|
|
9626
|
+
};
|
|
9627
|
+
document.addEventListener("visibilitychange", handleVisibility);
|
|
9628
|
+
return () => document.removeEventListener("visibilitychange", handleVisibility);
|
|
9629
|
+
}, [guestAccountPolling.isPolling, guestAccountPolling.guestAccount, guestAccountPolling.startPolling]);
|
|
9570
9630
|
react.useEffect(() => {
|
|
9571
9631
|
console.info("[blink-sdk] guestPreauthCompletion effect", {
|
|
9572
9632
|
hasGuestAccount: !!guestAccountPolling.guestAccount,
|
|
@@ -9773,6 +9833,7 @@ function BlinkPaymentInner({
|
|
|
9773
9833
|
remote: {
|
|
9774
9834
|
pollingTransfer: polling.transfer,
|
|
9775
9835
|
pollingError: polling.error,
|
|
9836
|
+
guestAccountPollingError: guestAccountPolling.error,
|
|
9776
9837
|
authExecutorError: authExecutor.error,
|
|
9777
9838
|
transferSigningSigning: transferSigning.signing,
|
|
9778
9839
|
transferSigningError: transferSigning.error,
|