1.5.0 • Published 3 months ago
@socketfi/sdk v1.5.0
🔌 SocketFi SDK
A lightweight JavaScript SDK for connecting to a SocketFi Smart Wallet from your web app.
This SDK provides a simple interface to:
- Initiate a SocketFi smart wallet connection
- Retrieve active session
- Log out and clear the session
⚙️ Installation
You can install this SDK via npm:
npm install @socketfi-sdk
How to use SocketFi SDK
1. Import the SDK
import {
socketConnect,
getSocketSession,
deleteSocketSession,
} from "@socketfi/sdk";
2. Initiate a Connection
This triggers a full-screen modal that lets the user connect their SocketFi smart wallet via passkey login.
const { userProfile, accessToken } = await socketConnect();
console.log("Connected user:", userProfile);
3. Get the Active Session
Check if the user is already connected:
const session = await getSocketSession();
if (session) {
console.log("User is already connected:", session.userProfile);
} else {
console.log("No active session.");
}
4. Clear the Session
To log out or disconnect the current user:
await deleteSocketSession();
console.log("User session cleared.");