@swype-org/react-sdk 0.1.151 → 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 +40 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +40 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -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
|
|
3340
|
+
const buttonLabel = popupFallback ? "Open Passkey Window" : "Verify Passkey";
|
|
3341
3341
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3342
3342
|
ScreenLayout,
|
|
3343
3343
|
{
|
|
@@ -6047,6 +6047,24 @@ function resolveRestoredMobileFlow(transferStatus, isSetup) {
|
|
|
6047
6047
|
function usePasskeyHandlers(dispatch, apiBaseUrl, accounts, knownCredentialIds, mobileSetupFlowRef) {
|
|
6048
6048
|
const { user, getAccessToken } = reactAuth.usePrivy();
|
|
6049
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]);
|
|
6050
6068
|
const completePasskeyRegistration = react.useCallback(async (credentialId, publicKey) => {
|
|
6051
6069
|
const token = await getAccessToken();
|
|
6052
6070
|
if (!token) throw new Error("Not authenticated");
|
|
@@ -6067,6 +6085,13 @@ function usePasskeyHandlers(dispatch, apiBaseUrl, accounts, knownCredentialIds,
|
|
|
6067
6085
|
dispatch({ type: "SET_REGISTERING_PASSKEY", value: true });
|
|
6068
6086
|
dispatch({ type: "SET_ERROR", error: null });
|
|
6069
6087
|
try {
|
|
6088
|
+
if (knownCredentialIds.length > 0) {
|
|
6089
|
+
const matched = await findDevicePasskey(knownCredentialIds);
|
|
6090
|
+
if (matched) {
|
|
6091
|
+
await activateExistingCredential(matched);
|
|
6092
|
+
return;
|
|
6093
|
+
}
|
|
6094
|
+
}
|
|
6070
6095
|
const passkeyDisplayName = user?.email?.address ?? user?.google?.name ?? user?.id ?? "Swype User";
|
|
6071
6096
|
const { credentialId, publicKey } = await createPasskeyCredential({
|
|
6072
6097
|
userId: user?.id ?? "unknown",
|
|
@@ -6086,12 +6111,24 @@ function usePasskeyHandlers(dispatch, apiBaseUrl, accounts, knownCredentialIds,
|
|
|
6086
6111
|
} finally {
|
|
6087
6112
|
dispatch({ type: "SET_REGISTERING_PASSKEY", value: false });
|
|
6088
6113
|
}
|
|
6089
|
-
}, [user, completePasskeyRegistration, dispatch]);
|
|
6114
|
+
}, [user, knownCredentialIds, activateExistingCredential, completePasskeyRegistration, dispatch]);
|
|
6090
6115
|
const handleCreatePasskeyViaPopup = react.useCallback(async () => {
|
|
6091
6116
|
dispatch({ type: "SET_REGISTERING_PASSKEY", value: true });
|
|
6092
6117
|
dispatch({ type: "SET_ERROR", error: null });
|
|
6093
6118
|
try {
|
|
6094
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
|
+
}
|
|
6095
6132
|
const passkeyDisplayName = user?.email?.address ?? user?.google?.name ?? user?.id ?? "Swype User";
|
|
6096
6133
|
const popupOptions = buildPasskeyPopupOptions({
|
|
6097
6134
|
userId: user?.id ?? "unknown",
|
|
@@ -6120,7 +6157,7 @@ function usePasskeyHandlers(dispatch, apiBaseUrl, accounts, knownCredentialIds,
|
|
|
6120
6157
|
} finally {
|
|
6121
6158
|
dispatch({ type: "SET_REGISTERING_PASSKEY", value: false });
|
|
6122
6159
|
}
|
|
6123
|
-
}, [user, getAccessToken, apiBaseUrl, accounts, mobileSetupFlowRef, dispatch]);
|
|
6160
|
+
}, [user, knownCredentialIds, getAccessToken, apiBaseUrl, activateExistingCredential, accounts, mobileSetupFlowRef, dispatch]);
|
|
6124
6161
|
const handleVerifyPasskeyViaPopup = react.useCallback(async () => {
|
|
6125
6162
|
dispatch({ type: "SET_VERIFYING_PASSKEY", value: true });
|
|
6126
6163
|
dispatch({ type: "SET_ERROR", error: null });
|