@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.cjs
CHANGED
|
@@ -811,10 +811,10 @@ function createPasskeyViaPopup(options) {
|
|
|
811
811
|
if (result) {
|
|
812
812
|
resolve(result);
|
|
813
813
|
} else {
|
|
814
|
-
reject(new Error("Passkey
|
|
814
|
+
reject(new Error("Passkey window was closed before completing."));
|
|
815
815
|
}
|
|
816
816
|
}).catch(() => {
|
|
817
|
-
reject(new Error("Passkey
|
|
817
|
+
reject(new Error("Passkey window was closed before completing."));
|
|
818
818
|
});
|
|
819
819
|
}
|
|
820
820
|
}, POPUP_CLOSED_GRACE_MS);
|
|
@@ -1740,6 +1740,9 @@ function resolvePostAuthStep(state) {
|
|
|
1740
1740
|
return { step: "create-passkey", clearPersistedFlow: false };
|
|
1741
1741
|
}
|
|
1742
1742
|
if (state.persistedMobileFlow) {
|
|
1743
|
+
if (state.persistedMobileFlow.isReauthorization) {
|
|
1744
|
+
return { step: "open-wallet", clearPersistedFlow: false };
|
|
1745
|
+
}
|
|
1743
1746
|
if (state.persistedMobileFlow.isSetup && hasActiveWallet(state.accounts)) {
|
|
1744
1747
|
return { step: "deposit", clearPersistedFlow: true };
|
|
1745
1748
|
}
|
|
@@ -3472,7 +3475,7 @@ var hintStyle = (color) => ({
|
|
|
3472
3475
|
color,
|
|
3473
3476
|
margin: "12px 0 0"
|
|
3474
3477
|
});
|
|
3475
|
-
function
|
|
3478
|
+
function PasskeyScreen({
|
|
3476
3479
|
onCreatePasskey,
|
|
3477
3480
|
onBack,
|
|
3478
3481
|
creating,
|
|
@@ -3482,7 +3485,7 @@ function CreatePasskeyScreen({
|
|
|
3482
3485
|
}) {
|
|
3483
3486
|
const { tokens } = useSwypeConfig();
|
|
3484
3487
|
const handleCreate = popupFallback && onCreatePasskeyViaPopup ? onCreatePasskeyViaPopup : onCreatePasskey;
|
|
3485
|
-
const buttonLabel = popupFallback ? "Open passkey
|
|
3488
|
+
const buttonLabel = popupFallback ? "Open passkey window" : "Create or verify passkey";
|
|
3486
3489
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3487
3490
|
ScreenLayout,
|
|
3488
3491
|
{
|
|
@@ -3499,8 +3502,8 @@ function CreatePasskeyScreen({
|
|
|
3499
3502
|
/* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "15", cy: "10", r: "1", fill: tokens.accent }),
|
|
3500
3503
|
/* @__PURE__ */ jsxRuntime.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" })
|
|
3501
3504
|
] }) }),
|
|
3502
|
-
/* @__PURE__ */ jsxRuntime.jsx("h2", { style: headingStyle3(tokens.text), children: "
|
|
3503
|
-
/* @__PURE__ */ jsxRuntime.jsx("p", { style: subtitleStyle3(tokens.textSecondary), children: popupFallback ? "Your browser requires a separate window
|
|
3505
|
+
/* @__PURE__ */ jsxRuntime.jsx("h2", { style: headingStyle3(tokens.text), children: "Create or verify your passkey" }),
|
|
3506
|
+
/* @__PURE__ */ jsxRuntime.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." }),
|
|
3504
3507
|
error && /* @__PURE__ */ jsxRuntime.jsx("div", { style: errorBannerStyle2(tokens), children: error }),
|
|
3505
3508
|
/* @__PURE__ */ jsxRuntime.jsx(InfoBanner, { children: "Your passkey is stored securely on your device. Swype never sees your biometric data." })
|
|
3506
3509
|
] })
|
|
@@ -5632,7 +5635,7 @@ function StepRenderer({
|
|
|
5632
5635
|
}
|
|
5633
5636
|
if (step === "create-passkey") {
|
|
5634
5637
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
5635
|
-
|
|
5638
|
+
PasskeyScreen,
|
|
5636
5639
|
{
|
|
5637
5640
|
onCreatePasskey: handlers.onRegisterPasskey,
|
|
5638
5641
|
onBack: handlers.onLogout,
|
|
@@ -5645,7 +5648,7 @@ function StepRenderer({
|
|
|
5645
5648
|
}
|
|
5646
5649
|
if (step === "verify-passkey") {
|
|
5647
5650
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
5648
|
-
|
|
5651
|
+
PasskeyScreen,
|
|
5649
5652
|
{
|
|
5650
5653
|
onCreatePasskey: handlers.onRegisterPasskey,
|
|
5651
5654
|
onBack: handlers.onLogout,
|
|
@@ -5970,6 +5973,8 @@ function SwypePaymentInner({
|
|
|
5970
5973
|
const initializedSelectSourceActionRef = react.useRef(null);
|
|
5971
5974
|
const preSelectSourceStepRef = react.useRef(null);
|
|
5972
5975
|
const pendingTokenAuthRef = react.useRef(null);
|
|
5976
|
+
const reauthSessionIdRef = react.useRef(null);
|
|
5977
|
+
const reauthTokenRef = react.useRef(null);
|
|
5973
5978
|
const checkingPasskeyRef = react.useRef(false);
|
|
5974
5979
|
const onCompleteRef = react.useRef(onComplete);
|
|
5975
5980
|
onCompleteRef.current = onComplete;
|
|
@@ -6263,7 +6268,7 @@ function SwypePaymentInner({
|
|
|
6263
6268
|
return;
|
|
6264
6269
|
}
|
|
6265
6270
|
if (!state.activeCredentialId) {
|
|
6266
|
-
dispatch({ type: "SET_ERROR", error: "
|
|
6271
|
+
dispatch({ type: "SET_ERROR", error: "Create or verify a passkey on this device before continuing." });
|
|
6267
6272
|
dispatch({ type: "NAVIGATE", step: "create-passkey" });
|
|
6268
6273
|
return;
|
|
6269
6274
|
}
|
|
@@ -6344,7 +6349,7 @@ function SwypePaymentInner({
|
|
|
6344
6349
|
return;
|
|
6345
6350
|
}
|
|
6346
6351
|
if (!state.activeCredentialId) {
|
|
6347
|
-
dispatch({ type: "SET_ERROR", error: "
|
|
6352
|
+
dispatch({ type: "SET_ERROR", error: "Create or verify a passkey on this device before continuing." });
|
|
6348
6353
|
dispatch({ type: "NAVIGATE", step: "create-passkey" });
|
|
6349
6354
|
return;
|
|
6350
6355
|
}
|
|
@@ -6372,12 +6377,15 @@ function SwypePaymentInner({
|
|
|
6372
6377
|
handlingMobileReturnRef.current = false;
|
|
6373
6378
|
mobileSetupFlowRef.current = true;
|
|
6374
6379
|
setupAccountIdRef.current = state.selectedAccountId;
|
|
6380
|
+
reauthSessionIdRef.current = session.id;
|
|
6381
|
+
reauthTokenRef.current = null;
|
|
6375
6382
|
persistMobileFlowState({
|
|
6376
6383
|
accountId: state.selectedAccountId,
|
|
6377
6384
|
sessionId: session.id,
|
|
6378
6385
|
deeplinkUri: session.uri,
|
|
6379
6386
|
providerId: matchedProvider?.id ?? null,
|
|
6380
|
-
isSetup: true
|
|
6387
|
+
isSetup: true,
|
|
6388
|
+
isReauthorization: true
|
|
6381
6389
|
});
|
|
6382
6390
|
dispatch({ type: "MOBILE_DEEPLINK_READY", deeplinkUri: session.uri });
|
|
6383
6391
|
triggerDeeplink(session.uri);
|
|
@@ -6418,7 +6426,7 @@ function SwypePaymentInner({
|
|
|
6418
6426
|
return;
|
|
6419
6427
|
}
|
|
6420
6428
|
if (!state.activeCredentialId) {
|
|
6421
|
-
dispatch({ type: "SET_ERROR", error: "
|
|
6429
|
+
dispatch({ type: "SET_ERROR", error: "Create or verify a passkey on this device before continuing." });
|
|
6422
6430
|
dispatch({ type: "NAVIGATE", step: "create-passkey" });
|
|
6423
6431
|
return;
|
|
6424
6432
|
}
|
|
@@ -6448,12 +6456,16 @@ function SwypePaymentInner({
|
|
|
6448
6456
|
handlingMobileReturnRef.current = false;
|
|
6449
6457
|
mobileSetupFlowRef.current = true;
|
|
6450
6458
|
setupAccountIdRef.current = state.selectedAccountId;
|
|
6459
|
+
reauthSessionIdRef.current = session.id;
|
|
6460
|
+
reauthTokenRef.current = { walletId: _walletId, tokenSymbol };
|
|
6451
6461
|
persistMobileFlowState({
|
|
6452
6462
|
accountId: state.selectedAccountId,
|
|
6453
6463
|
sessionId: session.id,
|
|
6454
6464
|
deeplinkUri: session.uri,
|
|
6455
6465
|
providerId: matchedProvider?.id ?? null,
|
|
6456
|
-
isSetup: true
|
|
6466
|
+
isSetup: true,
|
|
6467
|
+
isReauthorization: true,
|
|
6468
|
+
reauthorizationToken: { walletId: _walletId, tokenSymbol }
|
|
6457
6469
|
});
|
|
6458
6470
|
dispatch({ type: "MOBILE_DEEPLINK_READY", deeplinkUri: session.uri });
|
|
6459
6471
|
triggerDeeplink(session.uri);
|
|
@@ -6515,7 +6527,7 @@ function SwypePaymentInner({
|
|
|
6515
6527
|
const handleSelectProvider = react.useCallback(async (providerId) => {
|
|
6516
6528
|
dispatch({ type: "SELECT_PROVIDER", providerId });
|
|
6517
6529
|
if (!state.activeCredentialId) {
|
|
6518
|
-
dispatch({ type: "SET_ERROR", error: "
|
|
6530
|
+
dispatch({ type: "SET_ERROR", error: "Create or verify a passkey on this device before continuing." });
|
|
6519
6531
|
dispatch({ type: "NAVIGATE", step: "create-passkey" });
|
|
6520
6532
|
return;
|
|
6521
6533
|
}
|
|
@@ -6726,6 +6738,31 @@ function SwypePaymentInner({
|
|
|
6726
6738
|
} catch {
|
|
6727
6739
|
}
|
|
6728
6740
|
}
|
|
6741
|
+
if (resolved.step === "open-wallet" && persisted && persisted.isReauthorization && persisted.sessionId) {
|
|
6742
|
+
try {
|
|
6743
|
+
const session = await fetchAuthorizationSession(apiBaseUrl, persisted.sessionId);
|
|
6744
|
+
if (cancelled) return;
|
|
6745
|
+
if (session.status === "AUTHORIZED") {
|
|
6746
|
+
clearMobileFlowState();
|
|
6747
|
+
dispatch({ type: "NAVIGATE", step: "deposit" });
|
|
6748
|
+
if (persisted.reauthorizationToken) {
|
|
6749
|
+
dispatch({ type: "SELECT_TOKEN", walletId: persisted.reauthorizationToken.walletId, tokenSymbol: persisted.reauthorizationToken.tokenSymbol });
|
|
6750
|
+
}
|
|
6751
|
+
return;
|
|
6752
|
+
}
|
|
6753
|
+
} catch {
|
|
6754
|
+
}
|
|
6755
|
+
reauthSessionIdRef.current = persisted.sessionId;
|
|
6756
|
+
reauthTokenRef.current = persisted.reauthorizationToken ?? null;
|
|
6757
|
+
mobileSetupFlowRef.current = true;
|
|
6758
|
+
setupAccountIdRef.current = persisted.accountId ?? null;
|
|
6759
|
+
dispatch({
|
|
6760
|
+
type: "ENTER_MOBILE_FLOW",
|
|
6761
|
+
deeplinkUri: persisted.deeplinkUri,
|
|
6762
|
+
providerId: persisted.providerId
|
|
6763
|
+
});
|
|
6764
|
+
return;
|
|
6765
|
+
}
|
|
6729
6766
|
if (resolved.step === "open-wallet" && persisted && persisted.accountId && !persisted.transferId) {
|
|
6730
6767
|
clearMobileFlowState();
|
|
6731
6768
|
dispatch({ type: "NAVIGATE", step: "deposit" });
|
|
@@ -6995,9 +7032,36 @@ function SwypePaymentInner({
|
|
|
6995
7032
|
if (!state.activeCredentialId || !setupAccountIdRef.current) return;
|
|
6996
7033
|
const accountId = setupAccountIdRef.current;
|
|
6997
7034
|
const credentialId = state.activeCredentialId;
|
|
7035
|
+
const isReauth = !!reauthSessionIdRef.current;
|
|
7036
|
+
const sessionId = reauthSessionIdRef.current;
|
|
7037
|
+
const tokenSelection = reauthTokenRef.current;
|
|
6998
7038
|
let cancelled = false;
|
|
6999
7039
|
const POLL_INTERVAL_MS = 3e3;
|
|
7000
|
-
const
|
|
7040
|
+
const pollReauthorization = async () => {
|
|
7041
|
+
try {
|
|
7042
|
+
if (!sessionId || cancelled) return;
|
|
7043
|
+
const session = await fetchAuthorizationSession(apiBaseUrl, sessionId);
|
|
7044
|
+
if (cancelled) return;
|
|
7045
|
+
if (session.status === "AUTHORIZED") {
|
|
7046
|
+
cancelled = true;
|
|
7047
|
+
mobileSetupFlowRef.current = false;
|
|
7048
|
+
setupAccountIdRef.current = null;
|
|
7049
|
+
reauthSessionIdRef.current = null;
|
|
7050
|
+
reauthTokenRef.current = null;
|
|
7051
|
+
clearMobileFlowState();
|
|
7052
|
+
try {
|
|
7053
|
+
await reloadAccounts();
|
|
7054
|
+
} catch {
|
|
7055
|
+
}
|
|
7056
|
+
dispatch({ type: "MOBILE_SETUP_COMPLETE" });
|
|
7057
|
+
if (tokenSelection) {
|
|
7058
|
+
dispatch({ type: "SELECT_TOKEN", walletId: tokenSelection.walletId, tokenSymbol: tokenSelection.tokenSymbol });
|
|
7059
|
+
}
|
|
7060
|
+
}
|
|
7061
|
+
} catch {
|
|
7062
|
+
}
|
|
7063
|
+
};
|
|
7064
|
+
const pollWalletActive = async () => {
|
|
7001
7065
|
try {
|
|
7002
7066
|
const token = await getAccessTokenRef.current();
|
|
7003
7067
|
if (!token || cancelled) return;
|
|
@@ -7018,6 +7082,7 @@ function SwypePaymentInner({
|
|
|
7018
7082
|
} catch {
|
|
7019
7083
|
}
|
|
7020
7084
|
};
|
|
7085
|
+
const poll = isReauth ? pollReauthorization : pollWalletActive;
|
|
7021
7086
|
poll();
|
|
7022
7087
|
const intervalId = window.setInterval(poll, POLL_INTERVAL_MS);
|
|
7023
7088
|
const handleVisibility = () => {
|
|
@@ -7187,11 +7252,11 @@ function SwypePaymentInner({
|
|
|
7187
7252
|
}
|
|
7188
7253
|
|
|
7189
7254
|
exports.AdvancedSourceScreen = AdvancedSourceScreen;
|
|
7190
|
-
exports.CreatePasskeyScreen = CreatePasskeyScreen;
|
|
7191
7255
|
exports.IconCircle = IconCircle;
|
|
7192
7256
|
exports.InfoBanner = InfoBanner;
|
|
7193
7257
|
exports.OutlineButton = OutlineButton;
|
|
7194
7258
|
exports.PasskeyIframeBlockedError = PasskeyIframeBlockedError;
|
|
7259
|
+
exports.PasskeyScreen = PasskeyScreen;
|
|
7195
7260
|
exports.PoweredByFooter = PoweredByFooter;
|
|
7196
7261
|
exports.PrimaryButton = PrimaryButton;
|
|
7197
7262
|
exports.ScreenHeader = ScreenHeader;
|