@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 CHANGED
@@ -3073,8 +3073,8 @@ function LoginScreen({
3073
3073
  }
3074
3074
  ),
3075
3075
  /* @__PURE__ */ jsxRuntime.jsxs("div", { style: contentStyle2, children: [
3076
- /* @__PURE__ */ jsxRuntime.jsx("div", { style: iconBoxStyle(tokens.accent), children: /* @__PURE__ */ jsxRuntime.jsx("span", { style: iconLetterStyle, children: "S" }) }),
3077
- /* @__PURE__ */ jsxRuntime.jsx("h2", { style: headingStyle(tokens.text), children: "Your Money. Any App. One Tap." }),
3076
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: iconBoxStyle(tokens.accent), children: /* @__PURE__ */ jsxRuntime.jsx("span", { style: iconLetterStyle, children: "B" }) }),
3077
+ /* @__PURE__ */ jsxRuntime.jsx("h2", { style: headingStyle(tokens.text), children: "Your Money.\nAny App.\nOne Tap." }),
3078
3078
  error && /* @__PURE__ */ jsxRuntime.jsx("div", { style: errorStyle(tokens), children: error }),
3079
3079
  /* @__PURE__ */ jsxRuntime.jsx(
3080
3080
  "input",
@@ -3113,7 +3113,7 @@ var contentStyle2 = {
3113
3113
  display: "flex",
3114
3114
  flexDirection: "column",
3115
3115
  alignItems: "center",
3116
- paddingTop: 24
3116
+ justifyContent: "center"
3117
3117
  };
3118
3118
  var iconBoxStyle = (accent) => ({
3119
3119
  width: 56,
@@ -3337,7 +3337,7 @@ function PasskeyScreen({
3337
3337
  }) {
3338
3338
  const { tokens } = useSwypeConfig();
3339
3339
  const handleCreate = popupFallback && onCreatePasskeyViaPopup ? onCreatePasskeyViaPopup : onCreatePasskey;
3340
- const buttonLabel = popupFallback ? "Open passkey window" : "Verify PassKey";
3340
+ const buttonLabel = popupFallback ? "Open Passkey Window" : "Verify Passkey";
3341
3341
  return /* @__PURE__ */ jsxRuntime.jsxs(
3342
3342
  ScreenLayout,
3343
3343
  {
@@ -3361,7 +3361,7 @@ var contentStyle4 = {
3361
3361
  display: "flex",
3362
3362
  flexDirection: "column",
3363
3363
  alignItems: "center",
3364
- paddingTop: 32
3364
+ justifyContent: "center"
3365
3365
  };
3366
3366
  var headingStyle3 = (color) => ({
3367
3367
  fontSize: "1.45rem",
@@ -3857,7 +3857,8 @@ var headingStyle5 = (color) => ({
3857
3857
  fontWeight: 700,
3858
3858
  letterSpacing: "-0.02em",
3859
3859
  color,
3860
- margin: "8px 0 4px"
3860
+ margin: "24px 0 20px",
3861
+ textAlign: "center"
3861
3862
  });
3862
3863
  var errorBannerStyle3 = (tokens) => ({
3863
3864
  background: tokens.errorBg,
@@ -6046,6 +6047,24 @@ function resolveRestoredMobileFlow(transferStatus, isSetup) {
6046
6047
  function usePasskeyHandlers(dispatch, apiBaseUrl, accounts, knownCredentialIds, mobileSetupFlowRef) {
6047
6048
  const { user, getAccessToken } = reactAuth.usePrivy();
6048
6049
  const checkingPasskeyRef = react.useRef(false);
6050
+ const activateExistingCredential = react.useCallback(async (credentialId) => {
6051
+ dispatch({ type: "PASSKEY_ACTIVATED", credentialId });
6052
+ window.localStorage.setItem(ACTIVE_CREDENTIAL_STORAGE_KEY, credentialId);
6053
+ const token = await getAccessToken();
6054
+ if (token) {
6055
+ reportPasskeyActivity(apiBaseUrl, token, credentialId).catch(() => {
6056
+ });
6057
+ }
6058
+ const resolved = resolvePostAuthStep({
6059
+ hasPasskey: true,
6060
+ accounts,
6061
+ persistedMobileFlow: loadMobileFlowState(),
6062
+ mobileSetupInProgress: mobileSetupFlowRef.current,
6063
+ connectingNewAccount: false
6064
+ });
6065
+ if (resolved.clearPersistedFlow) clearMobileFlowState();
6066
+ dispatch({ type: "NAVIGATE", step: resolved.step });
6067
+ }, [getAccessToken, apiBaseUrl, accounts, mobileSetupFlowRef, dispatch]);
6049
6068
  const completePasskeyRegistration = react.useCallback(async (credentialId, publicKey) => {
6050
6069
  const token = await getAccessToken();
6051
6070
  if (!token) throw new Error("Not authenticated");
@@ -6066,6 +6085,13 @@ function usePasskeyHandlers(dispatch, apiBaseUrl, accounts, knownCredentialIds,
6066
6085
  dispatch({ type: "SET_REGISTERING_PASSKEY", value: true });
6067
6086
  dispatch({ type: "SET_ERROR", error: null });
6068
6087
  try {
6088
+ if (knownCredentialIds.length > 0) {
6089
+ const matched = await findDevicePasskey(knownCredentialIds);
6090
+ if (matched) {
6091
+ await activateExistingCredential(matched);
6092
+ return;
6093
+ }
6094
+ }
6069
6095
  const passkeyDisplayName = user?.email?.address ?? user?.google?.name ?? user?.id ?? "Swype User";
6070
6096
  const { credentialId, publicKey } = await createPasskeyCredential({
6071
6097
  userId: user?.id ?? "unknown",
@@ -6085,12 +6111,24 @@ function usePasskeyHandlers(dispatch, apiBaseUrl, accounts, knownCredentialIds,
6085
6111
  } finally {
6086
6112
  dispatch({ type: "SET_REGISTERING_PASSKEY", value: false });
6087
6113
  }
6088
- }, [user, completePasskeyRegistration, dispatch]);
6114
+ }, [user, knownCredentialIds, activateExistingCredential, completePasskeyRegistration, dispatch]);
6089
6115
  const handleCreatePasskeyViaPopup = react.useCallback(async () => {
6090
6116
  dispatch({ type: "SET_REGISTERING_PASSKEY", value: true });
6091
6117
  dispatch({ type: "SET_ERROR", error: null });
6092
6118
  try {
6093
6119
  const token = await getAccessToken();
6120
+ if (knownCredentialIds.length > 0) {
6121
+ const matched = await findDevicePasskeyViaPopup({
6122
+ credentialIds: knownCredentialIds,
6123
+ rpId: resolvePasskeyRpId(),
6124
+ authToken: token ?? void 0,
6125
+ apiBaseUrl
6126
+ });
6127
+ if (matched) {
6128
+ await activateExistingCredential(matched);
6129
+ return;
6130
+ }
6131
+ }
6094
6132
  const passkeyDisplayName = user?.email?.address ?? user?.google?.name ?? user?.id ?? "Swype User";
6095
6133
  const popupOptions = buildPasskeyPopupOptions({
6096
6134
  userId: user?.id ?? "unknown",
@@ -6119,7 +6157,7 @@ function usePasskeyHandlers(dispatch, apiBaseUrl, accounts, knownCredentialIds,
6119
6157
  } finally {
6120
6158
  dispatch({ type: "SET_REGISTERING_PASSKEY", value: false });
6121
6159
  }
6122
- }, [user, getAccessToken, apiBaseUrl, accounts, mobileSetupFlowRef, dispatch]);
6160
+ }, [user, knownCredentialIds, getAccessToken, apiBaseUrl, activateExistingCredential, accounts, mobileSetupFlowRef, dispatch]);
6123
6161
  const handleVerifyPasskeyViaPopup = react.useCallback(async () => {
6124
6162
  dispatch({ type: "SET_VERIFYING_PASSKEY", value: true });
6125
6163
  dispatch({ type: "SET_ERROR", error: null });