getOrCreatePasskeyOwner is always creating a new passkey
Closed this issue · 3 comments
Hi guys! How is it going? Hope you are doing well :)
I'm playing a little bit with different SDKs and really like the experience and the interactive documentation of the ZeroDev team, but now I'm struggling with the getOrCreatePasskeyOwner
method.
When I use createPasskeyOwner
always creates a new one and with getPasskeyOwner
always get the same but if I use getOrCreatePasskeyOwner
is not using my last passkey but instead of it creates a new one every time I call it.
Do you know what could be? Please and thank you :)
Minimal example
import { ECDSAProvider } from "@zerodev/sdk";
import { getOrCreatePasskeyOwner } from "@zerodev/sdk/passkey";
import { useState } from "react";
const projectId = ""; // Your project ID
function Passkey() {
const [isPasskeyLoading, setIsPasskeyLoading] = useState(false);
const [address, setAddress] = useState("");
const getOrCreatePasskey = async () => {
setIsPasskeyLoading(true);
try {
const passkeyOwner = await getOrCreatePasskeyOwner({
projectId: projectId,
name: "ZeroDev",
});
if (passkeyOwner) {
const ecdsaProvider = await ECDSAProvider.init({
projectId,
owner: passkeyOwner,
});
setAddress(await ecdsaProvider.getAddress());
}
} catch (_) {}
setIsPasskeyLoading(false);
};
return (
<>
<button onClick={isPasskeyLoading ? undefined : getOrCreatePasskey}>
{isPasskeyLoading ? "..." : "Get or create passkey owner"}
</button>
{address && <p>Your address: {address}</p>}
</>
);
}
export default Passkey;
If I am not wrong the expected flow is calling createPasskeyOwner
and then the fallback that is getPasskeyOwner
but the desired is calling createPasskeyOwner
only if there is no previous passkey for the project selected. Am I right?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs