Fourt SDK
The Fourt Software Development Kit (SDK) is a TypeScript library that allows you to interact with the Fourt.io authentication service. With it, you can sign in users with via multiple authentication methods. In this guide, you will be guided through Fourt.io's onboarding process and using the SDK to authenticate users.
Create your Fourt.io Application
- Go to the Fourt.io Dashboard (opens in a new tab) and sign in with your account. If you don't have an account, you can create one here (opens in a new tab).
- On the sidebar, click on All apps and then click on Create app button.
- After creating an application, you will be redirected to the application's page. Here you will find your API key under a blurred box. Click on the Copy button to copy it.
Using the Fourt.io SDK
Installation
sh pnpm add @fourt/sdk
Initialize a signer
The simplest way to use the Fourt.io API is through the SDK. To do this, you will need to instantiate the SDK with your API key.
To initialize the SDK, you will need to pass your API key to the one of the signer constructors. You will also be asked to provide additional options for authentication methods. As of now, the SDK only supports authentication through passkeys (see Web Authentication (opens in a new tab)), and thus only FourtWebSigner
is available. See the Signers page for more information.
import { FourtWebSigner } from "@fourt/sdk";
const fourtWebSigner = new FourtWebSigner({
auth: {
webauthn: {
rpId: "localhost",
},
},
configuration: {
apiKey: "<YOUR_API_KEY>",
},
});
Authenticate a user
Authenticating a user is as simple as calling the signIn
method on the Signer instance for the desired authentication method. For this example, we will use the passkeys method.
fourtWebSigner.auth.passkeys.signIn({
email,
});
At any moment afterwards, you can get the user's information by reading the value of the info
property on the Signer instance. This will return a User
(exported by @fourt/sdk/types
) object containing the user's information:
const user = await fourtWebSigner.user.info;
Examples
We have crafted a few examples to help you get started with the Fourt SDK.
Web
- Marketplace Demo Application (opens in a new tab): a React web application that allows you to sign in with passkeys and interact with an ERC20 token marketplace.