@swype-org/react-sdk 0.1.256 → 0.1.258
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 +39 -37
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +39 -37
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -118,6 +118,8 @@ interface TransferSignPayload {
|
|
|
118
118
|
/** Transfer object returned by the API */
|
|
119
119
|
interface Transfer {
|
|
120
120
|
id: string;
|
|
121
|
+
/** `guest` for guest checkout; `standard` for Privy + smart account flows. */
|
|
122
|
+
type?: 'standard' | 'guest';
|
|
121
123
|
status: string;
|
|
122
124
|
sources: Array<{
|
|
123
125
|
id: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -118,6 +118,8 @@ interface TransferSignPayload {
|
|
|
118
118
|
/** Transfer object returned by the API */
|
|
119
119
|
interface Transfer {
|
|
120
120
|
id: string;
|
|
121
|
+
/** `guest` for guest checkout; `standard` for Privy + smart account flows. */
|
|
122
|
+
type?: 'standard' | 'guest';
|
|
121
123
|
status: string;
|
|
122
124
|
sources: Array<{
|
|
123
125
|
id: string;
|
package/dist/index.js
CHANGED
|
@@ -1996,14 +1996,47 @@ function shouldUseWalletConnector(options) {
|
|
|
1996
1996
|
return options.useWalletConnector ?? !isMobileUserAgent(options.userAgent);
|
|
1997
1997
|
}
|
|
1998
1998
|
|
|
1999
|
+
// src/processingStatus.ts
|
|
2000
|
+
var PROCESSING_TIMEOUT_MS = 18e4;
|
|
2001
|
+
var TERMINAL_TRANSFER_STATUSES = /* @__PURE__ */ new Set(["COMPLETED", "FAILED", "EXPIRED"]);
|
|
2002
|
+
function isTerminalTransferStatus(status) {
|
|
2003
|
+
return TERMINAL_TRANSFER_STATUSES.has(status);
|
|
2004
|
+
}
|
|
2005
|
+
function isTransferAwaitingCompletion(transfer) {
|
|
2006
|
+
if (!transfer) return false;
|
|
2007
|
+
return !isTerminalTransferStatus(transfer.status);
|
|
2008
|
+
}
|
|
2009
|
+
function resolvePreferredTransfer(polledTransfer, localTransfer) {
|
|
2010
|
+
return polledTransfer ?? localTransfer;
|
|
2011
|
+
}
|
|
2012
|
+
function getTransferStatus(polledTransfer, localTransfer) {
|
|
2013
|
+
const transfer = resolvePreferredTransfer(polledTransfer, localTransfer);
|
|
2014
|
+
return transfer?.status ?? "UNKNOWN";
|
|
2015
|
+
}
|
|
2016
|
+
function hasProcessingTimedOut(processingStartedAtMs, nowMs) {
|
|
2017
|
+
if (!processingStartedAtMs) return false;
|
|
2018
|
+
return nowMs - processingStartedAtMs >= PROCESSING_TIMEOUT_MS;
|
|
2019
|
+
}
|
|
2020
|
+
var STATUS_DISPLAY_LABELS = {
|
|
2021
|
+
CREATED: "created",
|
|
2022
|
+
AUTHORIZED: "authorized",
|
|
2023
|
+
SENDING: "sending",
|
|
2024
|
+
SENT: "confirming delivery",
|
|
2025
|
+
COMPLETED: "completed",
|
|
2026
|
+
FAILED: "failed"
|
|
2027
|
+
};
|
|
2028
|
+
function getStatusDisplayLabel(status) {
|
|
2029
|
+
return STATUS_DISPLAY_LABELS[status] ?? status;
|
|
2030
|
+
}
|
|
2031
|
+
function buildProcessingTimeoutMessage(status) {
|
|
2032
|
+
const label = getStatusDisplayLabel(status);
|
|
2033
|
+
return `Payment is taking longer than expected (status: ${label}). Please try again.`;
|
|
2034
|
+
}
|
|
2035
|
+
|
|
1999
2036
|
// src/paymentResolvePhase.ts
|
|
2000
2037
|
function hasActiveWallet(accounts) {
|
|
2001
2038
|
return accounts.some((a) => a.wallets.some((w) => w.status === "ACTIVE"));
|
|
2002
2039
|
}
|
|
2003
|
-
function isTransferInFlight(transfer) {
|
|
2004
|
-
if (!transfer) return false;
|
|
2005
|
-
return ["CREATED", "SENDING", "SENT"].includes(transfer.status);
|
|
2006
|
-
}
|
|
2007
2040
|
function isGuestPreauthCompletedTransferPinPhase(phase) {
|
|
2008
2041
|
switch (phase.step) {
|
|
2009
2042
|
case "completed":
|
|
@@ -2039,7 +2072,7 @@ function resolvePhase(state) {
|
|
|
2039
2072
|
const c3 = !c1 && !c2 && guestPostPayLogin;
|
|
2040
2073
|
const c4 = !c1 && !c2 && !c3 && transferCompleted && !state.verificationTarget && !needsPasskeyBootstrap;
|
|
2041
2074
|
const c5 = !c1 && !c2 && !c3 && !c4 && state.transfer?.status === "FAILED";
|
|
2042
|
-
const c6 = !c1 && !c2 && !c3 && !c4 && !c5 && (state.creatingTransfer ||
|
|
2075
|
+
const c6 = !c1 && !c2 && !c3 && !c4 && !c5 && (state.creatingTransfer || isTransferAwaitingCompletion(state.transfer));
|
|
2043
2076
|
const c7 = !c1 && !c2 && !c3 && !c4 && !c5 && !c6 && pinSubflow;
|
|
2044
2077
|
const c8 = !c1 && !c2 && !c3 && !c4 && !c5 && !c6 && !c7 && state.mobileFlow && state.deeplinkUri != null;
|
|
2045
2078
|
const c9 = !c1 && !c2 && !c3 && !c4 && !c5 && !c6 && !c7 && !c8 && p.step === "wallet-setup" && p.mobile == null && state.guestPreauthorizing;
|
|
@@ -8471,37 +8504,6 @@ function useDataLoadEffect(deps) {
|
|
|
8471
8504
|
deps
|
|
8472
8505
|
]);
|
|
8473
8506
|
}
|
|
8474
|
-
|
|
8475
|
-
// src/processingStatus.ts
|
|
8476
|
-
var PROCESSING_TIMEOUT_MS = 18e4;
|
|
8477
|
-
function resolvePreferredTransfer(polledTransfer, localTransfer) {
|
|
8478
|
-
return polledTransfer ?? localTransfer;
|
|
8479
|
-
}
|
|
8480
|
-
function getTransferStatus(polledTransfer, localTransfer) {
|
|
8481
|
-
const transfer = resolvePreferredTransfer(polledTransfer, localTransfer);
|
|
8482
|
-
return transfer?.status ?? "UNKNOWN";
|
|
8483
|
-
}
|
|
8484
|
-
function hasProcessingTimedOut(processingStartedAtMs, nowMs) {
|
|
8485
|
-
if (!processingStartedAtMs) return false;
|
|
8486
|
-
return nowMs - processingStartedAtMs >= PROCESSING_TIMEOUT_MS;
|
|
8487
|
-
}
|
|
8488
|
-
var STATUS_DISPLAY_LABELS = {
|
|
8489
|
-
CREATED: "created",
|
|
8490
|
-
AUTHORIZED: "authorized",
|
|
8491
|
-
SENDING: "sending",
|
|
8492
|
-
SENT: "confirming delivery",
|
|
8493
|
-
COMPLETED: "completed",
|
|
8494
|
-
FAILED: "failed"
|
|
8495
|
-
};
|
|
8496
|
-
function getStatusDisplayLabel(status) {
|
|
8497
|
-
return STATUS_DISPLAY_LABELS[status] ?? status;
|
|
8498
|
-
}
|
|
8499
|
-
function buildProcessingTimeoutMessage(status) {
|
|
8500
|
-
const label = getStatusDisplayLabel(status);
|
|
8501
|
-
return `Payment is taking longer than expected (status: ${label}). Please try again.`;
|
|
8502
|
-
}
|
|
8503
|
-
|
|
8504
|
-
// src/hooks/useProcessingEffect.ts
|
|
8505
8507
|
function useProcessingEffect(deps) {
|
|
8506
8508
|
const {
|
|
8507
8509
|
state,
|
|
@@ -8537,7 +8539,7 @@ function useProcessingEffect(deps) {
|
|
|
8537
8539
|
reloadAccounts
|
|
8538
8540
|
]);
|
|
8539
8541
|
useEffect(() => {
|
|
8540
|
-
const isProcessing = state.creatingTransfer ||
|
|
8542
|
+
const isProcessing = state.creatingTransfer || isTransferAwaitingCompletion(state.transfer);
|
|
8541
8543
|
if (!isProcessing) {
|
|
8542
8544
|
processingStartedAtRef.current = null;
|
|
8543
8545
|
return;
|