@swype-org/react-sdk 0.1.148 → 0.1.152
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 +46 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +46 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3070,8 +3070,8 @@ function LoginScreen({
|
|
|
3070
3070
|
}
|
|
3071
3071
|
),
|
|
3072
3072
|
/* @__PURE__ */ jsxs("div", { style: contentStyle2, children: [
|
|
3073
|
-
/* @__PURE__ */ jsx("div", { style: iconBoxStyle(tokens.accent), children: /* @__PURE__ */ jsx("span", { style: iconLetterStyle, children: "
|
|
3074
|
-
/* @__PURE__ */ jsx("h2", { style: headingStyle(tokens.text), children: "Your Money
|
|
3073
|
+
/* @__PURE__ */ jsx("div", { style: iconBoxStyle(tokens.accent), children: /* @__PURE__ */ jsx("span", { style: iconLetterStyle, children: "B" }) }),
|
|
3074
|
+
/* @__PURE__ */ jsx("h2", { style: headingStyle(tokens.text), children: "Your Money.\nAny App.\nOne Tap." }),
|
|
3075
3075
|
error && /* @__PURE__ */ jsx("div", { style: errorStyle(tokens), children: error }),
|
|
3076
3076
|
/* @__PURE__ */ jsx(
|
|
3077
3077
|
"input",
|
|
@@ -3110,7 +3110,7 @@ var contentStyle2 = {
|
|
|
3110
3110
|
display: "flex",
|
|
3111
3111
|
flexDirection: "column",
|
|
3112
3112
|
alignItems: "center",
|
|
3113
|
-
|
|
3113
|
+
justifyContent: "center"
|
|
3114
3114
|
};
|
|
3115
3115
|
var iconBoxStyle = (accent) => ({
|
|
3116
3116
|
width: 56,
|
|
@@ -3334,7 +3334,7 @@ function PasskeyScreen({
|
|
|
3334
3334
|
}) {
|
|
3335
3335
|
const { tokens } = useSwypeConfig();
|
|
3336
3336
|
const handleCreate = popupFallback && onCreatePasskeyViaPopup ? onCreatePasskeyViaPopup : onCreatePasskey;
|
|
3337
|
-
const buttonLabel = popupFallback ? "Open
|
|
3337
|
+
const buttonLabel = popupFallback ? "Open Passkey Window" : "Verify Passkey";
|
|
3338
3338
|
return /* @__PURE__ */ jsxs(
|
|
3339
3339
|
ScreenLayout,
|
|
3340
3340
|
{
|
|
@@ -3358,7 +3358,7 @@ var contentStyle4 = {
|
|
|
3358
3358
|
display: "flex",
|
|
3359
3359
|
flexDirection: "column",
|
|
3360
3360
|
alignItems: "center",
|
|
3361
|
-
|
|
3361
|
+
justifyContent: "center"
|
|
3362
3362
|
};
|
|
3363
3363
|
var headingStyle3 = (color) => ({
|
|
3364
3364
|
fontSize: "1.45rem",
|
|
@@ -3854,7 +3854,8 @@ var headingStyle5 = (color) => ({
|
|
|
3854
3854
|
fontWeight: 700,
|
|
3855
3855
|
letterSpacing: "-0.02em",
|
|
3856
3856
|
color,
|
|
3857
|
-
margin: "
|
|
3857
|
+
margin: "24px 0 20px",
|
|
3858
|
+
textAlign: "center"
|
|
3858
3859
|
});
|
|
3859
3860
|
var errorBannerStyle3 = (tokens) => ({
|
|
3860
3861
|
background: tokens.errorBg,
|
|
@@ -6043,6 +6044,24 @@ function resolveRestoredMobileFlow(transferStatus, isSetup) {
|
|
|
6043
6044
|
function usePasskeyHandlers(dispatch, apiBaseUrl, accounts, knownCredentialIds, mobileSetupFlowRef) {
|
|
6044
6045
|
const { user, getAccessToken } = usePrivy();
|
|
6045
6046
|
const checkingPasskeyRef = useRef(false);
|
|
6047
|
+
const activateExistingCredential = useCallback(async (credentialId) => {
|
|
6048
|
+
dispatch({ type: "PASSKEY_ACTIVATED", credentialId });
|
|
6049
|
+
window.localStorage.setItem(ACTIVE_CREDENTIAL_STORAGE_KEY, credentialId);
|
|
6050
|
+
const token = await getAccessToken();
|
|
6051
|
+
if (token) {
|
|
6052
|
+
reportPasskeyActivity(apiBaseUrl, token, credentialId).catch(() => {
|
|
6053
|
+
});
|
|
6054
|
+
}
|
|
6055
|
+
const resolved = resolvePostAuthStep({
|
|
6056
|
+
hasPasskey: true,
|
|
6057
|
+
accounts,
|
|
6058
|
+
persistedMobileFlow: loadMobileFlowState(),
|
|
6059
|
+
mobileSetupInProgress: mobileSetupFlowRef.current,
|
|
6060
|
+
connectingNewAccount: false
|
|
6061
|
+
});
|
|
6062
|
+
if (resolved.clearPersistedFlow) clearMobileFlowState();
|
|
6063
|
+
dispatch({ type: "NAVIGATE", step: resolved.step });
|
|
6064
|
+
}, [getAccessToken, apiBaseUrl, accounts, mobileSetupFlowRef, dispatch]);
|
|
6046
6065
|
const completePasskeyRegistration = useCallback(async (credentialId, publicKey) => {
|
|
6047
6066
|
const token = await getAccessToken();
|
|
6048
6067
|
if (!token) throw new Error("Not authenticated");
|
|
@@ -6063,6 +6082,13 @@ function usePasskeyHandlers(dispatch, apiBaseUrl, accounts, knownCredentialIds,
|
|
|
6063
6082
|
dispatch({ type: "SET_REGISTERING_PASSKEY", value: true });
|
|
6064
6083
|
dispatch({ type: "SET_ERROR", error: null });
|
|
6065
6084
|
try {
|
|
6085
|
+
if (knownCredentialIds.length > 0) {
|
|
6086
|
+
const matched = await findDevicePasskey(knownCredentialIds);
|
|
6087
|
+
if (matched) {
|
|
6088
|
+
await activateExistingCredential(matched);
|
|
6089
|
+
return;
|
|
6090
|
+
}
|
|
6091
|
+
}
|
|
6066
6092
|
const passkeyDisplayName = user?.email?.address ?? user?.google?.name ?? user?.id ?? "Swype User";
|
|
6067
6093
|
const { credentialId, publicKey } = await createPasskeyCredential({
|
|
6068
6094
|
userId: user?.id ?? "unknown",
|
|
@@ -6082,12 +6108,24 @@ function usePasskeyHandlers(dispatch, apiBaseUrl, accounts, knownCredentialIds,
|
|
|
6082
6108
|
} finally {
|
|
6083
6109
|
dispatch({ type: "SET_REGISTERING_PASSKEY", value: false });
|
|
6084
6110
|
}
|
|
6085
|
-
}, [user, completePasskeyRegistration, dispatch]);
|
|
6111
|
+
}, [user, knownCredentialIds, activateExistingCredential, completePasskeyRegistration, dispatch]);
|
|
6086
6112
|
const handleCreatePasskeyViaPopup = useCallback(async () => {
|
|
6087
6113
|
dispatch({ type: "SET_REGISTERING_PASSKEY", value: true });
|
|
6088
6114
|
dispatch({ type: "SET_ERROR", error: null });
|
|
6089
6115
|
try {
|
|
6090
6116
|
const token = await getAccessToken();
|
|
6117
|
+
if (knownCredentialIds.length > 0) {
|
|
6118
|
+
const matched = await findDevicePasskeyViaPopup({
|
|
6119
|
+
credentialIds: knownCredentialIds,
|
|
6120
|
+
rpId: resolvePasskeyRpId(),
|
|
6121
|
+
authToken: token ?? void 0,
|
|
6122
|
+
apiBaseUrl
|
|
6123
|
+
});
|
|
6124
|
+
if (matched) {
|
|
6125
|
+
await activateExistingCredential(matched);
|
|
6126
|
+
return;
|
|
6127
|
+
}
|
|
6128
|
+
}
|
|
6091
6129
|
const passkeyDisplayName = user?.email?.address ?? user?.google?.name ?? user?.id ?? "Swype User";
|
|
6092
6130
|
const popupOptions = buildPasskeyPopupOptions({
|
|
6093
6131
|
userId: user?.id ?? "unknown",
|
|
@@ -6116,7 +6154,7 @@ function usePasskeyHandlers(dispatch, apiBaseUrl, accounts, knownCredentialIds,
|
|
|
6116
6154
|
} finally {
|
|
6117
6155
|
dispatch({ type: "SET_REGISTERING_PASSKEY", value: false });
|
|
6118
6156
|
}
|
|
6119
|
-
}, [user, getAccessToken, apiBaseUrl, accounts, mobileSetupFlowRef, dispatch]);
|
|
6157
|
+
}, [user, knownCredentialIds, getAccessToken, apiBaseUrl, activateExistingCredential, accounts, mobileSetupFlowRef, dispatch]);
|
|
6120
6158
|
const handleVerifyPasskeyViaPopup = useCallback(async () => {
|
|
6121
6159
|
dispatch({ type: "SET_VERIFYING_PASSKEY", value: true });
|
|
6122
6160
|
dispatch({ type: "SET_ERROR", error: null });
|