@swype-org/react-sdk 0.1.121 → 0.1.123
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 +81 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +81 -16
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -714,7 +714,7 @@ declare function Spinner({ size, label }: SpinnerProps): react_jsx_runtime.JSX.E
|
|
|
714
714
|
|
|
715
715
|
declare function SwypeLoadingScreen(): react_jsx_runtime.JSX.Element;
|
|
716
716
|
|
|
717
|
-
interface
|
|
717
|
+
interface PasskeyScreenProps {
|
|
718
718
|
onCreatePasskey: () => void;
|
|
719
719
|
onBack?: () => void;
|
|
720
720
|
creating: boolean;
|
|
@@ -724,7 +724,7 @@ interface CreatePasskeyScreenProps {
|
|
|
724
724
|
/** Opens a pop-up window on the Swype domain for passkey registration. */
|
|
725
725
|
onCreatePasskeyViaPopup?: () => void;
|
|
726
726
|
}
|
|
727
|
-
declare function
|
|
727
|
+
declare function PasskeyScreen({ onCreatePasskey, onBack, creating, error, popupFallback, onCreatePasskeyViaPopup, }: PasskeyScreenProps): react_jsx_runtime.JSX.Element;
|
|
728
728
|
|
|
729
729
|
interface SetupScreenProps {
|
|
730
730
|
availableBalance: number;
|
|
@@ -797,4 +797,4 @@ interface TokenPickerScreenProps {
|
|
|
797
797
|
}
|
|
798
798
|
declare function TokenPickerScreen({ account, chains, onSelectAuthorized, onAuthorizeToken, onBack, }: TokenPickerScreenProps): react_jsx_runtime.JSX.Element;
|
|
799
799
|
|
|
800
|
-
export { type Account, type ActionExecutionResult, type AdvancedSettings, AdvancedSourceScreen, type Amount, type AuthorizationAction, type AuthorizationSession, type AuthorizationSessionDetail, type Chain,
|
|
800
|
+
export { type Account, type ActionExecutionResult, type AdvancedSettings, AdvancedSourceScreen, type Amount, type AuthorizationAction, type AuthorizationSession, type AuthorizationSessionDetail, type Chain, type Destination, type ErrorResponse, IconCircle, InfoBanner, type ListResponse, type MerchantAuthorization, type MerchantPublicKey, OutlineButton, PasskeyIframeBlockedError, PasskeyScreen, type PaymentStep, PoweredByFooter, PrimaryButton, type Provider, ScreenHeader, ScreenLayout, SelectSourceScreen, SettingsMenu, SetupScreen, type SourceOption, type SourceSelection, type SourceType, Spinner, type StepItem, StepList, SwypeLoadingScreen, SwypePayment, type SwypePaymentProps, SwypeProvider, type SwypeProviderProps, type ThemeMode, type ThemeTokens, type TokenBalance, TokenPickerScreen, type Transfer, type TransferDestination, type UserConfig, type Wallet, type WalletSource, type WalletToken, buildPasskeyPopupOptions, createPasskeyCredential, createPasskeyViaPopup, darkTheme, deviceHasPasskey, findDevicePasskey, findDevicePasskeyViaPopup, getTheme, lightTheme, resolvePasskeyRpId, api as swypeApi, useAuthorizationExecutor, useSwypeConfig, useSwypeDepositAmount, useTransferPolling, useTransferSigning };
|
package/dist/index.d.ts
CHANGED
|
@@ -714,7 +714,7 @@ declare function Spinner({ size, label }: SpinnerProps): react_jsx_runtime.JSX.E
|
|
|
714
714
|
|
|
715
715
|
declare function SwypeLoadingScreen(): react_jsx_runtime.JSX.Element;
|
|
716
716
|
|
|
717
|
-
interface
|
|
717
|
+
interface PasskeyScreenProps {
|
|
718
718
|
onCreatePasskey: () => void;
|
|
719
719
|
onBack?: () => void;
|
|
720
720
|
creating: boolean;
|
|
@@ -724,7 +724,7 @@ interface CreatePasskeyScreenProps {
|
|
|
724
724
|
/** Opens a pop-up window on the Swype domain for passkey registration. */
|
|
725
725
|
onCreatePasskeyViaPopup?: () => void;
|
|
726
726
|
}
|
|
727
|
-
declare function
|
|
727
|
+
declare function PasskeyScreen({ onCreatePasskey, onBack, creating, error, popupFallback, onCreatePasskeyViaPopup, }: PasskeyScreenProps): react_jsx_runtime.JSX.Element;
|
|
728
728
|
|
|
729
729
|
interface SetupScreenProps {
|
|
730
730
|
availableBalance: number;
|
|
@@ -797,4 +797,4 @@ interface TokenPickerScreenProps {
|
|
|
797
797
|
}
|
|
798
798
|
declare function TokenPickerScreen({ account, chains, onSelectAuthorized, onAuthorizeToken, onBack, }: TokenPickerScreenProps): react_jsx_runtime.JSX.Element;
|
|
799
799
|
|
|
800
|
-
export { type Account, type ActionExecutionResult, type AdvancedSettings, AdvancedSourceScreen, type Amount, type AuthorizationAction, type AuthorizationSession, type AuthorizationSessionDetail, type Chain,
|
|
800
|
+
export { type Account, type ActionExecutionResult, type AdvancedSettings, AdvancedSourceScreen, type Amount, type AuthorizationAction, type AuthorizationSession, type AuthorizationSessionDetail, type Chain, type Destination, type ErrorResponse, IconCircle, InfoBanner, type ListResponse, type MerchantAuthorization, type MerchantPublicKey, OutlineButton, PasskeyIframeBlockedError, PasskeyScreen, type PaymentStep, PoweredByFooter, PrimaryButton, type Provider, ScreenHeader, ScreenLayout, SelectSourceScreen, SettingsMenu, SetupScreen, type SourceOption, type SourceSelection, type SourceType, Spinner, type StepItem, StepList, SwypeLoadingScreen, SwypePayment, type SwypePaymentProps, SwypeProvider, type SwypeProviderProps, type ThemeMode, type ThemeTokens, type TokenBalance, TokenPickerScreen, type Transfer, type TransferDestination, type UserConfig, type Wallet, type WalletSource, type WalletToken, buildPasskeyPopupOptions, createPasskeyCredential, createPasskeyViaPopup, darkTheme, deviceHasPasskey, findDevicePasskey, findDevicePasskeyViaPopup, getTheme, lightTheme, resolvePasskeyRpId, api as swypeApi, useAuthorizationExecutor, useSwypeConfig, useSwypeDepositAmount, useTransferPolling, useTransferSigning };
|
package/dist/index.js
CHANGED
|
@@ -808,10 +808,10 @@ function createPasskeyViaPopup(options) {
|
|
|
808
808
|
if (result) {
|
|
809
809
|
resolve(result);
|
|
810
810
|
} else {
|
|
811
|
-
reject(new Error("Passkey
|
|
811
|
+
reject(new Error("Passkey window was closed before completing."));
|
|
812
812
|
}
|
|
813
813
|
}).catch(() => {
|
|
814
|
-
reject(new Error("Passkey
|
|
814
|
+
reject(new Error("Passkey window was closed before completing."));
|
|
815
815
|
});
|
|
816
816
|
}
|
|
817
817
|
}, POPUP_CLOSED_GRACE_MS);
|
|
@@ -1737,6 +1737,9 @@ function resolvePostAuthStep(state) {
|
|
|
1737
1737
|
return { step: "create-passkey", clearPersistedFlow: false };
|
|
1738
1738
|
}
|
|
1739
1739
|
if (state.persistedMobileFlow) {
|
|
1740
|
+
if (state.persistedMobileFlow.isReauthorization) {
|
|
1741
|
+
return { step: "open-wallet", clearPersistedFlow: false };
|
|
1742
|
+
}
|
|
1740
1743
|
if (state.persistedMobileFlow.isSetup && hasActiveWallet(state.accounts)) {
|
|
1741
1744
|
return { step: "deposit", clearPersistedFlow: true };
|
|
1742
1745
|
}
|
|
@@ -3469,7 +3472,7 @@ var hintStyle = (color) => ({
|
|
|
3469
3472
|
color,
|
|
3470
3473
|
margin: "12px 0 0"
|
|
3471
3474
|
});
|
|
3472
|
-
function
|
|
3475
|
+
function PasskeyScreen({
|
|
3473
3476
|
onCreatePasskey,
|
|
3474
3477
|
onBack,
|
|
3475
3478
|
creating,
|
|
@@ -3479,7 +3482,7 @@ function CreatePasskeyScreen({
|
|
|
3479
3482
|
}) {
|
|
3480
3483
|
const { tokens } = useSwypeConfig();
|
|
3481
3484
|
const handleCreate = popupFallback && onCreatePasskeyViaPopup ? onCreatePasskeyViaPopup : onCreatePasskey;
|
|
3482
|
-
const buttonLabel = popupFallback ? "Open passkey
|
|
3485
|
+
const buttonLabel = popupFallback ? "Open passkey window" : "Create or verify passkey";
|
|
3483
3486
|
return /* @__PURE__ */ jsxs(
|
|
3484
3487
|
ScreenLayout,
|
|
3485
3488
|
{
|
|
@@ -3496,8 +3499,8 @@ function CreatePasskeyScreen({
|
|
|
3496
3499
|
/* @__PURE__ */ jsx("circle", { cx: "15", cy: "10", r: "1", fill: tokens.accent }),
|
|
3497
3500
|
/* @__PURE__ */ jsx("path", { d: "M9 14c0 1.5 1.34 2.5 3 2.5s3-1 3-2.5", stroke: tokens.accent, strokeWidth: "1.2", strokeLinecap: "round" })
|
|
3498
3501
|
] }) }),
|
|
3499
|
-
/* @__PURE__ */ jsx("h2", { style: headingStyle3(tokens.text), children: "
|
|
3500
|
-
/* @__PURE__ */ jsx("p", { style: subtitleStyle3(tokens.textSecondary), children: popupFallback ? "Your browser requires a separate window
|
|
3502
|
+
/* @__PURE__ */ jsx("h2", { style: headingStyle3(tokens.text), children: "Create or verify your passkey" }),
|
|
3503
|
+
/* @__PURE__ */ jsx("p", { style: subtitleStyle3(tokens.textSecondary), children: popupFallback ? "Your browser requires a separate window to continue. Tap the button below to continue." : "Use Face ID to sign in instantly \u2014 no passwords, no codes." }),
|
|
3501
3504
|
error && /* @__PURE__ */ jsx("div", { style: errorBannerStyle2(tokens), children: error }),
|
|
3502
3505
|
/* @__PURE__ */ jsx(InfoBanner, { children: "Your passkey is stored securely on your device. Swype never sees your biometric data." })
|
|
3503
3506
|
] })
|
|
@@ -5629,7 +5632,7 @@ function StepRenderer({
|
|
|
5629
5632
|
}
|
|
5630
5633
|
if (step === "create-passkey") {
|
|
5631
5634
|
return /* @__PURE__ */ jsx(
|
|
5632
|
-
|
|
5635
|
+
PasskeyScreen,
|
|
5633
5636
|
{
|
|
5634
5637
|
onCreatePasskey: handlers.onRegisterPasskey,
|
|
5635
5638
|
onBack: handlers.onLogout,
|
|
@@ -5642,7 +5645,7 @@ function StepRenderer({
|
|
|
5642
5645
|
}
|
|
5643
5646
|
if (step === "verify-passkey") {
|
|
5644
5647
|
return /* @__PURE__ */ jsx(
|
|
5645
|
-
|
|
5648
|
+
PasskeyScreen,
|
|
5646
5649
|
{
|
|
5647
5650
|
onCreatePasskey: handlers.onRegisterPasskey,
|
|
5648
5651
|
onBack: handlers.onLogout,
|
|
@@ -5967,6 +5970,8 @@ function SwypePaymentInner({
|
|
|
5967
5970
|
const initializedSelectSourceActionRef = useRef(null);
|
|
5968
5971
|
const preSelectSourceStepRef = useRef(null);
|
|
5969
5972
|
const pendingTokenAuthRef = useRef(null);
|
|
5973
|
+
const reauthSessionIdRef = useRef(null);
|
|
5974
|
+
const reauthTokenRef = useRef(null);
|
|
5970
5975
|
const checkingPasskeyRef = useRef(false);
|
|
5971
5976
|
const onCompleteRef = useRef(onComplete);
|
|
5972
5977
|
onCompleteRef.current = onComplete;
|
|
@@ -6260,7 +6265,7 @@ function SwypePaymentInner({
|
|
|
6260
6265
|
return;
|
|
6261
6266
|
}
|
|
6262
6267
|
if (!state.activeCredentialId) {
|
|
6263
|
-
dispatch({ type: "SET_ERROR", error: "
|
|
6268
|
+
dispatch({ type: "SET_ERROR", error: "Create or verify a passkey on this device before continuing." });
|
|
6264
6269
|
dispatch({ type: "NAVIGATE", step: "create-passkey" });
|
|
6265
6270
|
return;
|
|
6266
6271
|
}
|
|
@@ -6341,7 +6346,7 @@ function SwypePaymentInner({
|
|
|
6341
6346
|
return;
|
|
6342
6347
|
}
|
|
6343
6348
|
if (!state.activeCredentialId) {
|
|
6344
|
-
dispatch({ type: "SET_ERROR", error: "
|
|
6349
|
+
dispatch({ type: "SET_ERROR", error: "Create or verify a passkey on this device before continuing." });
|
|
6345
6350
|
dispatch({ type: "NAVIGATE", step: "create-passkey" });
|
|
6346
6351
|
return;
|
|
6347
6352
|
}
|
|
@@ -6369,12 +6374,15 @@ function SwypePaymentInner({
|
|
|
6369
6374
|
handlingMobileReturnRef.current = false;
|
|
6370
6375
|
mobileSetupFlowRef.current = true;
|
|
6371
6376
|
setupAccountIdRef.current = state.selectedAccountId;
|
|
6377
|
+
reauthSessionIdRef.current = session.id;
|
|
6378
|
+
reauthTokenRef.current = null;
|
|
6372
6379
|
persistMobileFlowState({
|
|
6373
6380
|
accountId: state.selectedAccountId,
|
|
6374
6381
|
sessionId: session.id,
|
|
6375
6382
|
deeplinkUri: session.uri,
|
|
6376
6383
|
providerId: matchedProvider?.id ?? null,
|
|
6377
|
-
isSetup: true
|
|
6384
|
+
isSetup: true,
|
|
6385
|
+
isReauthorization: true
|
|
6378
6386
|
});
|
|
6379
6387
|
dispatch({ type: "MOBILE_DEEPLINK_READY", deeplinkUri: session.uri });
|
|
6380
6388
|
triggerDeeplink(session.uri);
|
|
@@ -6415,7 +6423,7 @@ function SwypePaymentInner({
|
|
|
6415
6423
|
return;
|
|
6416
6424
|
}
|
|
6417
6425
|
if (!state.activeCredentialId) {
|
|
6418
|
-
dispatch({ type: "SET_ERROR", error: "
|
|
6426
|
+
dispatch({ type: "SET_ERROR", error: "Create or verify a passkey on this device before continuing." });
|
|
6419
6427
|
dispatch({ type: "NAVIGATE", step: "create-passkey" });
|
|
6420
6428
|
return;
|
|
6421
6429
|
}
|
|
@@ -6445,12 +6453,16 @@ function SwypePaymentInner({
|
|
|
6445
6453
|
handlingMobileReturnRef.current = false;
|
|
6446
6454
|
mobileSetupFlowRef.current = true;
|
|
6447
6455
|
setupAccountIdRef.current = state.selectedAccountId;
|
|
6456
|
+
reauthSessionIdRef.current = session.id;
|
|
6457
|
+
reauthTokenRef.current = { walletId: _walletId, tokenSymbol };
|
|
6448
6458
|
persistMobileFlowState({
|
|
6449
6459
|
accountId: state.selectedAccountId,
|
|
6450
6460
|
sessionId: session.id,
|
|
6451
6461
|
deeplinkUri: session.uri,
|
|
6452
6462
|
providerId: matchedProvider?.id ?? null,
|
|
6453
|
-
isSetup: true
|
|
6463
|
+
isSetup: true,
|
|
6464
|
+
isReauthorization: true,
|
|
6465
|
+
reauthorizationToken: { walletId: _walletId, tokenSymbol }
|
|
6454
6466
|
});
|
|
6455
6467
|
dispatch({ type: "MOBILE_DEEPLINK_READY", deeplinkUri: session.uri });
|
|
6456
6468
|
triggerDeeplink(session.uri);
|
|
@@ -6512,7 +6524,7 @@ function SwypePaymentInner({
|
|
|
6512
6524
|
const handleSelectProvider = useCallback(async (providerId) => {
|
|
6513
6525
|
dispatch({ type: "SELECT_PROVIDER", providerId });
|
|
6514
6526
|
if (!state.activeCredentialId) {
|
|
6515
|
-
dispatch({ type: "SET_ERROR", error: "
|
|
6527
|
+
dispatch({ type: "SET_ERROR", error: "Create or verify a passkey on this device before continuing." });
|
|
6516
6528
|
dispatch({ type: "NAVIGATE", step: "create-passkey" });
|
|
6517
6529
|
return;
|
|
6518
6530
|
}
|
|
@@ -6723,6 +6735,31 @@ function SwypePaymentInner({
|
|
|
6723
6735
|
} catch {
|
|
6724
6736
|
}
|
|
6725
6737
|
}
|
|
6738
|
+
if (resolved.step === "open-wallet" && persisted && persisted.isReauthorization && persisted.sessionId) {
|
|
6739
|
+
try {
|
|
6740
|
+
const session = await fetchAuthorizationSession(apiBaseUrl, persisted.sessionId);
|
|
6741
|
+
if (cancelled) return;
|
|
6742
|
+
if (session.status === "AUTHORIZED") {
|
|
6743
|
+
clearMobileFlowState();
|
|
6744
|
+
dispatch({ type: "NAVIGATE", step: "deposit" });
|
|
6745
|
+
if (persisted.reauthorizationToken) {
|
|
6746
|
+
dispatch({ type: "SELECT_TOKEN", walletId: persisted.reauthorizationToken.walletId, tokenSymbol: persisted.reauthorizationToken.tokenSymbol });
|
|
6747
|
+
}
|
|
6748
|
+
return;
|
|
6749
|
+
}
|
|
6750
|
+
} catch {
|
|
6751
|
+
}
|
|
6752
|
+
reauthSessionIdRef.current = persisted.sessionId;
|
|
6753
|
+
reauthTokenRef.current = persisted.reauthorizationToken ?? null;
|
|
6754
|
+
mobileSetupFlowRef.current = true;
|
|
6755
|
+
setupAccountIdRef.current = persisted.accountId ?? null;
|
|
6756
|
+
dispatch({
|
|
6757
|
+
type: "ENTER_MOBILE_FLOW",
|
|
6758
|
+
deeplinkUri: persisted.deeplinkUri,
|
|
6759
|
+
providerId: persisted.providerId
|
|
6760
|
+
});
|
|
6761
|
+
return;
|
|
6762
|
+
}
|
|
6726
6763
|
if (resolved.step === "open-wallet" && persisted && persisted.accountId && !persisted.transferId) {
|
|
6727
6764
|
clearMobileFlowState();
|
|
6728
6765
|
dispatch({ type: "NAVIGATE", step: "deposit" });
|
|
@@ -6992,9 +7029,36 @@ function SwypePaymentInner({
|
|
|
6992
7029
|
if (!state.activeCredentialId || !setupAccountIdRef.current) return;
|
|
6993
7030
|
const accountId = setupAccountIdRef.current;
|
|
6994
7031
|
const credentialId = state.activeCredentialId;
|
|
7032
|
+
const isReauth = !!reauthSessionIdRef.current;
|
|
7033
|
+
const sessionId = reauthSessionIdRef.current;
|
|
7034
|
+
const tokenSelection = reauthTokenRef.current;
|
|
6995
7035
|
let cancelled = false;
|
|
6996
7036
|
const POLL_INTERVAL_MS = 3e3;
|
|
6997
|
-
const
|
|
7037
|
+
const pollReauthorization = async () => {
|
|
7038
|
+
try {
|
|
7039
|
+
if (!sessionId || cancelled) return;
|
|
7040
|
+
const session = await fetchAuthorizationSession(apiBaseUrl, sessionId);
|
|
7041
|
+
if (cancelled) return;
|
|
7042
|
+
if (session.status === "AUTHORIZED") {
|
|
7043
|
+
cancelled = true;
|
|
7044
|
+
mobileSetupFlowRef.current = false;
|
|
7045
|
+
setupAccountIdRef.current = null;
|
|
7046
|
+
reauthSessionIdRef.current = null;
|
|
7047
|
+
reauthTokenRef.current = null;
|
|
7048
|
+
clearMobileFlowState();
|
|
7049
|
+
try {
|
|
7050
|
+
await reloadAccounts();
|
|
7051
|
+
} catch {
|
|
7052
|
+
}
|
|
7053
|
+
dispatch({ type: "MOBILE_SETUP_COMPLETE" });
|
|
7054
|
+
if (tokenSelection) {
|
|
7055
|
+
dispatch({ type: "SELECT_TOKEN", walletId: tokenSelection.walletId, tokenSymbol: tokenSelection.tokenSymbol });
|
|
7056
|
+
}
|
|
7057
|
+
}
|
|
7058
|
+
} catch {
|
|
7059
|
+
}
|
|
7060
|
+
};
|
|
7061
|
+
const pollWalletActive = async () => {
|
|
6998
7062
|
try {
|
|
6999
7063
|
const token = await getAccessTokenRef.current();
|
|
7000
7064
|
if (!token || cancelled) return;
|
|
@@ -7015,6 +7079,7 @@ function SwypePaymentInner({
|
|
|
7015
7079
|
} catch {
|
|
7016
7080
|
}
|
|
7017
7081
|
};
|
|
7082
|
+
const poll = isReauth ? pollReauthorization : pollWalletActive;
|
|
7018
7083
|
poll();
|
|
7019
7084
|
const intervalId = window.setInterval(poll, POLL_INTERVAL_MS);
|
|
7020
7085
|
const handleVisibility = () => {
|
|
@@ -7183,6 +7248,6 @@ function SwypePaymentInner({
|
|
|
7183
7248
|
);
|
|
7184
7249
|
}
|
|
7185
7250
|
|
|
7186
|
-
export { AdvancedSourceScreen,
|
|
7251
|
+
export { AdvancedSourceScreen, IconCircle, InfoBanner, OutlineButton, PasskeyIframeBlockedError, PasskeyScreen, PoweredByFooter, PrimaryButton, ScreenHeader, ScreenLayout, SelectSourceScreen, SettingsMenu, SetupScreen, Spinner, StepList, SwypeLoadingScreen, SwypePayment, SwypeProvider, TokenPickerScreen, buildPasskeyPopupOptions, createPasskeyCredential, createPasskeyViaPopup, darkTheme, deviceHasPasskey, findDevicePasskey, findDevicePasskeyViaPopup, getTheme, lightTheme, resolvePasskeyRpId, api_exports as swypeApi, useAuthorizationExecutor, useSwypeConfig, useSwypeDepositAmount, useTransferPolling, useTransferSigning };
|
|
7187
7252
|
//# sourceMappingURL=index.js.map
|
|
7188
7253
|
//# sourceMappingURL=index.js.map
|